Home >Web Front-end >CSS Tutorial >How to make a div appear at the top of the page
In CSS, you can use the "z-index" attribute to specify the stacking order of an element, with the syntax "z-index: value". The larger the value, the higher the display level; the smaller the value, the lower the display level. When the value is negative, it represents the lowest level.
The operating environment of this tutorial: Windows7 system, CSS3&&HTML5 version, Dell G3 computer.
Golden rules for cascading elements:
Whoever is bigger is better: When there is an obvious cascading level indicator, such as the effective z-index attribute value , in the same stacking context field, the one with a larger stacking level value covers the smaller one
comes from behind: When the stacking levels of elements are consistent and the stacking order is the same, in the DOM flow The element at the back will overwrite the previous element
Example:
<div style="z-index:999"></div> 数值越大,显示级越高,当然一般也不用999, 2,3就够了 <div id="police_computer_network" class="m_wrapper"> <ul> <li><a href="#" target="_blank">全国公安信息网</a></li> <li><a href="#" target="_blank">全国公安信息网</a></li> <li><a href="#" target="_blank">全国公安信息网</a></li> <li><a href="#" target="_blank">全国公安信息网</a></li> <li><a href="#" target="_blank">全国公安信息网</a></li> <li><a href="#" target="_blank">全国公安信息网</a></li> </ul> <div class="m_itemMain m_up">全国公安网</div> </div>
Recommended learning:css video tutorial
The above is the detailed content of How to make a div appear at the top of the page. For more information, please follow other related articles on the PHP Chinese website!