css圖片怎么實(shí)現(xiàn)垂直

這篇文章將為大家詳細(xì)講解有關(guān)css圖片怎么實(shí)現(xiàn)垂直,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)成立于2013年,先為路北等服務(wù)建站,路北等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為路北企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

vertical-align屬性

我們使用text-align屬性來(lái)定義圖片水平對(duì)齊方式。

大家就開始有疑問了,圖片水平對(duì)齊我們實(shí)現(xiàn)了,那如果想對(duì)圖片進(jìn)行垂直對(duì)齊呢?

在CSS中,我們可以使用vertical-align屬性來(lái)定義圖片的垂直對(duì)齊方式。

語(yǔ)法:vertical-align:屬性值;

vertical-align還有sub、super等一些屬性值,對(duì)于這些我們不需要去理會(huì),因?yàn)樵趯?shí)際開發(fā)中壓根兒用不上。我們只需要使用以上這4個(gè)屬性值就完全足夠了。

舉例1:

<!DOCTYPEhtml>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<title>vertical-align屬性</title>

<styletype="text/css">

img{width:80px;height:80px;}

#img_1{vertical-align:top;}

#img_2{vertical-align:middle;}

#img_3{vertical-align:bottom;}

#img_4{vertical-align:baseline;}

</style>

</head>

<body>

php中文網(wǎng)<imgid="img_1"src="https://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg"alt=""/>php中文網(wǎng)(<strong>top</strong>)

<hr/>

php中文網(wǎng)<imgid="img_2"src="https://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg"alt=""/>php中文網(wǎng)(<strong>middle</strong>)

<hr/>

php中文網(wǎng)<imgid="img_3"src="https://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg"alt=""/>php中文網(wǎng)(<strong>bottom</strong>)

<hr/>

php中文網(wǎng)<imgid="img_4"src="https://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg"alt=""/>php中文網(wǎng)(<strong>baseline</strong>)

</body>

</html>

效果如下:

微信截圖_20181112155823.png

大家仔細(xì)觀察一下,“vertical-align:baseline”和“vertical-align:bottom”是有區(qū)別的。

舉例2:

<!DOCTYPEhtml>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<title>vertical-align屬性</title>

<styletype="text/css">

div

{

width:100px;

height:80px;

border:1pxsolidgray;

}

.div_img1{vertical-align:top;}

.div_img2{vertical-align:middle;}

.div_img3{vertical-align:bottom;}

img{width:60px;height:60px;}

</style>

</head>

<body>

<divclass="div_img1">

<imgsrc="https://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg"alt=""/>

</div>

<divclass="div_img2">

<imgsrc="https://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg"alt=""/>

</div>

<divclass="div_img3">

<imgsrc="https://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg"alt=""/>

</div>

</body>

</html>

關(guān)于“css圖片怎么實(shí)現(xiàn)垂直”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

當(dāng)前題目:css圖片怎么實(shí)現(xiàn)垂直
路徑分享:http://bm7419.com/article32/igispc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版動(dòng)態(tài)網(wǎng)站、域名注冊(cè)網(wǎng)站導(dǎo)航、靜態(tài)網(wǎng)站企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

小程序開發(fā)