Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to div reverse order with horizontally

Trying to div reverse order with horizontally. But not working. How to show div horizontally with reverse order? I have used float right for each dive but not working. How to fix this issue?

app.component.html:

    <div class="wrapper">
      <div class="top">top</div>
      <div class="bottom">bottom</div>
    </div>

app.component.css:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 .wrapper {
   width:100%;
  flex-direction: column-reverse;
  display:  flex;
  grid-template-columns: auto 1fr;
}
 
.wrapper div{
  width:50%;
  border:2px solid #ccc; 
}

.top{
  float: right;
}

.bottom{
  float: right;
}

Demo: https://stackblitz.com/edit/angular-ivy-ueqfmx?file=src%2Fapp%2Fapp.component.css

>Solution :

You cannot float the child element of a flex container. You need to either use flexbox, or floats. Not both. Other than that, your code works fine

.wrapper {
  width:100%;
  flex-direction: column;
  display:  flex;
  grid-template-columns: auto 1fr;
}
.wrapper div{
  width:50%;
  border:2px solid #ccc; 
}

.col-reversed {
  flex-direction: column-reverse;
}

.row {
  flex-direction: row;
}

.row-reversed {
  flex-direction: row-reverse;
}
 
<div class="wrapper">
  <div class="top">top</div>
  <div class="bottom">bottom</div>
</div>

<br><br>

<div class="wrapper col-reversed">
  <div class="top">top</div>
  <div class="bottom">bottom</div>
</div>

<br><br>

<div class="wrapper row">
  <div class="top">top</div>
  <div class="bottom">bottom</div>
</div>

<br><br>

<div class="wrapper row-reversed">
  <div class="top">top</div>
  <div class="bottom">bottom</div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading