Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal line in the middle of the page

Tags:

html

css

I want to have a horizontal line in the middle of the page. Some thing like

<div class="line">
  <hr>
</div>

.line {
  top: 50%;
}

But this doesn't work. I don't want to write the line by myself like

<p> _______________________________________</p>

Is there some way to center the hr?

like image 568
Mocktheduck Avatar asked Sep 03 '25 01:09

Mocktheduck


2 Answers

You need the line to be taken out of the normal flow of the document before you can set the top property. Try this

.line {
   position:absolute;
   width:100%;
   top: 50%;
}
<hr class="line">

JS Fiddle: https://jsfiddle.net/q9o5q70z/

like image 171
Scott Marcus Avatar answered Sep 09 '25 16:09

Scott Marcus


Use the <hr> tag, it's what it's for.

like image 41
Ian Devlin Avatar answered Sep 09 '25 17:09

Ian Devlin