如何使CSS响应图像

时间:2017-05-19 14:11:41

标签: html css twitter-bootstrap

我在我的css类中添加了一个图像。现在我需要使用img-responsive Bootstrap方法来使这个图像响应。我怎么能这样做?

我的代码:

CSS

.mybackground {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
  height: 100vh;
  vertical-align: top;
    background: url(img.png) ;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;

}

注意:我已将图像添加到CSS类中。

2 个答案:

答案 0 :(得分:0)

我强烈建议您查看以下内容:

首先是Bootstrap中的img项: http://getbootstrap.com/css/#images

然后确认您正在进行适当的媒体通话: http://getbootstrap.com/css/#responsive-utilities

答案 1 :(得分:0)

将以下内容添加到CSS

 height: 100%;
 background: url(".....") no-repeat;
 background-size: 100% auto;