詳解Bootstrap四種圖片樣式
在本章中,我們將學(xué)習(xí) Bootstrap 對(duì)圖片的支持。Bootstrap 提供了四個(gè)可對(duì)圖片應(yīng)用簡(jiǎn)單樣式的class,分別是:
img-rounded 添加 border-radius:6px 來(lái)獲得圖片圓角
img-circle 添加 border-radius:50% 來(lái)讓整個(gè)圖片變成圓形
img-thumbnail 添加一些內(nèi)邊距(padding)和一個(gè)灰色的邊框
img-responsive 圖片響應(yīng)式
1、img-rounded
<!doctype html> <html lang="en"> <head> <!--網(wǎng)站編碼格式,UTF-8 國(guó)際編碼,GBK或 gb2312 中文編碼--> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="Keywords" content="關(guān)鍵詞一,關(guān)鍵詞二"> <meta name="Description" content="網(wǎng)站描述內(nèi)容"> <meta name="Author" content="Yvette Lau"> <meta name = "viewport" content = " width = device-width, initial-scale = 1 "> <title>BootstrapDemo</title> <!--css js 文件的引入--> <link rel="stylesheet" type="text/css" href="../bootstrap-3.3.5-dist/css/bootstrap.min.css"> </head> <body style="padding: 20px;"> <div class = "container"> <img src = "5.jpg" class="img-rounded" > </div> </body> </html>
.img-rounded{border-radius:6px;}
效果:
2、img-circle
<body style="padding: 20px;"> <div class = "container"> <img src = "5.jpg" class="img-circle" > </div> </body>
.img-circle{border-radius:50%;}
效果(因?yàn)楸緢D片的寬高大小不同,所以呈現(xiàn)出橢圓,如果將width和height設(shè)置相同,那么會(huì)呈現(xiàn)出一個(gè)圓):
3、img-thumbnail
<body style="padding: 20px;"> <div class = "container"> <img src = "5.jpg" class="img-thumbnail" > <img src = "4.jpg" class="img-thumbnail" > <img src = "3.jpg" class="img-thumbnail" > </div> </body>
.img-thumbnail{display:inline-block;max-width:100%;height:auto;padding:4px;line-height:1.42857143;
background-color:#FFF;border:1px solid #DDD;border-radius:4px;transition:all 0.2s ease-in-out;}
效果:
4、img-responsize
<body style="padding: 20px;"> <div class = "container" style = "width:150px;"> <img src = "5.jpg" class="img-responsive" width="400px" > </div> </body>
.img-responsive{display:block;max-width:100%;height:auto;}
效果(img中的width屬性值被忽略):
以上內(nèi)容分步驟給大家介紹了Bootstrap四種圖片樣式的相關(guān)知識(shí),希望大家喜歡。
相關(guān)文章
JavaScript正則表達(dá)式替換字符串中圖片地址(img src)的方法
這篇文章主要介紹了JavaScript正則表達(dá)式替換字符串中圖片地址(img src)的方法,結(jié)合實(shí)例形式分析了JS正則替換的常用技巧與注意事項(xiàng),需要的朋友可以參考下2017-01-01詳解Web使用webpack構(gòu)建前端項(xiàng)目
本篇文章主要介紹了詳解Web使用webpack構(gòu)建前端項(xiàng)目,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-09-09javascript 動(dòng)態(tài)數(shù)據(jù)下的錨點(diǎn)錯(cuò)位問(wèn)題解決方法
用 Javascript 實(shí)現(xiàn)錨點(diǎn)(Anchor)間平滑跳轉(zhuǎn)2008-12-12javascript工廠模式和構(gòu)造函數(shù)模式創(chuàng)建對(duì)象方法解析
本文主要對(duì)javascript工廠模式和構(gòu)造函數(shù)模式創(chuàng)建對(duì)象方法進(jìn)行解析,具有一定的參考價(jià)值,下面跟著小編一起來(lái)看下吧2016-12-12在JavaScript中監(jiān)聽(tīng)I(yíng)ME鍵盤(pán)輸入事件
在 JavaScript 中監(jiān)聽(tīng)用戶(hù)的鍵盤(pán)輸入是很容易的事情,但用戶(hù)一旦使用了輸入法,問(wèn)題就變得復(fù)雜了。2011-05-05JavaScript實(shí)現(xiàn)簡(jiǎn)單購(gòu)物小表格
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)簡(jiǎn)單購(gòu)物小表格,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09javascript 函數(shù)參數(shù)原來(lái)是可以有缺省值的
前幾天看 javaEye 時(shí)看到一個(gè)童鞋寫(xiě)的 getElementsByClassName 函數(shù)。2010-07-07