点击按钮弹窗DIV及弹窗细节


简单分析一下弹窗,先放代码

这是样式:

      .black_overlay{ 
           display: none; 
            position: absolute; 
            top: 0%; 
           left: 0%; 
            width: 100%; 
            height: 100%; 
            background-color: black;`
            z-index:1001; 
            -moz-opacity: 0.8; 
            opacity:.80; 
            filter: alpha(opacity=88); 
        } 
        .white_content { 
            display: none; 
            position: absolute; 
            top: 25%; 
            left: 25%; 
            width: 55%; 
            height: 55%; 
            padding: 20px; 
            border: 10px solid orange; 
            background-color: white; 
            z-index:1002; 
            overflow: auto; 
        } 

这是body

   <p>在这里可以添加一些解释文字:
   <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">请点这里</a>
   </p> 

这里是弹窗内容

  <div id="light" class="white_content">
  在这里可以编辑一个层窗口程序. 
  <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">点这里关闭本窗口</a></div>`
  <div id="fade" class="black_overlay"></div> 

style.display='block' 有什么效果

定义和用法
display 属性设置或返回元素的显示类型。

HTML 中的元素大多是"内联"或"块"元素:一个内联元素,在其左侧和右侧都是浮动内容。一个块元素填满整个行,并没有什么可显示在其左侧或右侧。

display 属性还允许作者显示或隐藏一个元素。与 visibility 属性类似。然而,如果您设置 display:none,将隐藏整个元素,如果您设置 visibility:hidden,元素的内容将不可见,但元素保持原来的位置和大小。

语法
设置 display 属性:

Object.style.display="value"
返回 display 属性:

Object.style.display

描述
block 元素呈现为块级元素。
compact 元素呈现为块级元素或内联元素,取决于上下文。
inherit display 属性的值从父元素继承。
inline 默认。元素呈现为内联元素。
inline-block 元素呈现为内联盒子内的块盒子。
inline-table 元素呈现为内联表格(类似 <table>),表格前后没有换行符。
list-item 元素呈现为列表。
marker 该值在盒子前后设置内容作为标记(与 :before 和 :after 伪元素一起使用,否则该值与 "inline" 是相同的)。
none 元素不会被显示。
run-in 元素呈现为块级或内联元素,取决于上下文。
table 元素呈现为块级表格(类似 <table>),表格前后带有换行符。
table-caption 元素呈现为表格标题(类似 <caption>)。
table-cell 元素呈现为表格单元格(类似 <td> 和 <th>)。
table-column 元素呈现为单元格的列(类似 <col>)。
table-column-group 元素呈现为一个或多个列的分组(类似 <colgroup>)。
table-footer-group 元素呈现为表格页脚行(类似 <tfoot>)。
table-header-group 元素呈现为表格页眉行(类似 <thead>)。
table-row 元素呈现为表格行(类似 <tr>)。
table-row-group 元素呈现为一个或多个行的分组(类似 <tbody>)。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM