Search code examples
cssfluid-layout

Centered div and fluid left padding over the container


I have a centered red div (blue) with a max width (1240px) in my layout and I search to make this in CSS. The logo area (purple) from the left of the centering area (blue) is 300px. At the left of this point, in red, it will be fluid (whatever the screen resolution you have).

(btw, that's the same thing for the lightgray div just below)

Do you have an idea to do that?

image

<header>
   <div id="logo">
      <div class="w">
         <a href="#">Website name</a>
      </div>
   </div>

   <div class="wrap">
      <div class="r">
         <nav id="menu">
            <ul>
               <li><a href="#">link</a></li>
               <li><a href="#">link</a></li>
               <li><a href="#">link</a></li>
            </ul>
         </nav>
         <nav id="social">
            <ul>
               <li><a href="#">link</a></li>
               <li><a href="#">link</a></li>
            </ul>
         </nav>
      </div>
   </div>
</header>

Solution

  • Solved with a :before pseudo-class on the #logo element.

    #logo:before{content:""; position:absolute; top:0; right:100%; width:1000%; height:100%; background:red;}
    

    http://jsfiddle.net/Flayks/fUf2z/