CSS + radius 五環,cssradius五環

來源:互聯網
上載者:User

CSS + radius 五環,cssradius五環

使用CSS的外鏈方式,寫了一個五環

CSS的布局

附加radius的使用

思路:

一個大盒子裡放兩個子盒子;

兩個子盒子上下排列,分別放3個和2個盒子用來製作圓環;

大盒子給相對定位,連個子盒子設為絕對位置;

用到CSS中的 border-radius 方法製作圓環,前提是用來製作圓環的五個盒子要添加邊框 border 這個屬性

 
html代碼

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />

        <!--CSS的外鏈方式-->
        <link rel="stylesheet" href="css/base.css" />
        <title>五環</title>
    </head>
    <body>
        <!--給一個大盒子外框-->
        <div class="radius">
            <!--子盒子一放上面三個環-->
            <div class="sub">
                <div class="b-r a"></div>
                <div class="b-r b"></div>
                <div class="b-r c"></div>
            </div>
            <!--子盒子二放下面兩個環-->
            <div class="sup">
                <div class="b-r d"></div>
                <div class="b-r e"></div>
            </div>
        </div>
    </body>
</html>

 
CSS代碼 /*給外面的盒子添加樣式和定位,主要是為了給五個環一個整體的定位*/
.radius{
    position: relative;
    width: 300px;
    height: 150px;
    margin: 0 auto;
    padding: 0;
    background-color: lightskyblue;
}

/*給五個將要設定成環的盒子統一設定CSS樣式*/
.b-r{
    float: left;
    width: 80px;
    height: 80px;
    border-radius: 50%;/*radius的使用,給一個正方形設定50%可製作一個圓*/
}
/*分別給五個環盒子添加邊框和顏色,邊框即圓環*/
.a{
    border: 10px solid blue;
}
.b{
    border: 10px solid black;
}
.c{
    border: 10px solid green;
}
.d{
    border: 10px solid yellow;
}
.e{
    border: 10px solid red;
}

/*然後對上三個環和下兩個環進行絕對位置,構成一個五環標記圖*/
.sub{
    width: 300px;
    height: 100px;
    position: absolute;
    float: left;
    /*background-color: aquamarine;*/
}
.sup{
    width: 200px;
    height: 100px;
    position: absolute;
    margin: 50px;  
    /*background-color: cornflowerblue;*/
}

 

這是最終的效果

陌陌說:我們在使用CSS的布局時,可以先構思出一個整體的畫面和給對應盒子臨時性添加背景顏色,這樣是有協助我們看清盒子之間的層級關係從而提高效率哦

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.