13 - CSS3 - 邊框圓角 - 鐘錶

weixin_34075551發表於2017-03-04

本文是針對剛學程式設計的小白,都是一些基礎知識,如果想了解更多深層一點的東西,歡迎移步本人部落格!!
部落格地址 點選跳轉


< ! ---------- HTML ----------- >

<div class="clock">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div class="cover"></div>
    <div class="hour"></div>
    <div class="minute"></div>
    <div class="second"></div>
    <div class="dot"></div>
</div>

< ! --------- Style --------------- >

<style>
    *{
        margin: 0;
        padding: 0;
    }
    .clock{
        width: 400px;
        height: 400px;
        margin: 100px auto;
        border: 10px solid #000;
        box-sizing: border-box;
        border-radius: 50%;
        position: relative;
    }
    .clock div{
        width: 8px;
        height: 380px;
        background-color: #ccc;
        position: absolute;
        left: 50%;
        margin-left:-4px;
    }
    .clock div:nth-child(1){
        width: 14px;
        margin-left:-7px;
    }
    .clock div:nth-child(2){
        transform: rotateZ(30deg);
    }
    .clock div:nth-child(3){
        transform: rotateZ(60deg);
    }
    .clock div:nth-child(4){
        transform: rotateZ(90deg);
        width: 14px;
        margin-left:-7px;
    }
    .clock div:nth-child(5){
        transform: rotateZ(120deg);
    }
    .clock div:nth-child(6){
        transform: rotateZ(150deg);
    }
    .clock .cover{
        width: 320px;
        height: 320px;
        background-color: white;
        border-radius: 50%;
        margin-left:-160px;
        top: 50%;
        margin-top:-160px;
    }
    .clock .hour{
        width: 20px;
        height: 100px;
        background-color: black;
        margin-left:-10px;
        top: 100px;
        animation: sport 43200s linear 0s infinite normal;
    }
    .clock .minute{
        width: 14px;
        height: 120px;
        background-color: black;
        margin-left:-7px;
        top: 80px;
        animation: sport 3600s linear 0s infinite normal;
    }
    .clock .second{
        width: 10px;
        height: 150px;
        background-color: red;
        margin-left:-5px;
        top: 50px;
        animation: sport 60s steps(60) 0s infinite normal;
    }
    .clock .dot{
        width: 30px;
        height: 30px;
        background-color: black;
        border-radius: 50%;
        margin-left:-15px;
        top: 50%;
        margin-top:-15px;
    }
    @keyframes sport {
        from{
            transform: rotateZ(0deg);
            transform-origin: center bottom;
        }
        to{
            transform: rotateZ(360deg);
            transform-origin: center bottom;

        }
    }
</style>

< ! --------- 效果展示 ---------- >

3359912-86a3344a0e765b77.gif
**鐘錶**

相關文章