CSS + radius five rings, cssradius five rings
Using CSS external links, write a fifth ring
CSS layout Use of additional radius |
Ideas: Put two sub-boxes in a large box; Two sub-boxes are arranged up and down, and three and two boxes are respectively placed to create rings; A large box provides relative positioning, and a sub-box is set to absolute positioning; Use the border-radius method in CSS to create a ring, provided that the border attribute is added to the five boxes used to create the ring. |
|
Html code |
<! DOCTYPE html> <Html> <Head> <Meta charset = "UTF-8"/> <! -- CSS external link --> <Link rel = "stylesheet" href = "css/base.css"/> <Title> five rings </title> </Head> <Body> <! -- Give an external box --> <Div class = "radius"> <! -- Put the three rings in the sub-box --> <Div class = "sub"> <Div class = "B-r a"> </div> <Div class = "B-r B"> </div> <Div class = "B-r c"> </div> </Div> <! -- Sub-Box 2 put down two sides and two rings --> <Div class = "sup"> <Div class = "B-r d"> </div> <Div class = "B-r e"> </div> </Div> </Div> </Body> </Html>
|
|
CSS code |
/* Add style and positioning to the outer box, mainly to locate the five rings and one whole */ . Radius { Position: relative; Width: 300px; Height: 150px; Margin: 0 auto; Padding: 0; Background-color: lightskyblue; }
/* Set the CSS style for the five boxes to be set as rings */ . B-r { Float: left; Width: 80px; Height: 80px; Border-radius: 50%;/* use radius. Set 50% for a square to create a circle */ } /* Add Borders and colors to the five ring boxes respectively. The border is the ring */ . { Border: 10px solid blue; } . B { Border: 10px solid black; } . C { Border: 10px solid green; } . D { Border: 10px solid yellow; } . E { Border: 10px solid red; }
/* Then perform absolute positioning on the three rings and the next two rings to form a five-ring markup diagram */ . Sub { Width: 300px; Height: 100px; Position: absolute; Float: left; /* Background-color: aquamarine ;*/ } . Sup { Width: 200px; Height: 100px; Position: absolute; Margin: 50px; /* Background-color: cornflowerblue ;*/ }
|
|
This is the final result
Mo said: When we use CSS layout, We can first create an overall picture and temporarily Add the background color to the corresponding box, this helps us to see the hierarchical relationship between boxes to improve efficiency.