How to secure the navigation bar by css
This article mainly explains "how css fixes the navigation bar", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to fix the navigation bar in CSS"!
In css, you can use the position attribute to fix the navigation bar, just add the "position:fixed;" style to the navigation bar element, and fix the navigation bar relative to the browser window. In this way, the fixed navigation bar element will not change position with the dragging of the scroll bar.
Operating environment of this tutorial: Windows 7 system, CSS3 && HTML5 version, Dell G3 computer.
How does CSS fix the navigation bar?
You can add anchor to the navigation bar to anchor it. The syntax is "position:fixed;".
Examples are as follows:
Document *{margin:0;padding: 0;} ul{ list-style-type: none; overflow: hidden; background-image:url(1118.02.png); position: fixed; top: 0; width: 100%; } li { float: left; } li a { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover{ background-color: red; } home news Contact us about us
Output:
At this point, I believe that everyone has a deeper understanding of "how to fix the navigation bar in css," so you may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!