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
The fixed layout of the page header was previousl...
You may encounter the following problems when ins...
In the process of team development, it is essenti...
After the changes: innodb_buffer_pool_size=576M -...
<br />I have compiled some domestic design w...
When I first started setting up an ftp server on ...
This article shares the specific code of js to im...
Result: The main part is to implement the code lo...
DIV background is semi-transparent, but the words ...
This article example shares the specific code of ...
Environment: VMware VCSA 6.7 (VMware-VCSA-all-6.7...
Written in front Environment: MySQL 5.7+, MySQL d...
Preface Let me share with you how to make a searc...
It is recommended that you do not set the width, h...
MySQL 5.5 installation and configuration method g...