In CSS, you can use the position positioning attribute to make the div fixed. This attribute is used to specify the positioning type of the element. When the value of the attribute is "fixed", a fixed positioning element is generated. The position of the element is fixed relative to the browser. No change, the syntax is "div{position:fixed;}".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
How to fix the div in css
In css, you can use the position positioning attribute to fix the position of the div on the page. The following example explains how to fix the position of div with css.
The example is as follows:
<html> <head> <style type="text/css"> div{ position:fixed; left:5px; top:5px; width:50px; height:50px; background-color:red; } </style> </head> <body> <div></div> <br/> <br/><br/><br/><br/><br/><br/><br/><br/><bbr/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><brr/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>sergsergsgs<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></><br/><br/> </body> </html>
Output result:
(Learning video sharing: css video tutorial)
The above is the detailed content of How to make div fixed with css. For more information, please follow other related articles on the PHP Chinese website!