Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery bootstrap如何使固定高度响应?_Jquery_Html_Css_Twitter Bootstrap_Carousel - Fatal编程技术网

Jquery bootstrap如何使固定高度响应?

Jquery bootstrap如何使固定高度响应?,jquery,html,css,twitter-bootstrap,carousel,Jquery,Html,Css,Twitter Bootstrap,Carousel,如何使用bootstrap 3使固定高度元素响应?例如,我将carousal的高度设置为650px。但我不能让它像图片那样灵敏。有什么想法吗 css html .... 试试: 或者, 我认为使用js更好(使用boostrap我们将使用jquery): 在这种情况下,将带有背景图像的div添加到中,您的css必须: .carousel-inner > item { position: relative; overflow:hidden; } .carousel-inner >

如何使用bootstrap 3使固定高度元素响应?例如,我将carousal的高度设置为650px。但我不能让它像图片那样灵敏。有什么想法吗

css

html


....
试试:

或者, 我认为使用js更好(使用boostrap我们将使用jquery):

在这种情况下,将带有背景图像的div添加到中,您的css必须:

.carousel-inner > item { position: relative; overflow:hidden;  }
.carousel-inner > item > .img-responsive-fix { position: absolute; top:0; bottom:0; left:0; right:0; text-align:center; padding:0; margin:0; }
.carousel-inner > item > .img-responsive { witdh:auto; }

您可以使用css3对象拟合来调整图像大小

它适用于Chrome和Opera。为其他人使用polyfill库:或


另一种方法是使用css3背景大小

它适用于所有没有javascript的现代浏览器,但您需要使用
而不是


您需要使用媒体查询重新设置旋转木马控制类的样式 这里只是一个要添加的示例代码

 @media (max-width: 800px) {
    .carousel-control{
      height:350px;
    }
 }

我也有同样的问题,反应固定高度。我用vh代替px。就我而言,它就像一个符咒

img {
    height: 85vh;
    width: 100%;
    object-fit: cover; // here
}

试试下面这个对我来说很好

/*使图像完全响应*/
.旋转木马内部img{
宽度:500px;
高度:350px;
}
旋转木马
{
高度:350px;
宽度:500px
}

您是否尝试更改img元素的高度而不是.carousel-inner?图像具有不同的高度,因此我想使用overflow hidden对其进行裁剪…将img响应类设置为高度:100%以允许图像达到全高。通常,您会从最小最小宽度到最大最小宽度进行媒体查询,然后设置里面的高度。我通过添加css3
background size
way改进了答案。它适用于所有没有javascript的现代浏览器。我通过添加css3
background size
way改进了答案。
...
function init_carousel(){
    H = +($( window ).height()); // or $('.carousel-inner') as you want ...
    $('.img-responsive').css('height',H+'px');
}
init_carousel();
...
.carousel-inner > item { position: relative; overflow:hidden;  }
.carousel-inner > item > .img-responsive-fix { position: absolute; top:0; bottom:0; left:0; right:0; text-align:center; padding:0; margin:0; }
.carousel-inner > item > .img-responsive { witdh:auto; }
img {
    height: 650px;
    width: 100%;
    object-fit: cover; // here
}
.image {
    height: 650px;
    background-position: center;
    background-size: cover;
}
<div class="image" style="background-image: url('my-image.jpg')"></div>
          function Screensize() {
        try {
            var height = ((screen.height * 80) / 100);
            document.getElementById('Mapbox').setAttribute("style", "display:block;height:" + height + "px; overflow:auto;");
        } 
        catch (ex)
        {  alert(ex); }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    }
 @media (max-width: 800px) {
    .carousel-control{
      height:350px;
    }
 }
img {
    height: 85vh;
    width: 100%;
    object-fit: cover; // here
}