html - 两个 div 之间出现无法解释的间隙

标签 html css twitter-bootstrap twitter-bootstrap-3

我在两个 div 之间出现了无法解释的间隙。

这是情况的图片:

enter image description here

这是我想要消失的红色 div 上方的间隙。

我希望红色 div 一直是 red 到图像所在的位置。我该怎么做?

代码:

<script type="text/html" id="product-template">
    <div class="col-sm-6 col-lg-2 clickable" style="margin-top:20px; padding: 25px;">
        <div style="border-radius: 10px; border: 1px solid white;height: 270px;overflow: hidden;">
            <div style= "height: 200px; border: 1px solid white; 
                        border-top-left-radius: 10px; 
                        border-top-right-radius: 10px;
                        color: white; 
                        background: center no-repeat;
                        background-image: url(../../the_vegan_repository/product_images/alpro_custard.jpg);
                        background-size:cover;">
            </div>
            <div style="height: 70px; background: red;">
                <h6 data-bind="text: product.name" style="color: white"></h6>
                <h6 data-bind="text: shop.name" style="color: white"></h6>
                <h6 data-bind="text: shop.suburb" style="color: white"></h6>
            </div>
        </div>
    </div>
</script>

最佳答案

你有一个 h6 有你底部 div 的 child ,在 Bootstrap 中,标题从 h1h6具有 margin-top:10pxmargin-bottom:10px “默认”,因此您需要在 h6< 中重置 margin/.

类似于:

h6 {
  margin-top:0
}

关于html - 两个 div 之间出现无法解释的间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36830620/

相关文章:

javascript - 我如何将点击事件定位到 Angular 2 中的另一个组件

javascript - 在用户点击时,将一段 javascript 加载到页面中

javascript - 毫不拖延,如何用js或jquery隐藏body中的所有图像

html - 将 glyphicon 添加到 rails link_to helper 并在悬停时禁用效果

javascript - 为什么 jQuery .click() 在此 <a> 标记上使用时不会导致回发?

html - 为什么我的导航栏中的文本重叠?

javascript - fullpage.js 调整点的大小以方便通过手机浏览

javascript - 链接到程序生成的 CSS,就好像它是一个外部文件一样?

ios - 图像中的 Bootstrap Modal 在 iOS 中不起作用

javascript - 使用 Bootstrap 模式打开新窗口