【问题标题】:Containing element does not grow to fit rotated child element [duplicate]包含元素不会增长以适合旋转的子元素[重复]
【发布时间】:2018-10-16 01:36:59
【问题描述】:

下面我有两个 div,一个增长到假设它的孩子的高度,另一个因为 css 转换,父母的高度没有调整。有谁知道为什么第二个 div 的高度没有调整,是否有解决这个问题的方法不涉及使用 javascript 更改父级的高度?

.container {
  background-color: blue;
  position: relative;
  margin-bottom: 200px;
}

.child {
  background-color: red;
  width:500px;
  height:100px;
  position: relative;
  left: 30%;
}

.b > .child {
  transform:  rotate(-90deg);
}
Container's height grows to fit child element:
<div class="container a">
  <div class="child"></div>
</div>

Container's height does not adjust to fit rotated element:
<div class="container b">
  <div class="child"></div>
</div>

【问题讨论】:

  • 因为transform纯视觉,不影响布局。

标签: javascript html css


【解决方案1】:

您使用旋转子元素进行了更改。高度和宽度的行为会有所不同。 你能试试这个代码,也许它会有所帮助。

.b > .child {  transform:  rotate(-90deg);   width: 100px; }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 2021-09-15
    相关资源
    最近更新 更多