I created a starter for ten, which you can look at JS Fiddle .
I used the following HTML and CSS example
HTML
<div id="example"> <h1>Example</h1> <p>Example text followed by a horizontal rule example text followed by a horizontal rule example text followed by a horizontal rule.</p> <hr> <p>Example text followed by a horizontal rule example text followed by a horizontal rule example text followed by a horizontal rule.</p> <hr> </div>
CSS
#example { width: 50%; margin: 0 auto; background-color: #FCFCFC; } #example hr { width: 150%; }
Fixed fixed width
You can get the same final result with a fixed pixel width, but it's a little more complicated.
I rejected your example to demonstrate this solution on JSFiddle .
Based on the HTML you specified CSS:
body { overflow-x: hidden; } .wrapper { width:800px; margin:0 auto; } .leftCol { width:200px; float:left; background-color:#ccc; margin:0; } .rightCol { width:600px; float:right; background-color:#dadada; margin:0; } hr { width: 200%; } @media only screen and (max-width: 800px) { body { overflow-x: auto; } hr { width: 100%; } }
Please note that the final part of this solution uses a media query to reset values ββwhen the viewport size changes below 800 pixels, because at the moment you want to enable the horizontal scroll bar. Media queries do not work in some older browsers, so you need to test them in the browsers you want to support. In the worst case scenario, your users lose the ability to scroll horizontally in older browsers.
source share