The DIV floating effect (fixed position) is implemented purely with CSS, and is compatible with commonly used browsers: IE8, 360, FireFox, Chrome, Safari, Opera, Maxthon, Sogou, The World, etc. The effect is as follows: Implementation code: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <title>DIV suspension example - pure CSS implementation</title> <style type="text/css"> /*Set the height, you can scroll up and down*/ body { height: 1800px; background:#dddddd; } /*div general style*/ div{ background: #1a59b7; color:#ffffff; overflow: hidden; z-index: 9999; position: fixed; padding:5px; text-align:center; width: 175px; height: 22px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; } /*upper right corner*/ div.right_top{ right: 10px; top: 10px; } /*lower right corner*/ div.right_bottom{ right: 10px; bottom: 10px; } /*Middle of the screen*/ div.center_{ right: 45%; top: 50%; } /*upper left corner*/ div.left_top{ left: 10px; top: 10px; } /*lower left corner*/ div.left_bottom{ left: 10px; bottom: 10px; } </style> </head> <body> <div class="right_top"> I am the div floating in the upper right corner</div> <div class="right_bottom"> I am the div floating in the lower right corner</div> <div class="center_"> I am the div floating in the middle of the screen</div> <div class="left_top"> I am the div suspended in the upper left corner</div> <div class="left_bottom"> I am the div suspended in the lower left corner</div> </body> </html> This concludes this article about sample code for implementing DIV suspension with pure CSS (fixed position). For more relevant CSS DIV suspension content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: Two ways to clear float in HTML
>>: JavaScript destructuring assignment detailed explanation
Table of contents 1. Introduction 2. Configure My...
In the later stage of exploiting SQL injection vu...
1. Command Introduction The ipcs command is used ...
Table of contents 1. Create a Hadoop directory in...
Table of contents process Demo Mini Program Backe...
To achieve the following goals: Mysql database wi...
1. To build a PPTP VPN, you need to open port 172...
Website administrators often accidentally delete ...
OBS studio is cool, but JavaScript is cooler. Now...
This article example shares the specific code of ...
The so-called connection limit in Nginx is actual...
Using NULL in comparison operators mysql> sele...
Table of contents Step 1: Installation Step 2: Ci...
getElementById cannot get the object There is a s...
Table of contents Interpolation Expressions metho...