tags:

views:

39

answers:

1

I want to create a dynamic vertical line on the right side of my page.
I would prefer to only do this in CSS. I want to be able to set the line at a certain height, but when the text expands the line should of course expand, also the position, vertically, should be able to be set.
So:

|   
| This is some text, |  
|  more text         |  
| and more text      |
|                    |
|

|
|
| This is a longer   |
| text piece.        |
| hopefully I am not |
| too confusing.     |
| And the great      |
| people here        |
| will understand    |
|                    |
|

Before it even comes up, no tables please.

Thank you

+4  A: 

You could put the text into a div and give it a border-right. It will expand with the text.

Edit per your comments:

You could put the text into a div with style="position: relative". You could then put another div into the div with:

position: absolute;
right: 0px;
top: 0px;
height: 300px;
width: 1px;
background-color: green;

this should give you a green line, 300px tall, to the right hand side of your DIV. I don't have the time to test this right now but it should work consistently across browsers as long as the surrounding DIV has a width or height set.

However, this will work only with Pixel heights. Relative heights will fail, I think, because IE will interpret them as relative to the document's height.

Pekka
Don't think I made myself clear.I want to be able to select the height of the right line. So that it can either be shorter than the text or longer.
Botto
What do you mean by select? With the mouse, or programmatically?
Pekka
With my stylesheet. I want to be able to have a line of a certain length that can be placed anywhere up or down the right hand side.
Botto
@Botto see my edit.
Pekka
@Botto, out of curiosity, what's your use-case for this?
David Thomas
@Pekka, it's just to give some arbitrary styling on a site, instead of having a border that goes from the top to the bottom, I wanted a border that could be set to certain dimensions and positions.
Botto
The last question was asked by @ricebowl, I'm mentioning him so he gets notified. @Botto my approach should work for that. You can even try removing the `height` and adding `bottom: 10%` to the example above, it may give you a 90% tall line. The same works for the other directions as well of course, by replacing top, right, left....
Pekka
Thanks, @Pekka =)
David Thomas