博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
3个简单CSS实现的动态效果
阅读量:5425 次
发布时间:2019-06-15

本文共 3241 字,大约阅读时间需要 10 分钟。

这里只是鼠标移入的时候出现的动态效果,并没有使用CSS的动画属性animation和变形属性transform。后面再补。。。

HTML代码如下:

<!DOCTYPE html>

<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<link rel="stylesheet" type="text/css" href="font_edpqa2m2qpp3c8fr/iconfont.css">
<link rel="stylesheet" href="index.css">
<body>
<div id="main">

// 每个li为一个框

<ul class="u1-items">
<li>
<div class="first"><img class="first-img" src="images/480_yugao.jpg" alt=""/>
<div class="items-icon">
<span><i class="iconfont icon-favorite"></i>
</span>
<span><i class="iconfont icon-caigou"></i></span>
</div>
<div class="items-txt">
<h2><span class="items-txt1">WARM </span><span class="items-txt2">OSCAR</span></h2>
</div>
</div>
</li>
<li>
<div class="second">
<img class="second-img" src="images/12.jpg"><h2><span>STRANGE</span><span>DEXTER</span></h2>
<h3>Dexter had his own strange way. You could watch him training ants.</h3>
<div class="items2-bd"> </div>
</div>
</li>

<li>

<div class="last">
<img src="images/1.jpg">
<h2><i class="iconfont icon-yinle"></i><span> Sweet </span><span>Marley</span></h2>
<div class="last-bd">

</div>

<div class="last-txt">

<p>Marley tried to convince her but she was not interested.</p>
</div>
</div>
</li>
</ul>
</div>
</body>
</html>

Css代码:

#main ul li{

list-style-type: none;
width:360px;
height:360px;
display: inline-block;
padding:30px;

}

ul li img{
width: 360px;
height: 360px;
position: absolute;
}
.items-icon{
position: absolute;
margin-top: 300px;
margin-left: 300px;
z-index:1;
opacity: 0;
width: 100px;
height: 100px;
-webkit-transition: all 1s;
}
.second-img{
opacity: 0.9;
-webkit-transition: all 1s;
}
.second:hover .second-img{
opacity: 1;
}
.items-txt:hover{
opacity:0;
}
.first:hover .items-icon{
opacity: 1;
}
.items-txt{
background-color: rgba(43,43,43,0.6);
position:absolute;
z-index: 2;
width:360px;
height: 360px;
color: #fff;
-webkit-transition: all 1s;
}
.items-txt h2{
margin-left:20px;
margin-top:40px;
display: inline-block;
}
.second:hover h3{
opacity: 1;
}
.second:hover .items2-bd{
margin-top:180px;
}
.second h3{
display: inline-block;
position: absolute;
color: #ffffff;
font-size: 18px;
width: 200px;
margin-left: 70px;
margin-top: 200px;
opacity: 0;
-webkit-transition: all 1s;
}

.last h2{

color: #ffffff;
position: absolute;
margin-left: 120px;
margin-top: 90px;
-webkit-transition: all 1s;
}
.last-txt{
opacity: 0;
-webkit-transition: all 1s;
}
.last-bd{
border: 1px solid #ffffff;
height: 5px;
width: 300px;
margin: 0 auto;
position: absolute;
background-color: #ffffff;
margin-top: 150px;
margin-left: 30px;
opacity: 0;
-webkit-transition: all 1s;

}

.last-txt p{
color: #fff;
font-weight: 400;
margin-top: 200px;
font-size: 25px;
margin-left: 30px;
}

.last:hover h2{

margin-top:40px;
}
.last:hover .last-bd{
opacity: 1;
margin-top:70px;
}
.last:hover .last-txt{
opacity: 1;
}
.last-txt {
width:300px;
text-align: right;
position: absolute;
}
.last hr{
position:absolute;
}

.second h2{

display: inline-block;
position:absolute;
color: #ffffff;
margin-left: 70px;
margin-top: 60px;
}
.items2-bd{
display: inline-block;
width:270px;
height: 135px;
border:10px solid #ffffff;
position: absolute;
margin-left: 35px;
margin-top: 20px;
-webkit-transition: all 1s;
}

 

转载于:https://www.cnblogs.com/qiuqiuling/p/9049676.html

你可能感兴趣的文章
导弹拦截
查看>>
ASP.NET CMD WebShell
查看>>
专访阿里资深研发工程师窦贤明:PG与商业数据库差距并不明显
查看>>
angular.lowercase()
查看>>
A - Higher Math (LightOJ - 1053)
查看>>
hnsdfz -- 6.20 -- day5
查看>>
内核--时间
查看>>
Oracle nest table -- 嵌套表的使用
查看>>
编写高质量代码改善C#程序的157个建议——建议20:使用泛型集合代替非泛型集合...
查看>>
编写高质量代码改善C#程序的157个建议——建议75:警惕线程不会立即启动
查看>>
python-字典的使用
查看>>
[ACM] poj 2249 Binomial Showdown (排列组合公式优化)
查看>>
目前的前端框架有哪些
查看>>
中小企业大数据应用之道:思维在于借力
查看>>
web项目log日志查看分析->流程理解
查看>>
ZOJ 3949 (17th 浙大校赛 B题,树型DP)
查看>>
【ZJOI 2018】线图(树的枚举,hash,dp)
查看>>
System.IO.StreamWriter写文件
查看>>
雷林鹏分享:jQuery EasyUI 应用 - 创建展开行明细编辑表单的 CRUD 应用
查看>>
时间戳和当前时间互相转化
查看>>