問(wèn)答題
1.內(nèi)聯(lián)元素如何轉(zhuǎn)化成為塊元素
- display-block
2.元素類(lèi)型有哪些?他們的特征分別是什么?
- 塊元素 內(nèi)聯(lián)元素
- 塊元素:
1.獨(dú)占一行。
2.支持所有的樣式议谷。
3.不設(shè)置寬度時(shí)炉爆,寬度撐滿(mǎn)整行堕虹。 - 內(nèi)聯(lián)元素:
1.可以在一行顯示。
2.不支持寬高芬首,對(duì)上下的margin和padding等特性支持的也有問(wèn)題赴捞。
3.寬度由內(nèi)容撐開(kāi)。
代碼換行會(huì)被解析郁稍。
3.清浮動(dòng)有哪些方法赦政?你最喜歡哪個(gè)?為什么
- 1.clear清除浮動(dòng)
2.加高 (問(wèn)題:擴(kuò)展性不好)
3.父級(jí)浮動(dòng) (問(wèn)題:頁(yè)面中所有元素都加浮動(dòng),margin左右自動(dòng)失效(floats bad !))
4.inline-block 清浮動(dòng)方法 (問(wèn)題:margin左右auto失效)
5.空標(biāo)簽清浮動(dòng) (問(wèn)題:IE6 最小高度 19px恢着;(解決后IE6下還有2px偏差))
6.br清浮動(dòng) (問(wèn)題:不符合工作中:結(jié)構(gòu)桐愉、樣式、行為掰派,三者分離的要求从诲。)
7.after偽類(lèi) 清浮動(dòng)方法
8.overflow:hidden 清浮動(dòng)方法 overflow:hidden;溢出隱藏 (問(wèn)題:需要配合 寬度 或者 zoom 兼容IE6 IE7) - 最喜歡after偽類(lèi) 清浮動(dòng)方法,它沒(méi)有那么多的副作用靡羡,用起來(lái)相對(duì)來(lái)說(shuō)比較方便系洛。
4.什么是BFC?如何才能得到一個(gè)BFC
- BFC(Block Formatting Context)略步,簡(jiǎn)單講描扯,它是提供了一個(gè)獨(dú)立布局的環(huán)境,每個(gè)BFC都遵守同一套布局規(guī)則趟薄。例如绽诚,在同一個(gè)BFC內(nèi),盒子會(huì)一個(gè)挨著一個(gè)的排杭煎,相鄰盒子 的間距是由margin決定且垂直方向的margin會(huì)重疊憔购。而float和clear float也只對(duì)同一個(gè)BFC內(nèi)的元素有效。
- 觸發(fā)BFC的條件:
a岔帽、float的值不為none玫鸟。
b、overflow的值不為visible犀勒。
c屎飘、display的值為table-cell, table-caption, inline-block中的任何一個(gè)。
d贾费、position的值不為relative和static钦购。
e、width|height|min-width|min-height:(!aotu)
5.Positon的值有哪些褂萧?
- position:relative | absolute | fixed | static | inherit
6.說(shuō)一下絕對(duì)定位押桃,相對(duì)定位和固定定位的區(qū)別
- 絕對(duì)定位:
a.使元素完全脫離文檔流
b.使內(nèi)嵌支持寬高
c.塊屬性標(biāo)簽內(nèi)容撐開(kāi)寬度
d.如果有定位父級(jí),相對(duì)于定位父級(jí)發(fā)生偏移导犹,沒(méi)有定位父級(jí)唱凯,相對(duì)于document發(fā)生偏移
e.相對(duì)定位一般都是配合絕對(duì)定位
f.提升層級(jí) - 相對(duì)定位:
a.不影響元素本身的特性
b.不會(huì)使元素脫離文檔流
c.如果沒(méi)有定位偏移量,對(duì)元素本身沒(méi)有影響
d.提升層級(jí) - 固定定位:
與相對(duì)定位的特征基本一致谎痢,差別是始終相對(duì)整個(gè)文檔進(jìn)行定位磕昼。 問(wèn)題:IE6不支持固定定位。
7.怎么改變一個(gè)div的層級(jí)节猿,寫(xiě)出代碼讓DIV1在DIV2在下
- 通過(guò)z-index改變層級(jí)
.div1 { position:absolute; } .div2 { position:absolute; z-index:1; }
8.如何實(shí)現(xiàn)層疊的DIV1與DIV2票从,上面DIV1不透明下面DIV2透明?
.div1 { position:absolute; z-index:1; } .div2 { position:absolute; opacity:0-1; }
9.合并行屬性,合并列屬性
- 合并行:
colspan=" "
- 合并列:
rowspan=" "
10.讓DIV水平垂直居中
.box { width:300px; height:400px; position:absolute; left:50%; right:50%; margin:-200px 0px 0px -150px; }
編程題
1.
(1)方法一(類(lèi)型轉(zhuǎn)換)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
<style>
div{
font:20px/30px "宋體";
}
span {
width:100px;
height:100px;
background:red;
display:inline-block;
}
</style>
</head>
<body>
<div >類(lèi)型轉(zhuǎn)換</div>
<span></span>
<span></span>
<span></span>
效果圖截圖
(2)方法二(浮動(dòng))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
<style>
div {
font:20px/30px "宋體";
}
span {
width:100px;
height:100px;
background:red;
float:left;
margin-right:8px;
}
</style>
</head>
<body>
<div>浮動(dòng)</div>
<span></span>
<span></span>
<span></span>
</body>
</html>
效果圖截圖
(2)方法三(定位)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
<style>
span {
font:20px/30px "宋體";
}
div {
width:100px;
height:100px;
background:red;
}
.div2 {
position:relative;
left:108px;
bottom:100px;
}
.div3 {
position:relative;
left:216px;
bottom:200px;
}
</style>
</head>
<body>
<span>定位</span>
<div class="div1"></div>
<div class="div2"></div>
<div class="div3"></div>
</body>
</html>
效果圖截圖
2.騰訊大學(xué)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
<style>
.title {
width:228px;
height:21px;
position:relative;
margin-bottom:19px;
}
.title1 {
width:19px;
height:19px;
border:1px solid #000;
border-bottom:none;
font:7px/15px "宋體";
text-align:center;
}
.title2 {
position:absolute;
left:31px;top:0px;
font:19px/20px "宋體";
color:#000;
}
.head {
width:228px;
height:35px;
position:relative;
margin-bottom:15px;
}
.head1 {
width:110px;
height:35px;
border:1px solid #cccccc;
border-bottom:none;
background-image:url(xiaodian.jpg);
background-repeat:no-repeat;
background-position:-2px 30px;
margin:0px 3px 0px 3px;
font:12px/35px "宋體";
text-align:center;
color:#000;
}
.head2 {
width:110px;
height:35px;
border-bottom:1px solid #cccccc;
position:absolute;
left:114px;
top:0px;
background-image:url(xiaodian.jpg);
background-repeat:no-repeat;
background-position:right 32px;
font:12px/35px "宋體";
text-align:center;
color:#cccccc;
}
.body1 {
width:228px;
height:160px;
background-image:url(tupian1.jpg);
position:relative;
margin-bottom:20px;
}
.body11 {
width:228px;
height:26px;
background:black;
position:absolute;
bottom:0px;
opacity:0.5;
}
.body12 {
width:20px;
height:26px;
background:#e2291c;
position:absolute;
left:0px;
bottom:0px;
font:9px/26px "宋體";
text-align:center;
color:#fff;
}
.body13 {
width:228px;
height:26px;
position:absolute;
bottom:0px;
font:11px/26px "宋體";
color:#fff;
text-indent:30px;
}
.body2 {
width:228px;
height:160px;
background-image:url(tupian2.jpg);
position:relative;
margin-bottom:20px;
}
.body21 {
width:228px;
height:26px;
background:black;
position:absolute;
bottom:0px;
opacity:0.5;
}
.body22 {
width:20px;
height:26px;
background:#e2291c;
position:absolute;
left:0px;
bottom:0px;
font:9px/26px "宋體";
text-align:center;
color:#fff;
}
.body23 {
width:228px;
height:26px;
position:absolute;
bottom:0px;
font:11px/26px "宋體";
color:#fff;
text-indent:30px;
}
.body3 {
width:228px;
height:160px;
background-image:url(tupian3.jpg);
position:relative;
margin-bottom:20px;
}
.body31 {
width:228px;
height:26px;
background:black;
position:absolute;
bottom:0px;
opacity:0.5;
}
.body32 {
width:20px;
height:26px;
background:#f6a544;
position:absolute;
left:0px;
bottom:0px;
font:9px/26px "宋體";
text-align:center;
color:#fff;
}
.body33 {
width:228px;
height:26px;
position:absolute;
bottom:0px;
font:11px/26px "宋體";
color:#fff;
text-indent:30px;
}
.body4 {
width:228px;
height:160px;
background-image:url(tupian4.jpg);
position:relative;
margin-bottom:20px;
}
.body41 {
width:228px;
height:26px;
background:black;
position:absolute;
bottom:0px;
opacity:0.5;
}
.body42 {
width:20px;
height:26px;
background:#ec5a2e;
position:absolute;
left:0px;
bottom:0px;
font:9px/26px "宋體";
text-align:center;
color:#fff;
}
.body43 {
width:228px;
height:26px;
position:absolute;
bottom:0px;
font:11px/26px "宋體";
color:#fff;
text-indent:30px;
}
.body5 {
width:228px;
height:160px;
background-image:url(tupian5.jpg);
position:relative;
margin-bottom:11px;
}
.body51 {
width:228px;
height:26px;
background:black;
position:absolute;
bottom:0px;
opacity:0.5;
}
.body52 {
width:20px;
height:26px;
background:#f6a544;
position:absolute;
left:0px;
bottom:0px;
font:9px/26px "宋體";
text-align:center;
color:#fff;
}
.body53 {
width:228px;
height:26px;
position:absolute;
bottom:0px;
font:11px/26px "宋體";
color:#fff;
text-indent:30px;
}
.body2222 {
position:relative;
}
.body6 {
width:227px;
height:30px;
position:absolute;
}
.body61 {
width:0px;
height:0px;
border-top:16px solid #9fd15a;
border-left:9px solid #9fd15a;
border-right:9px solid #9fd15a;
border-bottom:4px solid #fff;
}
.body62 {
font-size:11px;
color:#fff;
position:absolute;
left:6px;
top:4px;
}
.body63 {
width:227px;
height:30px;
font:12px/30px "宋體";
text-indent:23px;
color:#000;
position:absolute;
top:-9px;
}
.body7 {
width:227px;
height:30px;
position:absolute;
}
.body71 {
width:0px;
height:0px;
border-top:16px solid #9fd15a;
border-left:9px solid #9fd15a;
border-right:9px solid #9fd15a;
border-bottom:4px solid #fff;
position:absolute;
left:-6px;
top:13px;
}
.body72 {
font-size:11px;
color:#fff;
position:absolute;
left:-3px;
top:-12px;
}
.body73 {
width:227px;
height:30px;
font:12px/30px "宋體";
text-indent:23px;
color:#000;
position:absolute;
top:-9px;
}
.body8 {
width:227px;
height:30px;
position:absolute;
}
.body81 {
width:0px;
height:0px;
border-top:16px solid #9fd15a;
border-left:9px solid #9fd15a;
border-right:9px solid #9fd15a;
border-bottom:4px solid #fff;
position:absolute;
left:-6px;
top:13px;
}
.body82 {
font-size:11px;
color:#fff;
position:absolute;
left:-3px;
top:-12px;
}
.body83 {
width:227px;
height:30px;
font:12px/30px "宋體";
text-indent:23px;
color:#000;
position:absolute;
top:-9px;
}
.body9 {
width:227px;
height:30px;
position:absolute;
}
.body91 {
width:0px;
height:0px;
border-top:16px solid #9fd15a;
border-left:9px solid #9fd15a;
border-right:9px solid #9fd15a;
border-bottom:4px solid #fff;
position:absolute;
left:-6px;
top:13px;
}
.body92 {
font-size:11px;
color:#fff;
position:absolute;
left:-3px;
top:-12px;
}
.body93 {
width:227px;
height:30px;
font:12px/30px "宋體";
text-indent:23px;
color:#000;
position:absolute;
top:-9px;
}
.body10 {
width:227px;
height:30px;
position:absolute;
}
.body101 {
width:0px;
height:0px;
border-top:16px solid #9fd15a;
border-left:9px solid #9fd15a;
border-right:9px solid #9fd15a;
border-bottom:4px solid #fff;
position:absolute;
left:-6px;
top:13px;
}
.body102 {
font-size:11px;
color:#fff;
position:absolute;
left:-3px;
top:-12px;
}
.body103 {
width:227px;
height:30px;
font:12px/30px "宋體";
text-indent:23px;
color:#000;
position:absolute;
top:-9px;
}
</style>
</head>
<body>
<div class="box">
<div class="title">
<div class="title1">TOP</div>
<div class="title2">排行榜</div>
</div>
<div class="head">
<div class="head1">最熱排行</div>
<div class="head2">新課上線(xiàn)</div>
</div>
<div class="body">
<div class="body1">
<div class="body11"></div>
<div class="body12">1</div>
<div class="body13">張小龍:微信四大價(jià)值觀(guān)</div>
</div>
<div class="body2">
<div class="body21"></div>
<div class="body22">2</div>
<div class="body23">劉超:互聯(lián)網(wǎng)新時(shí)代需要什么樣...</div>
</div>
<div class="body3">
<div class="body31"></div>
<div class="body32">3</div>
<div class="body33">馬化騰:騰訊將專(zhuān)注于做互聯(lián)網(wǎng)...</div>
</div>
<div class="body4">
<div class="body41"></div>
<div class="body42">4</div>
<div class="body43">IT領(lǐng)袖峰會(huì)圓桌會(huì)談:互聯(lián)網(wǎng)下...</div>
</div>
<div class="body5">
<div class="body51"></div>
<div class="body52">5</div>
<div class="body53">微信支付對(duì)實(shí)體商業(yè)的價(jià)值幾何?</div>
</div>
<div class="body2222">
<div class="body6">
<div class="body61"></body>
<div class="body62">6</body>
<div class="body63">張小龍:小程序正式發(fā)布峰鄙,開(kāi)...</body>
</div>
<div class="body7">
<div class="body71"></body>
<div class="body72">7</body>
<div class="body73">馬化騰:通向互聯(lián)網(wǎng)未來(lái)的七...</body>
</div>
<div class="body8">
<div class="body81"></body>
<div class="body82">8</body>
<div class="body83">馬化騰:騰訊現(xiàn)在只做兩件事</body>
</div>
<div class="body9">
<div class="body91"></body>
<div class="body92">9</body>
<div class="body93">使用UE4制作VR內(nèi)容的優(yōu)化</body>
</div>
<div class="body10">
<div class="body101"></body>
<div class="body102">10</body>
<div class="body103">何凌南:謠言在想什么</body>
</div>
</div>
</div>
</div> ps:有史以來(lái)最長(zhǎng)的代碼浸间,累到吐血(╥﹏╥)
</body>
</html>
效果圖截圖
。吟榴。发框。不會(huì)用ps把兩張圖拼一起,分開(kāi)截的圖(╥﹏╥)
學(xué)習(xí)心得:作業(yè)真的是一次比一次難煤墙!應(yīng)該是方法太麻煩了梅惯,第二個(gè)編程作業(yè)一共花了六七個(gè)小時(shí)才做出來(lái),前幾天有事情耽誤了三天課程仿野,結(jié)果我也用了三天把前面的攆了回來(lái)铣减,結(jié)果現(xiàn)在的課程也落下三天......
做這個(gè)東西真的是累,從早晨一直在電腦前坐到晚上脚作,無(wú)論如何吧葫哗,總之最終把東西做出來(lái)了真的是特別高興,也感謝同學(xué)們和學(xué)長(zhǎng)們的幫助球涛。
百度云鏈接: http://pan.baidu.com/s/1o7TDixc
密碼: j5nt