框架集
框架集和內(nèi)聯(lián)框架的作用類似佳头,都是用于在一個(gè)頁面中引入其他的外部的頁面
框架集可以同時(shí)引入多個(gè)頁面,而內(nèi)聯(lián)框架只能引入一個(gè)
在h5標(biāo)準(zhǔn)中晴氨,推薦使用框架集康嘉,而不使用內(nèi)聯(lián)框架
使用frameset來創(chuàng)建一個(gè)框架集,注意frameset不能和body出現(xiàn)在同一個(gè)頁面中
所以要使用框架集籽前,頁面中就不可以使用body標(biāo)簽
- 屬性:
rows亭珍,指定框架集中的所有的框架,一行一行的排列
cols枝哄, 指定框架集中的所有的頁面肄梨,一列一列的排列
這兩個(gè)屬性frameset必須選擇一個(gè),并且需要在屬性中指定每一部分所占的大小
frameset中也可以再嵌套frameset
frameset和iframe一樣挠锥,它里邊的內(nèi)容都不會(huì)被搜索引擎所檢索
所以如果搜索引擎檢索到的頁面是一個(gè)框架頁的話众羡,它是不能去判斷里邊的內(nèi)容的
使用框架集則意味著頁面中不能有自己的內(nèi)容,只能引入其他的頁面
而我們每單獨(dú)加載一個(gè)頁面蓖租,瀏覽器都需要重新發(fā)送一次請(qǐng)求粱侣,引入幾個(gè)頁面就需要發(fā)送幾次請(qǐng)求,用戶的體驗(yàn)比較差
如果非得用建議使用frameset而不使用iframe
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>框架集</title>
</head>
<frameset cols="30%, *, 30%">
<!--
在frameset中使用frame子標(biāo)簽來指定要引入的頁面
引入幾個(gè)頁面就寫幾個(gè)frame
-->
<frame src="demo069_表格.html" />
<frame src="demo070_給表格添加樣式.html" />
<!-- 嵌套一個(gè)frameset -->
<frameset rows="30%, 50%, *">
<frame src="demo072_表格的布局.html" />
<frame src="demo073_完善clearfix.html" />
<frame src="demo074_表單.html" />
</frameset>
</frameset>
</html>
ie6png的修復(fù)
在IE6中對(duì)圖片格式png24支持度不高蓖宦,如果使用的圖片格式是png24齐婴,則會(huì)導(dǎo)致透明效果無法正常顯示
解決方法:
1.可以使用png8來代替png24,即可解決問題稠茂,但是使用png8代替png24以后柠偶,圖片的清晰圖會(huì)有所下降
2.使用JavaScript來解決該問題,需要向頁面中引入一個(gè)外部的JavaScript文件睬关,然后在寫一下簡(jiǎn)單的JS代碼诱担,來處理該問題
在body標(biāo)簽的最后引入外部的JS文件
再創(chuàng)建一個(gè)新的script標(biāo)簽,并且編寫一些js代碼
以下代碼只會(huì)在IE6中執(zhí)行电爹,其他瀏覽器中無效
<!--[if IE 6]>
<script type="text/javascript" src="js/DD_belatedPNG_0.0.8a-min.js"></script>
<script type="text/javascript">
DD_belatedPNG.fix("div,img");
</script>
<![endif]-->
條件Hack
有一些情況蔫仙,有一些特殊的代碼我們只需要在某些特殊的瀏覽器中執(zhí)行,而在其他的瀏覽器中不需要執(zhí)行藐不,這時(shí)就可以使用CSS Hack來解決該問題
CSS Hack實(shí)際上指的是一種特殊的代碼匀哄,這段代碼只在某些瀏覽器中可以識(shí)別,而其他瀏覽器不能識(shí)別雏蛮,通過這種方式涎嚼,來為一些瀏覽器設(shè)置特殊的代碼
條件Hack
它只對(duì)IE瀏覽器有效,其它的瀏覽器都會(huì)將它識(shí)別為注釋-
IE10及以上的瀏覽器已經(jīng)不支持這種方式
以下內(nèi)容只會(huì)出現(xiàn)在IE6中<!--[if IE 6]> <p>為了您和家人的健康挑秉,請(qǐng)遠(yuǎn)離IE67ㄌ荨!</p> <![endif]-->
例:
<!--[if IE 8]>
<p>當(dāng)前瀏覽器是IE8O拧立哑!</p>
<![endif]-->
<!--[if lt IE 9]>
<p>該標(biāo)簽會(huì)在IE9以下的瀏覽器中顯示</p>
<![endif]-->
<!--[if gte IE 9]>
<p>該標(biāo)簽會(huì)在IE9及以上的瀏覽器中顯示</p>
<![endif]-->
<!--[if lte IE 9]>
<p>該標(biāo)簽會(huì)在IE9及以下的瀏覽器中顯示</p>
<![endif]-->
<!--[if ! IE 6]>
<p>你的瀏覽器不是IE6</p>
<![endif]-->
屬性Hack
假設(shè)在IE6中需要將背景顏色設(shè)置為黃色才能達(dá)到和其它瀏覽器相同的效果
-
希望黃色背景只在IE6中生效
在樣式前添加一個(gè)下劃線,則該樣式只有IE6及以下的瀏覽器才可以識(shí)別_background-color: yellow;
-
添加了*的樣式只有IE7及以下的瀏覽器認(rèn)識(shí)
*background-color: yellow;
-
在樣式最后添加一個(gè)\0姻灶,則只有IE8及以上的瀏覽器才能識(shí)別
background-color: yellow\0;
CSS Hack不到萬不得已的情況盡量不要使用
CSS3過渡動(dòng)畫
1铛绰、transition-property 設(shè)置過渡的屬性,比如:width height background-color
2产喉、transition-duration 設(shè)置過渡的時(shí)間捂掰,比如:1s 500ms
3、transition-timing-function 設(shè)置過渡的運(yùn)動(dòng)方式
- linear 勻速
- ease 開始和結(jié)束慢速
- ease-in 開始是慢速
- ease-out 結(jié)束時(shí)慢速
- ease-in-out 開始和結(jié)束時(shí)慢速
- cubic-bezier(n,n,n,n)
- 比如:cubic-bezier(0.845, -0.375, 0.215, 1.335)
- 曲線設(shè)置網(wǎng)站:https://matthewlein.com/ceaser/
4曾沈、transition-delay 設(shè)置動(dòng)畫的延遲
5这嚣、transition: property duration timing-function delay 同時(shí)設(shè)置四個(gè)屬性
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS3過渡動(dòng)畫</title>
<style type="text/css">
.box{
width: 100px;
height: 100px;
background-color: gold;
/*在哪產(chǎn)生動(dòng)畫、動(dòng)畫的時(shí)間塞俱、運(yùn)動(dòng)曲線姐帚、延遲*/
/* transition: border-radius 500ms ease,width 500ms ease 500ms,height 500ms ease 1s,background-color 500ms ease 1.5s; */
transition: all 500ms ease;
}
.box:hover{
width: 500px;
height: 300px;
background-color: red;
border-radius: 50px;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
CSS3圓角、陰影障涯、rgba
CSS3圓角
設(shè)置某一個(gè)角的圓角罐旗,比如設(shè)置左上角的圓角:
border-top-left-radius:30px 60px;
同時(shí)分別設(shè)置四個(gè)角: border-radius:30px 60px 120px 150px;
設(shè)置四個(gè)圓角相同:
border-radius:50%;
.box{
width: 200px;
height: 200px;
border: 2px solid #000;
background-color: gold;
margin: 50px auto 0;
/*border-top-left-radius: 100px 50px;左上角為橢圓圓角*/
/*border-top-left-radius: 100px;
border-top-right-radius: 100px;左、右上角為正圓圓角*/
/*border-radius: 40px;曲率半徑為40的圓角矩形*/
/*border-radius: 20%;最大200px唯蝶,20%即40px*/
border-radius: 50%;/*正圓*/
}
CSS3陰影
box-shadow:h-shadow v-shadow blur spread color inset;
分別設(shè)置陰影:水平偏移 垂直偏移 羽化大小 擴(kuò)展大小 顏色 是否內(nèi)陰影
.box2{
width: 200px;
height: 40px;
background-color: gold;
margin: 100px auto 0;
/*水平偏移 垂直偏移 羽化大小 擴(kuò)展大小 顏色 是否內(nèi)陰影*/
box-shadow: 0px 0px 20px 2px red inset;
}
rgba(新的顏色值表示法)
1尤莺、盒子透明度表示法:opacity:0.1;filter:alpha(opacity=10)(兼容IE);
2、rgba(0,0,0,0.1) 前三個(gè)數(shù)值表示顏色生棍,第四個(gè)數(shù)值表示顏色的透明度
.box3{
width: 200px;
height: 200px;
/*background: url(images/location_bg.jpg);*/
background-color: gold;
margin: 50px auto 0;
border: 2px solid #000;
border-radius: 50%;
/*透明度30%颤霎,文字也透明了*/
opacity: 0.3;
filter: alpha(opacity=30);/*兼容IE*/
text-align: center;
line-height: 200px;
}
.box4{
width: 200px;
height: 200px;
/*背景色變透明,但文字不會(huì)透明*/
background-color: rgba(255,215,0,0.3);
margin: 50px auto 0;
/*邊框透明*/
border: 2px solid rgba(0,0,0,0.3);
border-radius: 50%;
text-align: center;
line-height: 200px;
}
運(yùn)動(dòng)曲線
cubic-bezier(n,n,n,n)
- 比如:cubic-bezier(0.845, -0.375, 0.215, 1.335)
- 曲線設(shè)置網(wǎng)站:https://matthewlein.com/ceaser/
<style type="text/css">
div{
width: 50px;
height: 50px;
background-color: gold;
margin-bottom: 20px;
}
div:nth-child(1){
/*勻速*/
transition: all 1s linear;
}
div:nth-child(2){
/*開始和結(jié)束慢速涂滴,中間加速*/
transition: all 1s ease;
}
div:nth-child(3){
/*開始慢速友酱,結(jié)尾突然停止*/
transition: all 1s ease-in;
}
div:nth-child(4){
/*突然開始,結(jié)束時(shí)慢速*/
transition: all 1s ease-out;
}
div:nth-child(5){
/*開始和結(jié)束時(shí)慢速*/
transition: all 1s ease-in-out;
}
div:nth-child(6){
/*貝塞爾(貝茲)曲線*/
/*transition: all 1s cubic-bezier(0.250,0.250,0.750,0.750);勻速*/
/*超出再縮回的彈性效果*/
transition: all 1s cubic-bezier(0.470, -0.485, 0.460, 1.435);
}
div:hover{
width: 1000px;
}
</style>
文字遮罩-擴(kuò)展二級(jí)菜單
文字遮罩
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>圖片文字遮罩</title>
<style type="text/css">
.box{
width: 200px;
height: 300px;
margin: 50px auto 0;
border: 1px solid #000;
position: relative;
/*默認(rèn)文字不可見*/
overflow: hidden;
}
.box img{
width: 200px;
height: 300px;
}
.box .pic_info{
width: 200px;
height: 200px;
background-color: rgba(0,0,0,0.5);
color: #fff;
/*定位使色塊在圖片正下方*/
position: absolute;
left: 0;
top: 300px;
transition: all 500ms cubic-bezier(0.470, -0.485, 0.460, 1.435);
}
.box:hover .pic_info{
/*色塊上移*/
top:150px;
}
/*間距用p標(biāo)簽的margin柔纵,而不直接給.pic_info用padding缔杉,因?yàn)閜adding會(huì)改變盒子大小*/
.box .pic_info p{
margin: 20px;
line-height: 30px;
}
</style>
</head>
<body>
<div class="box">
<img src="img/location_bg.jpg" alt="玫瑰花">
<div class="pic_info">
<p>圖片說明:這是一朵玫瑰花圖片說明:這是一朵玫瑰花圖片說明:這是一朵玫瑰花圖片說明:這是一朵玫瑰花</p>
</div>
</div>
</body>
</html>
CSS3 transform變換
1、translate(x,y) 設(shè)置盒子位移
2搁料、scale(x,y) 設(shè)置盒子縮放
3或详、rotate(deg) 設(shè)置盒子旋轉(zhuǎn)
4系羞、skew(x-angle,y-angle) 設(shè)置盒子斜切
5、perspective 設(shè)置透視距離
6霸琴、transform-style flat | preserve-3d 設(shè)置盒子是否按3d空間顯示
7椒振、translateX、translateY梧乘、translateZ 設(shè)置三維移動(dòng)
8澎迎、rotateX、rotateY选调、rotateZ 設(shè)置三維旋轉(zhuǎn)
9夹供、scaleX、scaleY仁堪、scaleZ 設(shè)置三維縮放
10哮洽、tranform-origin 設(shè)置變形的中心點(diǎn)
11、backface-visibility 設(shè)置盒子背面是否可見
.box,.box2,.box3,.box4{
width: 200px;
height: 200px;
background-color: gold;
margin: 50px auto 0;
transition: all 1s ease;
}
.box:hover{
/*box的動(dòng)畫不會(huì)影響到box2*/
/*位移*/
transform: translate(50px,50px);
}
.box2:hover{
/*沿Z軸旋轉(zhuǎn)360度*/
transform: rotate(360deg);
}
.box3:hover{
/*縮放*/
transform: scale(0.5,0.2);
}
.box4:hover{
/*斜切*/
/*transform: skew(45deg,0);*/
transform: skew(0,45deg);
}
元素旋轉(zhuǎn)
旋轉(zhuǎn)方向判斷
1弦聂、X軸向右袁铐、Y軸向下、Z軸向屏幕外
2横浑、讓軸向?qū)χ约禾藿埃槙r(shí)針方向就是該軸向的旋轉(zhuǎn)方向
.box{
width: 300px;
height: 300px;
background-color: gold;
margin: 50px auto 0;
transition: all 500ms ease;
/*設(shè)置盒子按3D空間顯示*/
transform-style: preserve-3d;
/*perspective設(shè)置透視距離,經(jīng)驗(yàn)數(shù)值800比較符合人眼的透視效果*/
transform: perspective(800px) rotateY(0deg);
}
變形中心點(diǎn)
div:nth-child(1){
/*設(shè)置變形的中心點(diǎn)*/
transform-origin: left center;
}
div:nth-child(2){
transform-origin: left top;
}
div:nth-child(3){
transform-origin: 50px 50px;
}
背面可見
默認(rèn)背景是可見的徙融,是反過來的洒缀!
設(shè)置背面不可見
backface-visibility: hidden;
圖片翻面
CSS3 animation動(dòng)畫
1、@keyframes 定義關(guān)鍵幀動(dòng)畫
2欺冀、animation-name 動(dòng)畫名稱
3树绩、animation-duration 動(dòng)畫時(shí)間
4、animation-timing-function 動(dòng)畫曲線
- linear 勻速
ease 開始和結(jié)束慢速
ease-in 開始是慢速
ease-out 結(jié)束時(shí)慢速
ease-in-out 開始和結(jié)束時(shí)慢速
steps 動(dòng)畫步數(shù)
5隐轩、animation-delay 動(dòng)畫延遲
6饺饭、animation-iteration-count 動(dòng)畫播放次數(shù) n|infinite
7、animation-direction
- normal 默認(rèn)動(dòng)畫結(jié)束不返回
- Alternate 動(dòng)畫結(jié)束后返回
8职车、animation-play-state 動(dòng)畫狀態(tài)
- paused 停止
- running 運(yùn)動(dòng)
9瘫俊、animation-fill-mode 動(dòng)畫前后的狀態(tài)
- none 不改變默認(rèn)行為
- forwards 當(dāng)動(dòng)畫完成后,保持最后一個(gè)屬性值(在最后一個(gè)關(guān)鍵幀中定義)
- backwards 在 animation-delay 所指定的一段時(shí)間內(nèi)悴灵,在動(dòng)畫顯示之前扛芽,應(yīng)用開始屬性值(在第一個(gè)關(guān)鍵幀中定義)
- both 向前和向后填充模式都被應(yīng)用
10、animation:name duration timing-function delay iteration-count direction;同時(shí)設(shè)置多個(gè)屬性
動(dòng)畫名稱积瞒、時(shí)間川尖、曲線、延遲茫孔、播放次數(shù)叮喳、結(jié)束后是否返回被芳、動(dòng)畫前后的狀態(tài)
infinite不限制次數(shù)
alternate動(dòng)畫結(jié)束后返回,返回也算次數(shù)
animation-fill-mode 動(dòng)畫前后的狀態(tài)
forwards動(dòng)畫完成保持在最后一幀
backwards在延遲時(shí)間內(nèi)馍悟,在動(dòng)畫顯示之前畔濒,應(yīng)用from開始屬性值(例如box寬100,from寬200赋朦,在延遲1s內(nèi)顯示200)
both向前和向后填充模式都被應(yīng)用(例如起始按200,結(jié)束停在最后一幀)
.box{
width: 100px;
height: 100px;
background-color: gold;
animation: moving 1s ease 1s 5 alternate both;
/*動(dòng)畫暫停*/
/*animation-play-state: paused;*/
}
.box:hover{
/*動(dòng)畫運(yùn)行*/
/*animation-play-state: running;*/
}
/*定義一個(gè)動(dòng)畫李破,名稱為moving*/
@keyframes moving{
/*初始狀態(tài)*/
from{
width: 200px;
}
/*結(jié)束狀態(tài)*/
to{
width: 500px;
}
}
多幀動(dòng)畫
.box{
width: 100px;
height: 100px;
background-color: gold;
margin: 50px auto 0;
animation: moving 1s ease 1s both;
}
@keyframes moving{
0%{
/*位移動(dòng)畫*/
transform: translateY(0px);
background-color: cyan;
}
50%{
transform: translateY(400px);
background-color: gold;
border-radius: 0px;
}
100%{
transform: translateY(0px);
background-color: red;
border-radius: 50px;
}
}
瀏覽器樣式前綴
為了讓CSS3樣式兼容宠哄,需要將某些樣式加上瀏覽器前綴:
-ms- 兼容IE瀏覽器
-moz- 兼容firefox
-o- 兼容opera
-webkit- 兼容chrome 和 safari
自動(dòng)添加瀏覽器前綴
目前的狀況是,有些CSS3屬性需要加前綴嗤攻,有些不需要加毛嫉,有些只需要加一部分,這些加前綴的工作可以交給插件來完成妇菱,比如安裝: autoprefixer
Sublime text 中安裝 autoprefixer 執(zhí)行 preferences/key Bindings-Users 設(shè)置快捷鍵 { "keys": ["ctrl+alt+x"], "command": "autoprefixer" } 通過此工具可以按照最新的前綴使用情況給樣式自動(dòng)加前綴承粤。