As we all know, the CSS position absolute is set according to the document by default. For example, if you set left:0 and top:0 after position:absolute, the element will be displayed in the upper left corner of the page. Sometimes we need to set a relative absolute position within the container of the parent element To achieve this, you need to set the position attribute of the parent element to relative. After setting it to relative, do not set the left and top attributes. At this time, although the parent element is relative, it still remains in the original position. Then set the position of the child element to absolute, and set its left, top, right, and bottom attributes, so that it is the absolute position relative to the parent element. The following is the HTML sample code: <!doctype html> <html> <style type="text/css"> #father { position: relative; width:600px; margin:auto; height:400px; border:1px solid red; } #son1 { position: absolute; top: 0; background:#f0f0f0; } #son2 { position: absolute; bottom: 0; background:blue; } </style> <body> <div id="father"> <div id="son1">I am son1</div> <div id="son2">I am son2</div> </div> </body> </html> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Create a screen recording function with JS
>>: Detailed explanation of transaction isolation levels in MySql study notes
1. Introduction to Apache Bench ApacheBench is a ...
1. Download MySQL from the official website: This...
If you don’t understand what I wrote, there may b...
Table of contents Problem Analysis Why encapsulat...
1. Edit the docker.service file vi /usr/lib/syste...
A long time ago, I summarized a blog post titled ...
As a backend programmer, you deal with Linux in m...
background When developing a feature similar to c...
Preface With the crazy speculation of virtual cur...
Query Rewrite Plugin As of MySQL 5.7.6, MySQL Ser...
The VMware Workstation Pro version I use is: 1. F...
#mysql -uroot -p Enter password mysql> show fu...
MySQL Performance Optimization MySQL performance ...
Table of contents Message Board Required librarie...
Don't be surprised if you see some kind of und...