国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

老生常談Bootstrap媒體對象

2019-11-19 16:09:23
字體:
來源:轉載
供稿:網友

前面的話

在Web頁面或者說移動頁面制作中,常常看到圖文混排效果,圖片居左(或居右),內容居右(或居左)排列。常常把這樣的效果稱為媒體對象。可以說它是一種抽象的樣式,可以用來構建不同類型的組件。本文將詳細介紹Bootstrap媒體對象

默認樣式

媒體對象一般是成組出現,而一組媒體對象常常包括以下幾個部分:

☑ 媒體對像的容器:常使用“media”類名表示,用來容納媒體對象的所有內容

☑ 媒體對像的對象:常使用“media-object”表示,就是媒體對象中的對象,常常是圖片

☑ 媒體對象的主體:常使用“media-body”表示,就是媒體對像中的主體內容,可以是任何元素,常常是圖片側邊內容

☑ 媒體對象的標題:常使用“media-heading”表示,就是用來描述對象的一個標題,此部分可選

除了上面四個部分之外,在Bootstrap框架中還常常使用“media-left”或者“media-right”來控制媒體對象中的對象浮動方式

[注意]在 html 結構中, .media-right 應當放在 .media-body 的后面

媒體對象樣式相對來說比較簡單,只是設置他們之間的間距

.media,.media-body { overflow: hidden; zoom: 1;}.media,.media .media { margin-top: 15px;}.media:first-child { margin-top: 0;}.media-object { display: block;}.media-heading { margin: 0 0 5px;}.media-left { margin-right: 10px;}.media-right { margin-left: 10px;}
<div class="media">  <a class="media-left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <img class="media-object" width=100 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">  </a>  <div class="media-body">    <h4 class="media-heading">小火柴的藍色理想</h4>    <div>好的代碼像粥一樣,都是用時間熬出來的</div>  </div></div>

嵌套

在評論系統中,經常會有媒體對象嵌套的需求。在Bootstrap框架中的媒體對象也具備這樣的功能,只需要將另一個媒體對象結構放置在媒體對象的主體內“media-body”

<div class="media">  <a class="media-left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <img class="media-object" width=100 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">  </a>  <div class="media-body">    <h4 class="media-heading">小火柴的藍色理想</h4>    <div>好的代碼像粥一樣,都是用時間熬出來的</div>    <div class="media">      <a class="pull-left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >        <img class="media-object" src="http://via.placeholder.com/100x100" alt="...">      </a>      <div class="media-body">        <h4 class="media-heading">我是小火柴</h4>        <div>好巧啊,我也叫小火柴</div>        <div class="media">          <a class="pull-left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >            <img class="media-object" width=100 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">          </a>          <div class="media-body">            <h4 class="media-heading">小火柴的藍色理想</h4>            <div>是的</div>          </div>        </div>      </div>    </div>  </div></div><div class="media">  <a class="media-left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <img class="media-object" width=100 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">  </a>  <div class="media-body">    <h4 class="media-heading">小火柴的藍色理想</h4>    <div>藍色理想衰落了,前端卻欣欣向榮起來</div>  </div></div>

對齊方式

圖片或其他媒體類型可以頂部、中部或底部對齊。默認頂部對齊。通過.media-middle或.media-bottom來設置

.media-middle {  vertical-align: middle;}.media-bottom {  vertical-align: bottom;}
<div class="media">  <a class="media-left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <img class="media-object" width=30 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">  </a>  <div class="media-body">    <h4 class="media-heading">小火柴的藍色理想</h4>    <div>藍色理想衰落了,前端卻欣欣向榮起來</div>  </div></div><div class="media">  <a class="media-left media-middle" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <img class="media-object" width=30 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">  </a>  <div class="media-body">    <h4 class="media-heading">小火柴的藍色理想</h4>    <div>藍色理想衰落了,前端卻欣欣向榮起來</div>  </div></div><div class="media">  <a class="media-left media-bottom" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <img class="media-object" width=30 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">  </a>  <div class="media-body">    <h4 class="media-heading">小火柴的藍色理想</h4>    <div>藍色理想衰落了,前端卻欣欣向榮起來</div>  </div></div>

媒體對象列表

媒體對象的嵌套僅是媒體對象中一個簡單應用效果之一,在很多時候,我們還會碰到一個列表,每個列表項都和媒體對象長得差不多。Bootstrap框架提供了一個列表展示的效果,在寫結構的時候可以使用ul,并且在ul上添加類名“media-list”,而在li上使用“media”

媒體對象列表,在樣式上也并沒有做過多的特殊處理,只是把列表的左間距置0以及去掉了項目列表符號

.media-list { padding-left: 0; list-style: none;}
<ul class="media-list"> <li class="media">  <a class="media-left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <img class="media-object" width=30 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">  </a>  <div class="media-body">    <h4 class="media-heading">小火柴的藍色理想</h4>    <div>藍色理想衰落了,前端卻欣欣向榮起來</div>  </div> </li> <li class="media">  <a class="media-left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <img class="media-object" width=30 src="http://files.VeVB.COm/file_images/article/201707/huochai.jpg" alt="...">  </a>  <div class="media-body">    <h4 class="media-heading">小火柴的藍色理想</h4>    <div>好的代碼像粥一樣,都是用時間熬出來的</div>  </div> </li> </ul>

以上這篇老生常談Bootstrap媒體對象就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙江县| 庄河市| 廊坊市| 铜陵市| 南木林县| 宜宾市| 宜黄县| 潞西市| 含山县| 盐源县| 泽州县| 瑞安市| 宁安市| 义乌市| 同江市| 五台县| 邯郸县| 额敏县| 团风县| 晋江市| 长垣县| 芮城县| 石台县| 定安县| 承德市| 巢湖市| 大连市| 湘潭市| 德化县| 外汇| 龙井市| 房产| 天柱县| 田林县| 玉环县| 日照市| 同心县| 黔南| 句容市| 鄱阳县| 桐城市|