搜尋
首頁web前端html教學Bootstrap学习(3)_html/css_WEB-ITnose

Bootstrap 图片

   Bootstrap 对图片的支持。Bootstrap 提供了三个可对图片应用简单样式的 class:

  • .img-rounded:添加 border-radius:6px 来获得图片圆角。
  • .img-circle:添加 border-radius:500px 来让整个图片变成圆形。
  • .img-thumbnail:添加一些内边距(padding)和一个灰色的边框。
  • 请看下面的实例演示:

    <!DOCTYPE html><html><head>   <title>Bootstrap 实例 - 图像</title>   <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>   <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script></head><body><img  class="img-rounded lazy"  src="/static/imghwm/default1.png"  data-src="/wp-content/uploads/2014/06/download.png"  alt="Bootstrap学习(3)_html/css_WEB-ITnose" ><img  class="img-circle lazy"  src="/static/imghwm/default1.png"  data-src="/wp-content/uploads/2014/06/download.png"  alt="Bootstrap学习(3)_html/css_WEB-ITnose" ><img  class="img-thumbnail lazy"  src="/static/imghwm/default1.png"  data-src="/wp-content/uploads/2014/06/download.png"  alt="Bootstrap学习(3)_html/css_WEB-ITnose" ></body></html>            

     显示结果如下:

    Bootstrap学习(3)_html/css_WEB-ITnose

    以下类可用于任何图片中。

    类 描述
    .img-rounded 为图片添加圆角 (IE8 不支持)
    .img-circle 将图片变为圆形 (IE8 不支持)
    .img-thumbnail 缩略图功能
    .img-responsive 图片响应式 (将很好地扩展到父元素)

    圆角的图片

          <meta name="viewport" content="width=device-width, initial-scale=1">    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">        <div style="color:white">      <h2 id="图片">图片</h2>      <p> .img-rounded 类为图片添加圆角 (IE8 不支持):</p>                  <img class="img-rounded lazy" src="/static/imghwm/default1.png" data-src="1.jpg" alt="Cinque Terre"    style="max-width:90%"  style="max-width:90%">     </div>    <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>    <script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>  

    效果如下图所示:

    圆形的图片

    <!DOCTYPE html><html>  <head>    <meta name="viewport" content="width=device-width, initial-scale=1">    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">  </head>  <body style = "background-color:black">    <div class="container" style = "color:white">      <h2 id="图片">图片</h2>      <p> .img-rounded 类为图片添加圆角 (IE8 不支持):</p>                  <img class="img-circle lazy"  src="/static/imghwm/default1.png"  data-src="1.jpg"  alt="Cinque Terre"    style="max-width:90%"  style="max-width:90%">     </div>    <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>    <script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>  </body></html>

    效果如下图所示

    缩略图

    <!DOCTYPE html><html>  <head>    <meta name="viewport" content="width=device-width, initial-scale=1">    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">  </head>  <body style = "background-color:black">    <div class="container" style = "color:white">      <h2 id="图片">图片</h2>      <p> .img-thumbnail 类可制作图片缩略图:</p>                  <img class="img-thumbnail lazy"  src="/static/imghwm/default1.png"  data-src="1.jpg"  alt="Cinque Terre"    style="max-width:90%"  style="max-width:90%">     </div>    <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>    <script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>  </body></html>

    效果如下图所示:

    响应式图片

    通过在 Bootstrap学习(3)_html/css_WEB-ITnose 标签添加 .img-responsive 类来让图片支持响应式设计。 图片将很好地扩展到父元素。

    .img-responsive 类将 max-width: 100%; 和 height: auto; 样式应用在图片上:

          <meta name="viewport" content="width=device-width, initial-scale=1">    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">        <div style="color:white">      <h2 id="图片">图片</h2>      <p> .img-thumbnail 类可制作图片缩略图:</p>                  <img class="img-responsive lazy" src="/static/imghwm/default1.png" data-src="1.jpg" alt="Cinque Terre"    style="max-width:90%"  style="max-width:90%">     </div>    <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>    <script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>  

     效果如下图所示

      Bootstrap学习(1):

         Bootstrap学习(2):

       致谢:感谢您的阅读!

    陳述
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
    HTML標籤和HTML屬性有什麼區別?HTML標籤和HTML屬性有什麼區別?May 14, 2025 am 12:01 AM

    HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

    HTML的未來:進化和趨勢HTML的未來:進化和趨勢May 13, 2025 am 12:01 AM

    HTML的未來將朝著更加語義化、功能化和模塊化的方向發展。 1)語義化將使標籤更明確地描述內容,提升SEO和無障礙訪問。 2)功能化將引入新元素和屬性,滿足用戶需求。 3)模塊化將支持組件化開發,提高代碼復用性。

    為什麼HTML屬性對Web開發很重要?為什麼HTML屬性對Web開發很重要?May 12, 2025 am 12:01 AM

    htmlattributesarecrucialinwebdevelopment forcontrollingBehavior,外觀和功能

    Alt屬性的目的是什麼?為什麼重要?Alt屬性的目的是什麼?為什麼重要?May 11, 2025 am 12:01 AM

    alt屬性是HTML中標籤的重要部分,用於提供圖片的替代文本。 1.當圖片無法加載時,alt屬性中的文本會顯示,提升用戶體驗。 2.屏幕閱讀器使用alt屬性幫助視障用戶理解圖片內容。 3.搜索引擎索引alt屬性中的文本,提高網頁的SEO排名。

    HTML,CSS和JavaScript:示例和實際應用HTML,CSS和JavaScript:示例和實際應用May 09, 2025 am 12:01 AM

    HTML、CSS和JavaScript在網頁開發中的作用分別是:1.HTML用於構建網頁結構;2.CSS用於美化網頁外觀;3.JavaScript用於實現動態交互。通過標籤、樣式和腳本,這三者共同構築了現代網頁的核心功能。

    如何在標籤上設置lang屬性?為什麼這很重要?如何在標籤上設置lang屬性?為什麼這很重要?May 08, 2025 am 12:03 AM

    設置標籤的lang屬性是優化網頁可訪問性和SEO的關鍵步驟。 1)在標籤中設置lang屬性,如。 2)在多語言內容中,為不同語言部分設置lang屬性,如。 3)使用符合ISO639-1標準的語言代碼,如"en"、"fr"、"zh"等。正確設置lang屬性可以提高網頁的可訪問性和搜索引擎排名。

    HTML屬性的目的是什麼?HTML屬性的目的是什麼?May 07, 2025 am 12:01 AM

    htmlattributeseresene forenhancingwebelements'functionalityandAppearance.TheyAdDinformationTodeFineBehavior,外觀和互動,使網站互動,響應式,visalalyAppealing.AttributesLikutesLikeSlikEslikesrc,href,href,href,類,類型,類型,和dissabledtransfransformformformformformformformformformformformformformformforment

    您如何在HTML中創建列表?您如何在HTML中創建列表?May 06, 2025 am 12:01 AM

    toCreateAlistInHtml,useforforunordedlistsandfororderedlists:1)forunorderedlists,wrapitemsinanduseforeachItem,RenderingeringAsabulletedList.2)fororderedlists,useandfornumberedlists,useandfornumberedlists,casundfornumberedlists,casundfornthetthetthetthetthetthetthetttributefordforderfordforderforderentnumberingsnumberingsnumberingStys。

    See all articles

    熱AI工具

    Undresser.AI Undress

    Undresser.AI Undress

    人工智慧驅動的應用程序,用於創建逼真的裸體照片

    AI Clothes Remover

    AI Clothes Remover

    用於從照片中去除衣服的線上人工智慧工具。

    Undress AI Tool

    Undress AI Tool

    免費脫衣圖片

    Clothoff.io

    Clothoff.io

    AI脫衣器

    Video Face Swap

    Video Face Swap

    使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

    熱門文章

    熱工具

    禪工作室 13.0.1

    禪工作室 13.0.1

    強大的PHP整合開發環境

    VSCode Windows 64位元 下載

    VSCode Windows 64位元 下載

    微軟推出的免費、功能強大的一款IDE編輯器

    PhpStorm Mac 版本

    PhpStorm Mac 版本

    最新(2018.2.1 )專業的PHP整合開發工具

    SAP NetWeaver Server Adapter for Eclipse

    SAP NetWeaver Server Adapter for Eclipse

    將Eclipse與SAP NetWeaver應用伺服器整合。

    Safe Exam Browser

    Safe Exam Browser

    Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。