在項目開發中我們采用的CSS3新特性有
1.CSS3的選擇器
1)E:last-child 匹配父元素的最后一個子元素E。
2)E:nth-child(n)匹配父元素的第n個子元素E。
3)E:nth-last-child(n) CSS3 匹配父元素的倒數第n個子元素E。
2. @Font-face 特性
Font-face 可以用來加載字體樣式,而且它還能夠加載服務器端的字體文件,讓客戶端顯示客戶端所沒有安裝的字體。
-
@ font-face {
-
font-family: BorderWeb;
-
src:url(BORDERW0.eot);
-
}
-
@ font-face {
-
font-family: Runic;
-
src:url(RUNICMT0.eot);
-
}
-
.border { FONT-SIZE: 35px; COLOR: black; FONT-FAMILY: "BorderWeb" }
-
.event { FONT-SIZE: 110px; COLOR: black; FONT-FAMILY: "Runic" }
-
@ font-face {
-
font-family: iconfont;
-
src: url(//at.alicdn.com/t/font_1465189805_4518812.eot);
-
}
3. 圓角
border-radius: 15px;
4. 多列布局 (multi-column layout)
-
<div class="mul-col">
-
<div>
-
<h3>新手上路</h3>
-
<p>新手專區 消費警示 交易安全 24小時在線幫助 免費開店</p>
-
</div>
-
<div>
-
<h3>付款方式</h3>
-
<p>快捷支付 信用卡 余額寶 螞蟻花唄 貨到付款</p>
-
</div>
-
<div>
-
<h3>淘寶特色</h3>
-
<p>手機淘寶 旺信 大眾評審 B格指南</p>
-
</div>
-
</div>
-
.mul-col{
-
column-count: 3;
-
column-gap: 5px;
-
column-rule: 1px solid gray;
-
border-radius: 5px;
-
border:1px solid gray;
-
padding: 10px ;
-
}
兼容性不好,還不夠成熟。還不能用在實際項目中。
5.陰影(Shadow)
-
.class1{
-
text-shadow:5px 2px 6px rgba(64, 64, 64, 0.5);
-
}
OPPO官網的陰影特效 http://www.oppo.com/cn/products.html
6.CSS3 的漸變效果
background-image:-webkit-gradient(linear,0% 0%,100% 0%,from(#2A8BBE),to(#FE280E));
這里 linear 表示線性漸變,從左到右,由藍色(#2A8BBE)到紅色(#FE280E)的漸變。效果圖如下:
7.css彈性盒子模型
-
<div class="boxcontainer">
-
<div class="item">1</div>
-
<div class="item">2</div>
-
<div class="item">3</div>
-
<div class="item">4</div>
-
</div>
-
.boxcontainer {
-
width: 1000px;
-
display: -webkit-box;
-
display: -moz-box;
-
-webkit-box-orient: horizontal;
-
-moz-box-orient: horizontal;
-
}
-
-
.item {
-
background: #357c96;
-
font-weight: bold;
-
margin: 2px;
-
padding: 20px;
-
color: #fff;
-
font-family: Arial, sans-serif;
-
}
效果圖
8. CSS3制作特效
1) Transition 對象變換時的過渡效果
- transition-property 對象參與過渡的屬性
- transition-duration 過渡的持續時間
- transition-timing-function 過渡的類型
- transition-delay 延遲過渡的時間
縮寫方式:
transition:border-color .5s ease-in .1s, background-color .5s ease-in .1s, color .5s ease-in .1s;
拆分方式:
-
transition-property:border-color, background-color, color;
-
transition-duration:.5s, .5s, .5s;
-
transition-timing-function:ease-in, ease-in, ease-in;
-
transition-delay:.1s, .1s, .1s;
示例代碼
<style type="text/css"> .main{ position: relative; margin: 0 auto; height:45px; width: 300px; background-color:lightgray; transition:background-color .6s ease-in 0s; } .main:hover{ background-color: dimgray; } </style> <div class="main"></div>
效果顯示