How to set a certain div to be fixed in css: first create an HTML sample file; then define a div in the body; finally set the div to be fixed through attributes such as "position: fixed;".
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, DELL G3 computer
css controls a certain div to be fixed
The most common way to fix it is to position it.
But you need to pay attention when positioning:
① If you want to fix it somewhere on the screen, then make sure the parent element of the fixed element is body;
② is Fixed elements set width and height.
For example, add the following code to your footer class:
If the top is fixed
[Recommended learning:css video tutorial]
The above is the detailed content of How to set a certain block to be fixed in css. For more information, please follow other related articles on the PHP Chinese website!