Search code examples
csszurb-foundationcodepen

How to break out of foundation row and stick to right edge of viewport


I have an example of zurb foundation grid on codepen. I'm trying to think of a way to extend a div to the right edge of the viewport but keep the left edge inline with the grid as the viewport is resized.

<div class="row">
  <div class="large-12 columns">
    <div class="my-custom-block">
      MY CUSTOM BLOCK ==> Please extend to right edge of viewport
    </div>
  </div>
</div>

Update I don't mind if the solution is outside the grid and doesn't use Foundation. I just want the my component to match the start of the grid but stay flush to the right of the viewport when resized.

zurb example

example on codepen


Solution

  • The problem is that the row class has a defined width/max-width with margin:auto on it. If you don't mind changing row to a percentage max-width you could do something like this:

    .row {
     max-width: 62.5%;
    }
    
    .special-row {
     overflow:hidden;
     width: 100%;
     float: right;
     margin-right: 0;   
     margin-top: 0;
     margin-bottom: 0;
     //this is halfway between the 62.5% above and 100%
     max-width: 81.25%;
    }