2.2.CSS实战与提高
练习11:制作开心餐厅页面
CSS
p {
font-size : 14px;
}
body h2 {
font-size : 16px;
}
.firstH2 {
color : red;
}
.firstH2 ~ h2 {
color : blue;
}
HTML
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> 开心餐厅</ title>
< link href = " css/style.css" rel = " stylesheet" type = " text/css" />
</ head>
< body>
< img src = " image/game01.jpg" alt = " 主题图片" />
< br/>
< img src = " image/game02.jpg" alt = " 游戏简介" />
< p > 开心餐厅,让你可以开心的烹饪美味佳肴,从一个简洁的小餐厅起步,逐步打造自己的餐饮大食代。< br/>
烹饪美食,雇佣好友帮忙,装修个性餐厅,获得顾客美誉。< br/>
步步精心经营,细心打理,我们都能成为餐饮大亨哦。</ p>
< img src = " image/game03.jpg" alt = " 游戏特色" />
< h2 class = " firstH2" > 如何做菜?</ h2>
< p>
1.点击餐厅中的炉灶,打开菜谱,选择自己要做的食物后,进行烹饪。不断点击炉灶,直到食物进入自动烹饪阶段;< br/>
2.每道菜所需要制作的步骤和烹饪的时间不一样,你可以根据自己的时间和偏好来进行选择,还会有各地特色食物供应哦;< br/>
3.烹饪完毕的食物要及时端到餐台上,否则过一段时间会腐坏;< br/>
4.食物放在餐台上后,服务员会自动端给顾客,顾客吃完后会付钱给你。
</ p>
< h2> 如何经营餐厅?</ h2>
< p>
1.自己做老板,当大厨,雇佣好友来做服务员为你打工。心情越好的员工效率越高。员工兼职的份数越少,工作的时间越短
心情越好;好友间亲密度越高,可雇用的时间越长;< br/>
2.随着等级的升高,可雇佣的员工、可购买的炉灶、餐台、经营面积都会随之增加;< br/>
3.餐桌椅的摆放位置也很有讲究,它会影响顾客和服务员行走路程。
</ p>
< h2> 如何吸引顾客?</ h2>
< p>
1.美誉度决定了餐厅的客流量,美誉度高的时候来餐厅的顾客多,美誉度低的时候来餐厅的顾客少;< br/>
2.如果不需要等待,就能及时享用到食物,顾客就会满意地增加餐厅美誉度;与之相反,如果没有吃到食物就离开的顾客会
降低美誉度;< br/>
3.总而言之,储备充足的食物、及时的服务、足够的餐桌椅是必不可少的!
</ p>
< h2> 如何和好友互动?</ h2>
< p>
1.不忍眼睁睁看好友餐厅的食物腐坏,那就帮忙端到餐台吧!自己还可以获得经验值奖励;< br/>
2.仓库里的东西可以赠送给好友,直接拖拽到礼物即可赠送;拖拽到收银即可出售。注意哦,每个级别能收到礼物的总价值
是有上限的;< br/>
3.系统的额外食物奖励可和好友分享,把分享消息发布到开心网动态上,让朋友们一起感受快乐!每天最多可以从5位好友
的餐厅领取免费食物,食物将被放入仓库的冷藏室里,可出售给系统,也可以拖到餐台上卖给顾客;< br/>
4.在好友需要帮助的时候,给予帮忙,当然啦,你也可以给好友捣捣乱、使使坏。作为奖励,你也会获得经验值和现金。
</ p>
< img src = " image/game04.jpg" alt = " 游戏口碑" />
< p> 开心餐厅,让你可以开心的烹饪美味佳肴,从一个简洁的小餐厅起步,逐步打造自己的餐饮大食代。< br/>
烹饪美食,雇佣好友帮忙,装修个性餐厅,获得顾客美誉。< br/>
步步精心经营,细心打理,我们都能成为餐饮大亨哦。
</ p>
</ body>
</ html>
练习12:制作爱奇异视频播放列表
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> 爱奇异视频播放列表</ title>
< style>
li {
display : inline-block;
}
li h4:nth-of-type(1) {
font-size : 16px;
color : #4d4d4d;
}
li p:nth-of-type(1) {
color : #640000;
font-size : 14px;
}
li p:nth-of-type(2) {
font-size : 12px;
color : blue;
}
</ style>
</ head>
< body>
< h3> 热播</ h3>
< ul>
< li>
< img src = " image/img1.png" alt = " " />
< h4> 神武赵子龙</ h4>
< p> 怒,林更新不抱网红抱女神</ p>
< p> 点击次数:242445次</ p>
</ li>
< li>
< img src = " image/img2.png" alt = " " />
< h4> 旋风十一人</ h4>
< p> 胡歌变教练在撩前女友</ p>
< p> 点击次数:242445次</ p>
</ li>
< li>
< img src = " image/img3.png" alt = " " />
< h4> 太阳的后裔</ h4>
< p> 宋慧乔吃嫩草</ p>
< p> 点击次数:242445次</ p>
</ li>
< li>
< img src = " image/img4.png" alt = " " />
< h4> 山海经之赤影传说</ h4>
< p> 娜扎张翰再度联手</ p>
< p> 点击次数:242445次</ p>
</ li>
</ ul>
</ body>
</ html>
练习13:家用电器商品分类页面
CSS
#type {
width : 300px;
}
#title {
font-size : 18px;
text-indent : 1em;
background : linear-gradient ( to bottom, #0467ac, #63a7d6, #b6dbf5) ;
line-height : 35px;
height : 35px;
color : #FFF;
font-weight : bold;
}
li {
list-style : none;
}
.secondTitle {
background-color : #e4f1fa;
background : linear-gradient ( to bottom, #e4f1fa, #bddff7, #e4f1fa) ;
text-indent : 2em;
font-size : 14px;
line-height : 30px;
font-weight : bold;
}
.secondTitle a {
color : #0565c6;
text-decoration : none;
}
.secondTitle a:hover {
text-decoration : underline;
}
p {
line-height : 26px;
text-indent : 1em;
}
p a {
color : #666666;
text-decoration : none;
}
p a:hover {
color : #F60;
text-decoration : underline;
}
HTML
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> 家用电器分类</ title>
< link href = " css/type.css" rel = " stylesheet" type = " text/css" />
</ head>
< body>
< div id = " type" >
< h2 id = " title" > 家用电器</ h2>
< ul>
< li>
< h3 class = " secondTitle" > < a href = " #" > 大家电</ a> </ h3>
< p> < a href = " #" > 平板电视</ a> < a href = " #" > 洗衣机</ a> < a href = " #" > 冰箱</ a> < br/>
< span> </ span> < a href = " #" > 空调</ a> < a href = " #" > 烟机/灶具</ a> < a
href = " #" > 热水器</ a> < br/>
< span> </ span> < a href = " #" > 冷柜/酒柜</ a> < a href = " #" > 消毒柜</ a> < a href = " #" > 家庭影院</ a>
</ p>
</ li>
< li>
< h3 class = " secondTitle" > < a href = " #" > 生活电器</ a> </ h3>
< p> < a href = " #" > 电风扇</ a> < a href = " #" > 净化器</ a> < a href = " #" > 吸尘器</ a> < br/>
< span> </ span> < a href = " #" > 净水设备</ a> < a href = " #" > 挂烫机</ a> < a
href = " #" > 电话机</ a>
</ p>
</ li>
< li>
< h3 class = " secondTitle" > < a href = " #" > 厨房电器</ a> </ h3>
< p> < a href = " #" > 榨汁机</ a> < a href = " #" > 电压力锅</ a> < a href = " #" > 电饭煲</ a> < br/>
< span> </ span> < a href = " #" > 豆浆机</ a> < a href = " #" > 微波炉</ a> < a
href = " #" > 电磁炉</ a>
</ p>
</ li>
< li> < h3 class = " secondTitle" > < a href = " #" > 五金家装</ a> </ h3>
< p> < a href = " #" > 淋浴/水槽</ a> < a href = " #" > 电动工具</ a> < a href = " #" > 手动工具</ a> < br/>
< span> </ span> < a href = " #" > 仪器仪表</ a> < a href = " #" > 浴霸/排气</ a> < a
href = " #" > 灯具</ a>
</ p> </ li>
</ ul>
</ div>
</ body>
</ html>
练习14:畅销书排行榜
CSS
.book {
width : 290px;
background-color : #f3f4df;
background : linear-gradient ( to bottom, #f9fbcb, #f8f8f3) ;
}
.title {
font-size : 16px;
color : #FFF;
line-height : 30px;
text-indent : 1em;
background : #518700 url ( ../image/bang.gif) 100px 2px no-repeat;
background-size : contain;
}
ul li {
list-style-type : none;
line-height : 28px;
font-size : 12px;
text-indent : 2em;
}
ul li:nth-of-type(1) { background : url ( ../image/book_no01.gif) 0 center no-repeat; }
ul li:nth-of-type(2) { background : url ( ../image/book_no02.gif) 0 center no-repeat; }
ul li:nth-of-type(3) { background : url ( ../image/book_no03.gif) 0 center no-repeat; }
ul li:nth-of-type(4) { background : url ( ../image/book_no04.gif) 4px center no-repeat; }
ul li:nth-of-type(5) { background : url ( ../image/book_no05.gif) 4px center no-repeat; }
ul li:nth-of-type(6) { background : url ( ../image/book_no06.gif) 4px center no-repeat; }
ul li:nth-of-type(7) { background : url ( ../image/book_no07.gif) 4px center no-repeat; }
ul li:nth-of-type(8) { background : url ( ../image/book_no08.gif) 4px center no-repeat; }
ul li:nth-of-type(9) { background : url ( ../image/book_no09.gif) 4px center no-repeat; }
ul li:nth-of-type(10) { background : url ( ../image/book_no10.gif) 4px center no-repeat; }
ul li a {
color : #1a66b3;
text-decoration : none;
}
ul li a:hover {
text-decoration : underline;
}
HTML
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> 畅销书排行榜</ title>
< link href = " css/book.css" rel = " stylesheet" type = " text/css" />
</ head>
< body>
< div class = " book" >
< h2 class = " title" > 畅销书排行</ h2>
< ul>
< li > < a href = " #" target = _blank> 不抱怨的世界(畅...</ a> </ li>
< li > < a href = " #" target = _blank> 遇见未知的自己...</ a> </ li>
< li > < a href = " #" target = _blank> 活法(季羡林、...</ a> </ li>
< li > < a href = " #" target = _blank> 高效能人士的七个习惯</ a> </ li>
< li > < a href = " #" target = _blank> 被迫强大(北外女生香奈儿...</ a> </ li>
< li > < a href = " #" target = _blank> 遇见心想事成的自己(《遇...</ a> </ li>
< li > < a href = " #" target = _blank> 世界上最伟大的推销员(插...</ a> </ li>
< li > < a href = " #" target = _blank> 我的成功可以复制(唐骏亲...</ a> </ li>
< li > < a href = " #" target = _blank> 少有人走的路:心智成熟的...</ a> </ li>
< li > < a href = " #" target = _blank> 活出全新的自己――唤醒...</ a> </ li>
</ ul>
</ div>
</ body>
</ html>
练习15:聚美优品商品分类
CSS
h1, dl, dt, dd {
margin : 0px;
padding : 0px;
}
body {
background-color : #D5D5D5;
}
#product {
width : 230px;
background-color : #fff;
}
#product h1 {
font-size : 16px;
font-weight : bold;
color : #FFF;
background-color : #000;
text-indent : 1em;
line-height : 35px;
}
#product dt {
padding-left : 27px;
line-height : 35px;
height : 35px;
font-size : 14px;
font-weight : bold;
}
#product dd {
font-size : 12px;
color : #666666;
line-height : 20px;
border-bottom : 1px #666666 dashed;
padding-left : 27px;
}
#product dt:nth-of-type(1) {
background : url ( ../image/icon_01.gif) 0px 0px no-repeat;
}
#product dt:nth-of-type(2) {
background : url ( ../image/icon_02.gif) 0px 2px no-repeat;
}
#product dt:nth-of-type(3) {
background : url ( ../image/icon_03.gif) 0px 4px no-repeat;
}
#product dt:nth-of-type(4) {
background : url ( ../image/icon_04.gif) 0px 2px no-repeat;
}
#product dt:nth-of-type(5) {
background : url ( ../image/icon_05.gif) 0px 0px no-repeat;
}
#product dt:nth-of-type(6) {
background : url ( ../image/icon_06.gif) 0px 0px no-repeat;
}
#product dt:nth-of-type(7) {
background : url ( ../image/icon_07.gif) 0px 0px no-repeat;
}
#product dt:nth-of-type(8) {
background : url ( ../image/icon_08.gif) 0px 0px no-repeat;
}
#product dt:nth-of-type(9) {
background : url ( ../image/icon_09.gif) 0px 0px no-repeat;
}
#product dd:last-of-type {
border-bottom : 0px;
}
HTML
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> 商品分类</ title>
< link href = " css/product.css" rel = " stylesheet" type = " text/css" />
</ head>
< body>
< div id = " product" >
< h1> 全部分类</ h1>
< dl>
< dt> 护肤</ dt>
< dd> 洁面 化妆水 喷雾 美容液 眼霜< br/>
眼部精华 眼膜 面膜 面膜贴< br/>
水洗面膜 免洗面膜 精华 精油< br/>
凝露 乳液 面霜 日霜 晚霜
</ dd>
< dt> 彩妆</ dt>
< dd> 卸妆 防晒 隔离 BB霜 粉底 粉饼< br/>
睫毛膏 眼影 唇彩 腮红 眼线笔< br/>
底妆 遮瑕 蜜粉 眉笔 美甲
</ dd>
< dt> 香氛</ dt>
< dd> 男香 女香 小Q装 中性香水</ dd>
< dt> 身体护理</ dt>
< dd> 洗发 护发 沐浴 身体乳 手足护理< br/>
护手霜 纤体 身体精油 颈部护理< br/>
个人护理 卫生用品 脱毛
</ dd>
< dt> 礼盒套装</ dt>
< dd> 护肤套装 身体护理套装 彩妆套装 < br/>
旅行装 香水套装 男士套装
</ dd>
< dt> 美容工具</ dt>
< dd> 护肤 彩妆 美发 美体 美甲 < br/>
美容仪器 其他美容工具
</ dd>
< dt> 母婴专区</ dt>
< dd> 奶粉 尿裤湿巾 母婴洗护</ dd>
< dt> 男士专区</ dt>
< dd> 洁面 爽肤水 面霜 男香< br/>
眼霜 凝胶 乳液 精华 沐浴
</ dd>
< dt> 食品保健</ dt>
< dd> 瘦身类 保健类 美容类 食品类</ dd>
</ dl>
</ div>
</ body>
</ html>
练习16:仿京东快报
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> 京东快报</ title>
< style>
* {
padding : 0;
margin : 0;
}
body {
margin : 30px;
}
a {
text-decoration : none;
}
.box {
border : 1px #e4e4e4 solid;
width : 230px;
box-sizing : border-box;
}
h2 {
padding-left : 10px;
line-height : 43px;
height : 43px;
border-bottom : 2px #E8E8E7 dotted;
font-size : 16px;
color : #666;
font-weight : normal;
background : linear-gradient ( to bottom, #CCCCFF, #FFFFFF) ;
}
ul {
list-style : none;
padding-top : 5px;
padding-bottom : 5px;
}
ul li {
line-height : 26px;
padding-left : 10px;
padding-right : 10px;
}
li a {
font-size : 12px;
color : #666;
text-decoration : none;
}
li a:hover {
color : #b20000;
}
li a span {
font-weight : bold;
}
</ style>
</ head>
< body>
< div class = " box" >
< h2> 京东快报</ h2>
< ul>
< li> < a href = " " > < span> [特惠]</ span> 海飞丝去屑又去油 超清爽</ a> </ li>
< li> < a href = " " > < span> [公告]</ span> 京东公益支持鲁甸新动作</ a> </ li>
< li> < a href = " " > < span> [特惠]</ span> 4688元抢iPhone 6</ a> </ li>
< li> < a href = " " > < span> [公告]</ span> 小米电视携豪礼高调入驻京东</ a> </ li>
</ ul>
</ div>
</ body>
</ html>
练习17:制作特殊图形
半圆
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> border-radius制作半圆形</ title>
< style>
div {
background : red;
margin : 30px;
}
div:nth-of-type(1) {
width : 100px;
height : 50px;
border-radius : 50px 50px 0 0;
}
div:nth-of-type(2) {
width : 100px;
height : 50px;
border-radius : 0 0 50px 50px;
}
div:nth-of-type(3) {
width : 50px;
height : 100px;
border-radius : 0 50px 50px 0;
}
div:nth-of-type(4) {
width : 50px;
height : 100px;
border-radius : 50px 0 0 50px;
}
</ style>
</ head>
< body>
< div> </ div>
< div> </ div>
< div> </ div>
< div> </ div>
</ body>
</ html>
扇形
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> border-radius制作扇形</ title>
< style>
div {
background : red;
margin : 30px;
}
div:nth-of-type(1) {
width : 50px;
height : 50px;
border-radius : 50px 0 0 0;
}
div:nth-of-type(2) {
width : 50px;
height : 50px;
border-radius : 0 50px 0 0;
}
div:nth-of-type(3) {
width : 50px;
height : 50px;
border-radius : 0 0 50px 0;
}
div:nth-of-type(4) {
width : 50px;
height : 50px;
border-radius : 0 0 0 50px;
}
</ style>
</ head>
< body>
< div> </ div>
< div> </ div>
< div> </ div>
< div> </ div>
</ body>
</ html>
圆形
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> border-radius制作圆形</ title>
< style>
div {
width : 100px;
height : 100px;
border : 4px solid red;
border-radius : 50%;
}
</ style>
</ head>
< body>
< div> </ div>
</ body>
</ html>
练习18:聚美优品美容产品热点
CSS
p, ul, li {
margin : 0px;
padding : 0px;
}
ul, li {
list-style-type : none;
}
body {
background-color : #eee7e1;
font-size : 12px;
}
#beauty {
width : 260px;
background-color : #FFF;
}
#beauty p {
font-size : 14px;
font-weight : bold;
color : #FFF;
background-color : #e9185a;
height : 35px;
line-height : 35px;
padding-left : 10px;
}
#beauty li {
border-bottom : 1px #a8a5a5 dashed;
height : 30px;
line-height : 30px;
padding-left : 2px;
}
#beauty a {
color : #666666;
text-decoration : none;
}
#beauty a:hover {
color : #e9185a;
}
#beauty a span {
color : #FFF;
font-weight : bold;
margin-right : 10px;
display : inline-block;
width : 20px;
height : 20px;
border-radius : 50%;
background : #373b3c;
line-height : 20px;
text-align : center;
}
#beauty a:hover span {
background : #e9185a;
}
HTML
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> 美容热点产品</ title>
< link href = " css/beauty.css" rel = " stylesheet" type = " text/css" />
</ head>
< body>
< div id = " beauty" >
< p> 大家都喜欢买的美容品</ p>
< ul>
< li> < a href = " #" > < span> 1</ span> 雅诗兰黛即时修护眼部精华霜15ml</ a> </ li>
< li> < a href = " #" > < span> 2</ span> 伊丽莎白雅顿显效复合活肤霜 75ml</ a> </ li>
< li> < a href = " #" > < span> 3</ span> OLAY玉兰油多效修护霜 50g</ a> </ li>
< li> < a href = " #" > < span> 4</ span> 巨型一号丝瓜水320ML</ a> </ li>
< li> < a href = " #" > < span> 5</ span> 倩碧保湿洁肤水2号 200ml</ a> </ li>
< li> < a href = " #" > < span> 6</ span> 比度克细肤淡印霜 30g</ a> </ li>
< li> < a href = " #" > < span> 7</ span> 兰芝 (LANEIGE)夜间修护锁水面膜 80ml</ a> </ li>
< li> < a href = " #" > < span> 8</ span> SK-II护肤精华露 215ml</ a> </ li>
< li> < a href = " #" > < span> 9</ span> 欧莱雅青春密码活颜精华肌底液</ a> </ li>
</ ul>
</ div>
</ body>
</ html>
练习19:制作爱奇异视频播放列表
<! DOCTYPE html >
< html>
< head lang = " en" >
< meta charset = " UTF-8" >
< title> 爱奇异视频播放列表</ title>
< style>
* {
margin : 0;
padding : 0;
}
.box {
width : 1000px;
margin : 50px auto;
}
h3 {
font-size : 18px;
line-height : 40px;
}
li {
display : inline-block;
padding : 10px;
margin-right : 5px;
}
li img {
border-radius : 10px;
}
li h4:nth-of-type(1) {
font-size : 16px;
color : #4d4d4d;
line-height : 30px;
}
li p:nth-of-type(1) {
color : #640000;
font-size : 14px;
line-height : 20px;
}
li p:nth-of-type(2) {
font-size : 12px;
color : blue;
line-height : 20px;
}
ul li:hover {
border-color : #dfdfdf;
border-radius : 10px;
-moz-box-shadow : 0 5px 5px rgba ( 0, 0, 0, 0.1) , 0 0 10px 0 rgba ( 0, 0, 0, 0.2) ;
-webkit-box-shadow : 0 5px 5px rgba ( 0, 0, 0, 0.1) , 0 0 10px 0 rgba ( 0, 0, 0, 0.2) ;
box-shadow : 0 5px 5px rgba ( 0, 0, 0, 0.1) , 0 0 10px 0 rgba ( 0, 0, 0, 0.2) ;
background-color : #fff;
}
</ style>
</ head>
< body>
< div class = " box" >
< h3> 热播</ h3>
< ul>
< li>
< img src = " image/img1.png" alt = " " />
< h4> 神武赵子龙</ h4>
< p> 怒,林更新不抱网红抱女神</ p>
< p> 点击次数:242445次</ p>
</ li>
< li>
< img src = " image/img2.png" alt = " " />
< h4> 旋风十一人</ h4>
< p> 胡歌变教练在撩前女友</ p>
< p> 点击次数:242445次</ p>
</ li>
< li>
< img src = " image/img3.png" alt = " " />
< h4> 太阳的后裔</ h4>
< p> 宋慧乔吃嫩草</ p>
< p> 点击次数:242445次</ p>
</ li>
< li>
< img src = " image/img4.png" alt = " " />
< h4> 山海经之赤影传说</ h4>
< p> 娜扎张翰再度联手</ p>
< p> 点击次数:242445次</ p>
</ li>
</ ul>
</ div>
</ body>
</ html>
后续待更新