鼠标经过,图片移动,图片内字体上移,还有图片的旋转实例
工具/原料
html
方法/步骤
1、搜索素材,分析图片效果<!DOCTYPEhtml><html><head><metacharset="UTF-8"><title></title><styletype="text/css">*{padding:0;margin:0;}消除图片及其他的默认填充,边框ul,ol{list-style:none;}消除ul,ol的样式body{background:#555;width:1000px;height:1000px;}设置body的高宽,背景色
2、#aa{width:400px;height:300px;margin:50px;overflow:hidden;position:relative;float:left;}布局,浮动,相对定位(字体绝对定位),超出隐藏#aaimg{left:-80px;position:absolute;}#aa:hoverimg{left:0;transition:left0.5s;}#aah2{font-size:30px;color:#FFF;position:absolute;top:250px;left:30px;font-weight:normal;}设置字体颜色大小,位置#aa:hoverh2{top:180px;transition:top0.5s;}鼠标经过样式#aaspan{font-weight:bold;}
3、#aap{position:absolute;left:30px;top:260px;color:#fff;opacity:0;}字体初始位置,透明对0,#aa:hoverp{top:215px;opacity:1;transition:top0.7s,opacity0.5s0.2s;}opacity透明度#color{background:#00f;opacity:0.2;position:absolute;top:0;left:0;width:400px;height:300px;}#color:hover{opacity:0;transition:opacity;}
4、#bb{animation:abc2sinfinite;width:400px;height:400px;margin:50px;background:#666;float:left;position:relative;}@keyframesabc{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}设置动画,旋转@keyframesa{0%{transform:rotate(0deg);}25%{transform:rotate(360deg);}50%{transform:rotate(360deg);}75%{transform:rotate(360deg);}100%{transform:rotate(360deg);}}
5、#m1{float:left;width:200px;height:咯悝滩镞200px;background:#0000FF;animation:abc1s足毂忍珩infinite;}#m2{float:left;width:200px;height:200px;background:#00ffFF;animation:abc1sinfinite;}#m3{float:left;width:200px;height:200px;background:#0F0;animation:abc1sinfinite;}#m4{float:left;width:200px;height:200px;background:#ff00FF;animation:abc1sinfinite;}#m5{position:absolute;top:100px;left:100px;background:#48d;width:200px;height:200px;animation:a2sinfinite;}</style></head>田字格的设置,
6、<body><divid="aa"&g隋茚粟胫t;<imgsrc="img/bhua.j禊诬娱飑pg"/><h2>NICE<span>LILY</span></h2><p>Lilylikestoplaywithcrayonsandpencils</p><divid="color"></div></div><divid="bb"><divid="m1"></div><divid="m2"></div><divid="m3"></div><divid="m4"></div><divid="m5"></div></div></body></html>body的设置