0

I how can I solve this responsive layout case: I have three boxes. On wide screens I want two of them on the left with a fixed width and the other one on the right. On small screens I want all boxes to become 100% and the right one to be between the other two.

I´ve made a fiddle that almost works, but I need to get rid of that gap in wide mode.

https://jsfiddle.net/ypmgo7no/3/

.leftfixed {
  float:left;
  width:200px;
  background:purple;
  height:50px;
}

.right {
  margin-left:220px;
  background:yellow;
  height:100px;
}

@media (max-width:500px) {
  .leftfixed {
    float:none;
      width:100%;
      background:blue;
   }

   .right {
     margin-left:0;
     }
}

See the problem: (sorry, just realised that "Wide mode" and "Small mode" in the image are interchanged) Image

2 Answers2

0

Do you want like this?

.leftfixed {
  float:none;
  width:200px;
  background:purple;
  height:100px;
}

.right {
    left: 220px;
    background: yellow;
    height: 200px;
    position: absolute;
    width: 100%;
    top: 7px;
  }

@media (max-width:500px) {
  .leftfixed {
    float:none;
      width:100%;
      background:blue;
   }
   
   .right {
     margin-left:0;
     position:inherit;
     
     }
}
<div class="leftfixed">
box left fixed width 1
</div>

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

<div class="leftfixed">
box left fixed width 2
</div>
Sagar Kodte
  • 3,723
  • 4
  • 23
  • 52
0

This is another method i added class bottom to last div and added position:relative and bottom:100px in your original code.

.leftfixed {
  float:left;
  width:200px;
  background:purple;
  height:100px;
}

.right {
    margin-left: 220px;
    background: yellow;
    height: 200px;
    /*position: absolute;*/
    width: 100%;
    top: 7px;
  }
  .bottom{
       position: relative;
     bottom: 100px;
  }

@media (max-width:500px) {
  .leftfixed {
    float:none;
      width:100%;
      background:blue;
   }
   
   .right {
     margin-left:0;
   
     
     }
}
<div class="leftfixed">
box left fixed width 1
</div>

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

<div class="leftfixed bottom">
box left fixed width 2
</div>
Sagar Kodte
  • 3,723
  • 4
  • 23
  • 52