通常我們在寫input時(shí),它的背景文字框都是灰色的,樣式很單一,其實(shí)它可以做的更好看的,在CSS3中就專門提供了一屬性placeholder來實(shí)現(xiàn)輸入框的美化。接下來,就為大家展示下:
HTML:
CSS:
效果:
對于input輸入框的背景提示信息(placeholder)的美化雖然只是對網(wǎng)站應(yīng)用的小小點(diǎn)綴,但正是這樣細(xì)節(jié)上的小差別將你的網(wǎng)站和別人的網(wǎng)站區(qū)別開來。IE10也支持了placeholder屬性哦!
切版 qieban(.cn)
TML5的結(jié)構(gòu)化標(biāo)簽,對搜索引擎更友好
li 標(biāo)簽對不利于搜索引擎的收錄,盡量少用
banner圖片一般擁有版權(quán),不需要搜索引擎收錄,因此可以使用ul + li
<samp></samp>可用于淺色副標(biāo)題
display:inline-block; 每個(gè)導(dǎo)航塊存在水平間隙,解決方法是在父元素上添加font-size:0;
sublime安裝csscomb插件
選中css代碼,ctrl+shift+c 自動整理好代碼
排序前:
排序后:
此時(shí)存在多余的空行
解決方法:
安裝cssformat插件,對代碼執(zhí)行edit->cssformat->expanded 即可刪除空行
選中單句樣式前面的空白部分(即tab空位)
然后alt+f3 會統(tǒng)一選中所有tab留白
按一次刪除,再按一次刪除,再空一格
此時(shí)這個(gè)效果:
然后按向下箭頭,按向左箭頭,按刪除一次,再加個(gè)空格
此時(shí)效果
再向下箭頭,再刪除
此時(shí)效果
css樣式代碼美化完畢。
新標(biāo)簽元素的瀏覽器兼容解決:
header,nav,section,aside,article,footer{display: block;}
最后曬出所有代碼
index.html
<!DOCTYPE html>
<html lang="en" manifest="index.manifest">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<div class="container">
<a href="#"><img src="cat-little.jpg"></a>
<nav>
<a href="#" class="active">導(dǎo)航</a>
<a href="#">導(dǎo)航</a>
<a href="#">導(dǎo)航</a>
<a href="#">導(dǎo)航</a>
<a href="#">導(dǎo)航</a>
</nav>
</div>
</header>
<section class="banner">
<ul>
<li class="left"><img src="banner1.jpg"></li>
<li class="active"><img src="banner3.jpg"></li>
<li class="right"><img src="banner2.jpg"></li>
</ul>
</section>
<section class="main">
<aside>
<h1>左邊<samp>標(biāo)題</samp></h1>
<dl>
<dt>小標(biāo)題</dt>
<dd class="text">文字內(nèi)容哦~</dd>
<dd class="pic"><img src="p1.jpg"></dd>
</dl>
<dl>
<dt>小標(biāo)題</dt>
<dd class="text">文字內(nèi)容哦~</dd>
<dd class="pic"><img src="p2.jpg"></dd>
</dl>
<dl>
<dt>小標(biāo)題</dt>
<dd class="text">文字內(nèi)容哦~</dd>
<dd class="pic"><img src="p3.jpg"></dd>
</dl>
</aside>
<article>
<h1>右邊<samp>標(biāo)題</samp></h1>
<p>這是右邊文章內(nèi)容哦~</p>
<img src="qrt.jpg">
<p>這是右邊文章內(nèi)容哦~</p>
</article>
</section>
<footer>
<div class="container">
<p>版權(quán)信息</p>
<span>
<img src="b1.jpg">
<img src="b2.jpg">
<img src="b3.jpg">
</span>
</div>
</footer>
</body>
</html>
style.css
* { font-size: 14px; margin: 0; padding: 0; border: none;}
a { text-decoration: none;}
ul { list-style: none;}
/*瀏覽器兼容解決*/
header,nav,section,aside,article,footer{display: block;}
/*頭部*/
header { width: 100%; height: 60px; background-color: #000;}
.container { width: 1200px; margin: 0 auto;}
.container > a { display: block; float: left; width: 150px; height: 60px; padding-left: 10px;}
.container > a img { height: 40px; padding-top: 10px;}
nav { font-size: 0; float: right; padding-right: 10px;}
nav > a { font-size: 16px; line-height: 60px; display: inline-block; width: 100px; height: 60px; cursor: pointer; text-align: center; color: #fff;}
nav > a:first-child { background: rgb(212, 1, 18);}
nav > a:nth-child(2) { background: rgb(254, 184, 0);}
nav > a:nth-child(3) { background: rgb(120, 185, 23);}
nav > a:nth-child(4) { background: rgb(242, 124, 1);}
nav > a:last-child { background: rgb(1, 127, 203);}
nav > a:hover, nav > a.active { padding-bottom: 5px;}
/*banner*/
.banner { background: #ccc;}
.banner ul { position: relative; width: 1200px; height: 400px; margin: 0 auto; padding-top: 100px;}
.banner ul li { position: absolute; z-index: 1; top: 0; bottom: 0; overflow: hidden; width: 500px; height: 250px; margin: auto;}
.banner ul li img { overflow: hidden; width: 100%;}
.banner ul li.active { z-index: 2; right: 0; /*設(shè)置水平居中*/ left: 0; width: 600px; height: 300px;}
.banner ul li.left { /*設(shè)置在左邊*/ left: 0;}
.banner ul li.right { /*設(shè)置在右邊*/ right: 0;}
/*主體部分*/
.main { width: 1200px; height: 350px; margin: 0 auto;}
aside { float: left; width: 600px;}
article { float: right; width: 600px;}
.main h1 { font-size: 24px; font-weight: lighter; margin: 20px 0;}
.main h1 samp { color: #7d7d7d;}
aside img { height: 70px;}
aside dl { position: relative; margin-bottom: 10px;}
aside dl dt { position: absolute; top: 0; left: 90px;}
aside dd.pic { overflow: hidden; width: 70px; height: 70px;}
aside dd.text { position: absolute; top: 20px; left: 90px;}
article > img { overflow: hidden; height: 130px;}
article > p { margin-bottom: 10px;}
/*底部*/
footer { background-color: #000;}
footer > .container { width: 1200px; height: 60px; margin: 0 auto;}
footer > .container > p { line-height: 60px; float: left; color: #fff;}
footer > .container > span { float: right;}
footer > .container > span > img { width: 25px; height: 25px; margin-left: 10px; padding-top: 17px; cursor: pointer; opacity: .7;}
footer > .container > span > img:hover { opacity: 1;}
/*# sourceMappingURL=style.css.map */
效果圖
原文鏈接:https://www.cnblogs.com/chenyingying0/p/12250255.html
喜歡小編的可以點(diǎn)個(gè)贊關(guān)注小編哦,小編每天都會給大家分享文章。
我自己是一名從事了多年的前端老程序員,小編為大家準(zhǔn)備了新出的前端編程學(xué)習(xí)資料,免費(fèi)分享給大家!
如果你也想學(xué)習(xí)前端,可以觀看【置頂】文章。也可以私信【1】 領(lǐng)取最新前端練手實(shí)戰(zhàn)項(xiàng)目
、美化網(wǎng)頁元素
本章目標(biāo):
【查看淘寶頁面,讓學(xué)員觀察,重點(diǎn)記住了什么東西】 因此使用CSS樣式美化網(wǎng)頁文本具有如下意義。
< span>標(biāo)簽 < span>標(biāo)簽 的作用:能讓某幾個(gè)文字或者某個(gè)詞語凸顯出來,從而添加對應(yīng)的樣式!
<p>好好學(xué)習(xí),<span>天天向上</span></p>
在這里插入圖片描述
*請認(rèn)真填寫需求信息,我們會在24小時(shí)內(nèi)與您取得聯(lián)系。