Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap text element with line behind text

I'm looking to create text headers that have a line behind the text to fill the entire width of the container, like this example:

Example:

enter image description here

The actual text itself would have a white box around it as to block out the line.

.divider-text {
    height: 1px;
    width: 100%;
    display: inline;
    overflow: hidden;
    background-color: #e5e5e5;
}

This code here fills the entire text container with the #e5e5e5 color.

like image 422
Inmana00 Avatar asked Dec 10 '22 20:12

Inmana00


1 Answers

Consider the following markup and CSS

.heading-1{
  position:relative;
  text-align: center
}
.heading-1:before {
  content: "";
  display: block;
  border-top: solid 2px #bebebe;
  width: 100%;
  height: 2px;
  position: absolute;
  top: 50%;
  z-index: 0;
}
.heading-1 span {
  background: #fff;
  padding: 0 10px;
  position: relative;
  z-index: 1;
}
<h1 class="heading-1"><span>Centered Text</span></h1>
like image 165
ReLeaf Avatar answered Dec 29 '22 00:12

ReLeaf