Home > Web Front-end > CSS Tutorial > Example code of how CSS implements hover dynamic effects

Example code of how CSS implements hover dynamic effects

黄舟
Release: 2017-09-30 09:37:48
Original
2440 people have browsed it


【CSS to achieve hover dynamic effect】


##

<!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>
Copy after login


The above is the detailed content of Example code of how CSS implements hover dynamic effects. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template