Bootstrap图像

前面的话

  图像在网页制作中也是常要用到的元素,本文将详细介绍Bootstrap图像

 

响应式图片

  通过为图片添加 

.img-responsive
 类可以让图片支持响应式布局。其实质是为图片设置了 
max-width: 100%;
、 
height: auto;
 和 
display: block;
 属性,从而让图片在其父元素中更好的缩放

img {
    vertical-align: middle;
}
.img-responsive,.thumbnail>img,.thumbnail a >img,.carousel-inner > .item >img,.carousel-inner > .item > a >img {
    display: block;
    max-width: 100%;
    height: auto;
}

  如果需要让使用了 

.img-responsive
 类的图片水平居中,请使用 
.center-block
 类,不要用 
.text-center

  在IE8-10浏览器中,设置为 

.img-responsive
 的 SVG 图像显示出的尺寸不匀称。为了解决这个问题,在出问题的地方添加 
width: 100% \9;
 即可。Bootstrap 并没有自动为所有图像元素设置这一属性,因为这会导致其他图像格式出现错乱

<div>
    <img src="http://via.placeholder.com/350x150" class="img-responsive" alt="Responsive image">
</div>

style="width: 100%; height: 180px;" src="https://demo.xiaohuochai.site/bootstrap/img/i1.html" frameborder="0" width="320" height="240">

 

图片形状

  通过为 

<img>
 元素添加以下相应的类,可以让图片呈现不同的形状

  1、img-rounded:圆角图片

  2、img-circle:圆形图片

  3、img-thumbnail:缩略图片

  对于圆角图片和圆形图片效果,因为是使用了CSS3的圆角样式border-radius来实现的,所以注意对于IE8以及其以下版本不支持,是没有圆角效果的。

.img-rounded {
    border-radius: 6px;
}
.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;
    -webkit-transition: all .2s ease-in-out;
    transition: all .2s ease-in-out;
}
.img-circle {
    border-radius: 50%;
}
<div>
    <img src="http://via.placeholder.com/140x140" alt="rounded" class="img-rounded">
    <img src="http://via.placeholder.com/140x140" alt="circle" class="img-circle">
    <img src="http://via.placeholder.com/140x140" alt="thumbnail" class="img-thumbnail">    
</div>

style="width: 100%; height: 180px;" src="https://demo.xiaohuochai.site/bootstrap/img/i2.html" frameborder="0" width="320" height="240">

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值