Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a vertical, dotted line down center of page using CSS?

Tags:

css

I'd like to draw a dotted line, vertically down the center of my page, "hiding" under any content boxes along the way... Is there a technique to do this in CSS, or will I have to use a repeating image?

like image 633
Chaddeus Avatar asked Sep 15 '12 02:09

Chaddeus


People also ask

How do you make a vertical dotted line in CSS?

You can use border-left or border-right properties to make a vertical line. In order to determine the height of an element, the height property is used. In order to determine the position of a vertical line, using the position property.

How do you put a line in the middle of the page in CSS?

How Do You Make A Line In Css? Adding hr> in your markup will allow you to add a horizontal line to the page. A browser draws a line along one of the top-side of a container, ranging from a child-sized element to the entire body.

How do I move a vertical line in CSS?

Just simply add border-left: 5px solid rgb(128, 0, 17); to the div . services . Wrap anything you in a <div></div> and add a border to that wrapping <div></div> . This is the workflow you should follow.


3 Answers

This gives you dots: http://jsfiddle.net/NBMRp/

body:after {
    content:"";
    position: absolute;
    z-index: -1;
    top: 0;
    bottom: 0;
    left: 50%;
    border-left: 2px dotted #444; /*change these values to suit your liking*/
}

They're just not that pretty.

like image 78
João Paulo Macedo Avatar answered Sep 21 '22 17:09

João Paulo Macedo


For the dotted line i would use:

.vertical_dotted_line
{
    border-left: 1px dotted black;
    height: 100px;
} 

<div class="vertical_dotted_line"></div>

And to make it under other elements you need to play with the z-index of your dotted line div and the other divs (they should have a higher value of z-index)

like image 43
Majid Laissi Avatar answered Sep 18 '22 17:09

Majid Laissi


If you wants the lines should extend out of div's height -

.dashed-lines:after {
content:"";
position: absolute;
z-index: -1;
top: -50px;
bottom: -50px;
left: 50%;
border-left: 2px dotted #ce9b3a;

}

like image 45
Wasim Khan Avatar answered Sep 18 '22 17:09

Wasim Khan