CSS3完成可旋转的hover实际效果

日期:2021-01-20 类型:科技新闻 

关键词:怎么把小程序变成二维码,微信小程序怎么开通,微信小程序csdn,小程序开发,网络答题小程序

CSS3完成可旋转的hover实际效果,实际编码以下所示:

1.css

/*基本款式*/  
html {  
    font-family: sans-serif;  
    -ms-text-size-adjust: 100%;  
    -webkit-text-size-adjust: 100%;  
}  
body {  
    margin: 0 auto;  
    text-align: center;  
    background-color: #FFFFCC;  
}  
ul {  
    list-style: none;  
    float: left;  
    margin: 0;  
    padding: 0;  
}  
a {  
    cursor: pointer;  
}  
div {  
    display: inline-block;  
    margin: 40px;  
}  
ul li {  
    width: 200px;  
    height: 40px;  
    line-height: 40px;  
    text-align: center;  
    margin: 10px;  
    background-color: #747474;  
    border-radius: 4px;  
    color: white;  
}  
dis-block{  
    display: block;  
}  
/*#nav1电脑鼠标hover实际效果  前后左右旋转*/  
#nav1 ul li {  
    transform-style: preserve⑶d;  
    -webkit-transform-style: preserve⑶d;  
    -ms-transform-style: preserve⑶d;  
    -moz-transform-style: preserve⑶d;  
    transition: 0.5s;  
    -webkit-transition: 0.5s;  
    -ms-transition: 0.5s;  
    -moz-transition: 0.5s;  
}  
#nav1 ul li:hover {  
    transform: translateZ(30px) rotateX(360deg) scale(1.1);  
    -webkit-transform: translateZ(30px) rotateX(360deg) scale(1.1);  
    -ms-transform: translateZ(30px) rotateX(360deg) scale(1.1);  
    -moz-transform: translateZ(30px) rotateX(360deg) scale(1.1);  
}  
/*#nav2电脑鼠标hover实际效果 上浮*/  
#nav2 ul li {  
    transform-style: preserve⑶d;  
    -webkit-transform-style: preserve⑶d;  
    -ms-transform-style: preserve⑶d;  
    -moz-transform-style: preserve⑶d;  
    transition: 0.5s;  
    -webkit-transition: 0.5s;  
    -ms-transition: 0.5s;  
    -moz-transition: 0.5s;  
}  
#nav2 ul li:hover {  
    transform: translateZ(30px) scale(1.1);  
    -webkit-transform: translateZ(30px) scale(1.1);  
    -ms-transform: translateZ(30px) scale(1.1);  
    -moz-transform: translateZ(30px) scale(1.1);  
}  
/*#nav4电脑鼠标hover实际效果 下浮*/  
#nav4 ul li {  
    transform-style: preserve⑶d;  
    -webkit-transform-style: preserve⑶d;  
    -ms-transform-style: preserve⑶d;  
    -moz-transform-style: preserve⑶d;  
    transition: 0.5s;  
    -webkit-transition: 0.5s;  
    -ms-transition: 0.5s;  
    -moz-transition: 0.5s;  
}  
#nav4 ul li:hover {  
    transform: translateZ(30px) scale(0.9);  
    -webkit-transform: translateZ(30px) scale(0.9);  
    -ms-transform: translateZ(30px) scale(0.9);  
    -moz-transform: translateZ(30px) scale(0.9);  
}  
/*#nav3电脑鼠标hover实际效果 上下旋转*/  
#nav3 ul li {  
    transform-style: preserve⑶d;  
    -webkit-transform-style: preserve⑶d;  
    -ms-transform-style: preserve⑶d;  
    -moz-transform-style: preserve⑶d;  
    transition: 0.5s;  
    -webkit-transition: 0.5s;  
    -ms-transition: 0.5s;  
    -moz-transition: 0.5s;  
}  
#nav3 ul li:hover {  
    transform: translateZ(30px) rotateY(360deg) scale(1.1);  
    -webkit-transform: translateZ(30px) rotateY(360deg) scale(1.1);  
    -ms-transform: translateZ(30px) rotateY(360deg) scale(1.1);  
    -moz-transform: translateZ(30px) rotateY(360deg) scale(1.1);  
}  
/*button1 hover实际效果*/  
btn1 {  
    background-color: #1AAB8A;  
    color: white;  
    font-size: 18px;  
    height: 60px;  
    width: 150px;  
    border: 0;  
    transition: 800ms ease all;  
    outline: none;  
    position: relative;  
}  
btn1:hover {  
    background: #fff;  
    color: #1AAB8A;  
}  
btn1:before, .btn1:after {  
    content: '';  
    position: absolute;  
    height: 2px;  
    width: 0;  
    background: #1AAB8A;  
    transition: 400ms ease all;  
}  
btn1:before {  
    right: 0;  
    top: 0;  
}  
btn1:after {  
    left: 0;  
    bottom: 0;  
}  
btn1:hover:before, .btn1:hover:after {  
    width: 100%;  
    transition: 800ms ease all;  
}  

2.html

<div id="nav1">  
            <p>前后左右旋转</p>  
            <ul>  
                <li>  
                    <a>home</a>  
                </li>  
                <li>  
                    <a>js</a>  
                </li>  
                <li>  
                    <a>jquery</a>  
                </li>  
                <li>  
                    <a>div+css</a>  
                </li>  
                <li>  
                    <a>css3</a>  
                </li>  
            </ul>  
        </div>  
        <div id="nav2">  
            <p>上浮</p>  
            <ul>  
                <li>  
                    <a>home</a>  
                </li>  
                <li>  
                    <a>js</a>  
                </li>  
                <li>  
                    <a>jquery</a>  
                </li>  
                <li>  
                    <a>div+css</a>  
                </li>  
                <li>  
                    <a>css3</a>  
                </li>  
            </ul>  
        </div>  
        <div id="nav4">  
            <p>下浮</p>  
            <ul>  
                <li>  
                    <a>home</a>  
                </li>  
                <li>  
                    <a>js</a>  
                </li>  
                <li>  
                    <a>jquery</a>  
                </li>  
                <li>  
                    <a>div+css</a>  
                </li>  
                <li>  
                    <a>css3</a>  
                </li>  
            </ul>  
        </div>  
        <div id="nav3">  
            <p>上下旋转</p>  
            <ul>  
                <li>  
                    <a>home</a>  
                </li>  
                <li>  
                    <a>js</a>  
                </li>  
                <li>  
                    <a>jquery</a>  
                </li>  
                <li>  
                    <a>div+css</a>  
                </li>  
                <li>  
                    <a>css3</a>  
                </li>  
            </ul>  
        </div>  
        <div class="dis-block">  
            <p>按钮hover实际效果</p>  
            <button class="btn1" type="button">hover!</button>  
        </div>  

实际效果:



总结

以上所述是网编给大伙儿详细介绍的CSS3完成可旋转的hover实际效果,期待对大伙儿有一定的协助,假如大伙儿有任何疑惑请给我留言,网编会立即回应大伙儿的。在此也十分谢谢大伙儿对脚本制作之家网站的适用!