good_evening
good_evening

Reputation: 21739

Use the width of the body, not the element

<div id="tst">
    Hello. 
    <div id="ln">
     Red line should be not just in tst element, but in all body.            
    </div>
</div>​

#tst {
 width: 200px;
 margin: 10px auto;            
}
#ln {
 width: 100%;
 border-bottom: 2px solid red;    
}
​

Working example: http://jsfiddle.net/hXEe7/

Is it possible to make red line 100% width of the body without putting #ln element outside #tst? Line must be in #ln element, it's just an example. Thanks.

Upvotes: 0

Views: 58

Answers (2)

#ln {
    width: 100%;
    border-bottom: 2px solid red;   
    position:absolute;
    left: 0;
    right: 0;
}

Will take <div id="ln"> out of the regular document flow, and will use the body's width.

Upvotes: 2

The easiest way to do this, provided that no other element above it is positioned, is to make the line's position absolute like this:

#ln {
     position: absolute;
     left: 0;
     right: 0;
}

Upvotes: 2

Related Questions