CSS + radius five rings, cssradius five rings

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.