CSS如何?hover動態效果的範例程式碼

來源:互聯網
上載者:User


【CSS實現hover動態效果】


<!DOCTYPE html><html>    <head>        <meta charset="utf-8">    </head>    <style type="text/css">        .wrap {            width: 500px;            height: 500px;            margin: 0 auto;            border: 1px solid blue;        }        .con {            width: 80%;            height: 100px;            margin: 40px auto;            border: 1px solid black;        }        /*必須在父級hover,相容:IE6+*/        .one:hover p {            color: red;        }        /*標籤內要加data-title屬性,相容:IE9+*/        .two:hover::before {            content: attr(data-title);/*取到data-title屬性的值*/            color: green;        }        .three:hover::after {            content: attr(data-title);/*取到data-title屬性的值*/            color: blue;        }    </style>    <body>        <p>            <p class="con one">                <span>滑鼠移進來</span>                <p>顏色會變哦</p>            </p>            <p class="con two" data-title="看我七十二變">                <span>滑鼠移進來</span>                <p>文字會變哦</p>            </p>            <p class="con three" data-title="看我七十二變">                <span>滑鼠移進來</span>                <p>文字會變哦</p>            </p>        </p>    </body></html>

相關文章

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.