0

I have this html and css. How do I push Menu A content to new line? below the titles?

.root {
  display: flex;
}

.content {
  order: 2;
}
<div class="root">
  <div class="title">Menu A</div>
  <div class="content">Menu A content</div>

  <div class="title">Menu B</div>
</div>
Dhaval Jardosh
  • 7,151
  • 5
  • 27
  • 69
Jane Emelia
  • 477
  • 2
  • 5
  • 11

4 Answers4

2

.root {
  display: flex;
  display: -webkit-flex; 
  -webkit-flex-wrap: wrap; 
  flex-wrap: wrap;
}

.content {
  order:2;
  width:100%
}
<div class="root">
  <div class="title">Menu A</div>
  <div class="content">Menu A content</div>
  <div class="title">Menu B</div>
</div>
chintan
  • 311
  • 1
  • 8
1

You can try this

.root {
  display: flex;
  flex-direction: column;  /* Add this */
}

.content {
  order: 2;
}
<div class="root">
  <div class="title">Menu A</div>
  <div class="content">Menu A content</div>

  <div class="title">Menu B</div>
</div>

Or try this

.root {
  display: flex;
  flex-direction: column; /* Add this */
  flex-flow: wrap;  /* Add this */
}

.content {
  order: 2;
  width: 100%;
}
<div class="root">
  <div class="title">Menu A</div>
  <div class="content">Menu A content</div>

  <div class="title">Menu B</div>
</div>
LKG
  • 4,152
  • 1
  • 11
  • 21
0

try this:

.root {
  display: flex;
  flex-wrap: wrap;
}
.root div{
  width: 100%;
}  
<div class="root">
  <div class="title">Menu A</div>
  <div class="content">Menu A content</div>

  <div class="title">Menu B</div>
</div>
-1

You need to adjust your class in the following way.

.root
  .sub-root
    .title
    .content
  .sub-root
    .title
 and so on....

As you are using Flex.

Your sub-root will be adjacent to each other, and your content will be on the next line.

And by correct way, I meant fixing your HTML. :)

.root {
  display: flex;
}
<div class="root">
  <div class="sub-root">
    <div class="title">Menu A</div>
    <div class="content">Menu A content</div>
  </div>
  <div class="sub-root">
    <div class="title">Menu B</div>
  </div>
</div>
Dhaval Jardosh
  • 7,151
  • 5
  • 27
  • 69
  • I'm sorry, what? In what way is the existing HTML not "correct"? (I suspect there is a valid underlying point here that's being clouded by *extremely* poor writing.) – BoltClock Apr 19 '18 at 03:57