【发布时间】:2017-08-04 17:15:21
【问题描述】:
我在一个网站上工作,其中一个部分的结构是这样的:
<div class="col-md-6">
<section class="right" data-type="background" data-speed="30" style="background: url(<?php echo get_field('book_image')['url']; ?>);">
</section>
</div>
在这种情况下,父 div(在 safari 中)的高度为 2976 像素。但是,即使我已将 height 属性应用于它,孩子也不会将自己调整到相同的高度。
我在 macOS 上的 Chrome 和 Safari 中都试过这个:Chrome 工作,Safari 没有。
有没有办法让它工作,最好没有任何 JS?谢谢:)
-- 编辑
我使用的是 Bootstrap4,但是,right 类只包含设置 div 样式的属性。以下内容
.right {
max-width: 50vw;
height: 100%;
background-size: 60vh !important;
background-repeat: no-repeat;
}
-- 编辑#2。
这是一个演示问题的 sn-p:
.left {
padding: 0;
background: #000; /*debugging*/
height: 200px; /*debugging*/
}
.right {
height: 100%;
background-size: 60vh !important;
background-repeat: no-repeat;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row">
<div class="col-6 left">
</div>
<div class="col-6">
<section class="right" data-type="background" data-speed="30" style="background: red;"></section>
</div>
</div>
</div>
(或在 JSFiddle 中:Click me
【问题讨论】:
-
如果您有考虑您的 class="right" 的 css 请告诉我,您是否使用引导程序或其他解决方案
-
height:100%;的孩子,inline-block父母 -
@Levon 编辑了我的帖子 :)
-
@Hash 这不会产生任何结果
-
您介意分享一支短笔/小提琴吗?至少我们需要知道您的 CSS 的外观,尤其是对于父级
col-md-6div。
标签: html css safari bootstrap-4