css3常用动效以及总结

(迁移自旧博客2017 08 06)

CSS3 文本效果:

box-shadow:盒子阴影,可以给卡片添加提高美化效果。可广泛应用于内容展示页面。
<div class="card">
  <div class="header">
    <h1>7</h1>
  </div>

  <div class="container">
    <p>January 7, 2017</p>
  </div>
</div>
div.card {
   250px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  text-align: center;
}

div.header {
    background-color: #4CAF50;
    color: white;
    padding: 10px;
    font-size: 40px;
}

div.container {
    padding: 10px;
}

效果如下:


<div class="polaroid">
  <img src="rock600x400.jpg" alt="Norway" style="100%">
  <div class="container">
    <p>Hardanger, Norway</p>
  </div>
</div>
div.polaroid {
   250px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  text-align: center;
}

div.container {
  padding: 10px;
}

效果如下:

css3 过渡:

最简单的过渡是一个div,给它加上如下代码,便可以从宽度100px华丽的过渡到宽度为300px。
div
{
	100px;
	height:100px;
	background:red;
	transition:width 2s;
	-webkit-transition:width 2s; /* Safari */
}

div:hover
{
	300px;
}

那么再来点高级的,我们经常在页面上看到炫酷的动效,其实仔细分析,你会发现它并不难做,好多华丽的效果甚至都用不到js就能实现,比如下面这个例子。

<div class="box">
		<div class="describe">css3</div>
		<div class="describe">过渡</div>
	</div> 
.box {
     100px;
    height: 60px;
    background: #BCEE68;
	color:white;
	font-weight:bold;
    -webkit-transition: width 1s, height 1s,font-size 1s, color 1s,-webkit-transform 1s; /* For Safari 3.1 to 6.0 */
    transition: width 1s, height 1s, color 1s,font-size 1s, transform 1s;
}

.box:hover {
     150px;
    height: 90px;
	background:#9B30FF;
    -webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */
    transform: rotate(360deg);
	font-size:20px;
}
.describe{
	text-align:center;
}

效果非常炫酷,不是静态所以就不上图了,有兴趣的自己试下。可以用作展示页,也可以用作一行导航菜单,会反转变样式的一组菜单很时尚的嘿嘿。

原文地址:https://www.cnblogs.com/ym7583306/p/10390236.html