将h1元素的宽度限制为其父元素

时间:2019-11-12 22:25:20

标签: css

我想限制hd的宽度,但不必设置宽度。我希望它占据全部可用宽度(父母的宽度吗?)

.wrapper {
  outline: 1px #000 solid;
  width: 600px;
  margin: auto;
  display: flex;
}

.left {
  flex-grow: 1
}

.left h1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.right {
  width: 200px;
  background-color: #CCC;
}
<div class="wrapper">
  <div class="left">
    <h1>this is a really really really long heading</h1>
  </div>
  <div class="right">right</div>
</div>

0 个答案:

没有答案