似乎无法找出这一个。将背景图像应用于Bootstrap列,但给0高度?
我想有这应该在一个div的右手部分应用背景图像,并使用自举列会做到这一点的最好方式响应思想。但是,图像没有显示,因为列div的高度始终为1像素,无论CSS如何。
这是为什么,我该如何将其设置为在其他分区的整个高度?
HTML
<div id="procedure-singleReview" class="well">
<div class="row">
<div class="col-md-8">
<h2 class="bv-brand">Here's what a happy client says...</h2>
<blockquote>
<?php echo $sidebarReviews[0]->post_excerpt;?>
<footer><?php echo get_post_meta($sidebarReviews[0]->ID,'client_name',true);?> <span class="rating rating-<?php echo get_post_meta($sidebarReviews[0]->ID, 'rating', true);?>"></span></footer>
</blockquote>
<a href="<?php echo get_the_permalink($sidebarReviews[0]->ID);?>" class="btn btn-primary">Read full review</a> <a href="/testimonial-reviews/" class="btn btn-default">Read all reviews</a>
</div>
<div class="col-md-4 hidden-sm img"></div>
</div>
</div>
CSS
#procedure-singleReview .img {
height:100%;
background-image:url(http://placehold.it/800x600);
background-size:cover;
background-repeat:no-repeat;
background-position:center;
}
你会尝试'background-size:100%;'? –
尽管我已经尝试过了,但它并未改变高度,只影响容器内背景图像的显示(在此情况下为1像素高)。无论如何,我不希望将背景大小设置为100%,因为我希望它特别使用“封面”来填充div的空间。 – Lee
'身高:100%'不起作用。如果你想以这种方式使用它,你需要在父元素上设置一个高度(比如100px)。看到这个小提琴:https://jsfiddle.net/1max0ry9/ – user3528269