Khalid Khalil
Khalid Khalil

Reputation: 419

Putting Heading within 2 horizontal lines in CSS

I want to put an h3 heading between 2 pairs of horizontal line just like that : enter image description here

Anyone help me with the idea to implement that in html,css


UPDATE

Please how can I do this but with an anchor tag ( actually a button ) I want it to be just like that:

enter image description here

Upvotes: 2

Views: 3718

Answers (2)

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123387

You could style a pseudoelement, like so : http://jsbin.com/epeceb/1/

CSS

h3 {
  width: 500px;
  font: 30px Arial;
  font-weight: normal; 
  text-align: right;
  position: relative;
}

h3 span {
  background: #fff; 
  margin-right: 15%;
  padding: 0 20px;
}

h3:before {
  content: "";
  width: 100%;
  left: 0;
  top: 50%;
  margin-top: -4px;
  position: absolute;
  z-index: -1;
  height: 0;
  border-top: 8px double red;
}

Screenshot

enter image description here

Upvotes: 7

Steven
Steven

Reputation: 867

The best way to achieve this, is to make the two lines in css, have a div absolute that will go over the lines with a white background. Should work perfectly.

Upvotes: 3

Related Questions