Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

flexbox - CSS: element has 'display: block' and doesn't start a new line

Please take a look on the following code:

.header {
  display: flex;
  width: 100vw;
  height: 20vh;
}

div {
  border: solid;
}

#first {
  flex: 1
}

#second {
  flex: 1
}

#third {
  flex: 1
}
<header class="header">
  <div id="first"></div>
  <div id="second"></div>
  <div id="third"></div>
</header>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

However, I know that when an element has a display: block property, it means that the element starts a new line.

Your information is wrong because the display property alone never tells us if we will have a new line or not.

Let's take another example without flexbox:

.box {
  width:200px;
  height:200px;
  border:2px solid;
  float:left;
}
<div class="box">

</div>
<div class="box">

</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...