css How to implement a div that does not move with the scroll bar: first create a sample file; then set the css attribute style of the div to "position:fixed;" to fix the div from moving with the scroll bar.
The operating environment of this tutorial: Windows 7 system, HTML5&&CSS3 version, Dell G3 computer. This method is suitable for all brands of computers.
Recommended: "css video tutorial"
css set div not to move with the scroll bar
Fix a content to a certain A position, positioned relative to the browser window. Fixed positioning is used here.
Positioning usually includes absolute positioning and relative positioning. These are relative to the block elements in the body, but if you want a certain content to be in a certain position, regardless of scrolling No matter where the bar slides, it will still be in the browser window, so you need to use fixed.
The fixed element box behaves like setting position to absolute, except that its containing block is the viewport itself. Agree to have values of left, top, right, bottom. Its usage is similar to absolute.
Example:
<div style="width:100px; height:100px; border:1px solid red; position:fixed; left:300px; top:300px;"> 固定的内容 </div>
The above div has a width of 100 and a height of 100. It is 300 pixels from the upper left corner of the browser and does not scroll with the scrolling of the page.
The above is the detailed content of How to implement css div that does not move with the scroll bar. For more information, please follow other related articles on the PHP Chinese website!