(遷移自舊博客2017 08 06)
css
<div class="card"> <div class="header"> <h1>7</h1> </div> <div class="container"> <p>January 7, 2017</p> </div> </div>
div.card { width: 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; }
效果以下:
html
<div class="polaroid"> <img src="rock600x400.jpg" alt="Norway" style="width:100%"> <div class="container"> <p>Hardanger, Norway</p> </div> </div>
div.polaroid { width: 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。web
div { width:100px; height:100px; background:red; transition:width 2s; -webkit-transition:width 2s; /* Safari */ } div:hover { width:300px; }
那麼再來點高級的,咱們常常在頁面上看到炫酷的動效,其實仔細分析,你會發現它並不難作,好多華麗的效果甚至都用不到js就能實現,好比下面這個例子。3d
<div class="box"> <div class="describe">css3</div> <div class="describe">過渡</div> </div>
.box { width: 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 { width: 150px; height: 90px; background:#9B30FF; -webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */ transform: rotate(360deg); font-size:20px; } .describe{ text-align:center; }
效果很是炫酷,不是靜態因此就不上圖了,有興趣的本身試下。能夠用做展現頁,也能夠用做一行導航菜單,會反轉變樣式的一組菜單很時尚的嘿嘿。code