tags:

views:

67

answers:

4

I have a stack of divs down the center of the page (using margin:auto)

now I want to draw a line starting at the center and extending to the right (say 400 pixels). I'm a but stumped, any idea how to make this work nicely?

cheers!

+3  A: 
div.line
{
    position: absolute;
    left: 50%;
    width: 50%;
}
Developer Art
This didn't work for me.
fudgey
You need to specify position:relative on the surrounding container for this div. Otherwise position:absolute may not work as expected.
Developer Art
I see, it didn't work because I have 7 divs all stacked on top of each other. You'll need to set the top position for each div.
fudgey
A: 

Put the content inside another tag.

And style the tag as following(for example a div):

div.special_tag {
  float: right;
  width: 50%;
}
brainfck
+1  A: 
div.line
{
  width: 400px;
  height: 10px;
  margin: 0 auto;
  border-right: 400px solid black;
}
Salman A
This worked for me
fudgey
Good to know :)
Salman A
A: 

Personally, I'd just use margins:

Set to the left of the midline:

.leftSide {
 width: 400px;
 height: 100px;
 margin: 0 50% 0 auto;
 background: #555;
 border: #777 1px solid;
}

or right side of midline

.rightSide {
 width: 400px;
 height: 100px;
 margin: 0 auto 0 50%;
 background: #555;
 border: #777 1px solid;
}
fudgey