Preface Sometimes, we need a floating effect requirement like the following figure: accomplish In standard, normal situations, this can only be accomplished using Step 1: Set the parent container positioning to relative. Step 2: Set the subcontainer positioning to absolute. <div id="a"> <div id="b">I want to float out! </div> </div> #a{ width:400px; height:100px; background:rgb(0, 0, 0); position:relative;/*Parent element>relative positioning*/ } #b{ width: 150px; height:50px; background:rgb(185, 155, 255); position:absolute;/*Sub-element>absolute positioning*/ top:-30px;/*control floating*/ /* left:XX; */ } Effect picture: The parent element is set to Note: Only child elements will be out of the document flow. The parent element is relatively positioned and will not be out of the document flow, so it will not cause page misalignment. This concludes this article about how to use CSS to make child containers extend beyond parent elements (the effect of child containers floating in parent containers). For more information about how to use CSS to make child containers extend beyond parent elements, please search previous articles on 123WORDPRESS.COM or continue browsing the related articles below. We hope that you will support 123WORDPRESS.COM in the future! |
<<: How to set a dotted border in html
>>: A Different Kind of "Cancel" Button
Be careful when listening for events that are tri...
1. Common connections for mysql INNER JOIN (inner...
In the UI cutting process, the page is often comp...
To put it simply, the IP of the virtual machine u...
A root routing component (the root routing compon...
load Request Success Request failed Click cmd and...
Permissions and database design User Management U...
As the platform continues to grow, the project...
A colleague reported that a MySQL instance could ...
Table of contents this Method In the object Hidde...
This article example shares the specific code of ...
Table of contents 1 Introduction to nginx 1 What ...
Inserting Data insert into table name (column nam...
Cell padding is the distance between the cell con...
Table of contents Preface Rendering Example Code ...