Stretch divider to one side but keep title centered

First, I would use flexbox instead of table layout then adjust the margin/padding:

Kept only the relevant code for the demo

#container {
  width: 400px;
  background: #EFEFEF;
  padding: 24px;
}

/* Normal use case */
.divider {
  display: flex;
  margin: 16px 0;
  align-items:center;
}

.divider::before, .divider::after {
  flex:1;
  height: 1px; 
  background:#AAA;
  content: '';
}
.divider::before {
  margin-right:24px;
}
.divider::after {
  margin-left:24px;
}

.divider.stretched-left:before {
  margin-left:-24px;   
  padding-left: 24px;
}

.divider.stretched-right:after {
  margin-right:-24px;   
  padding-right: 24px;
}
<div id="container">
  <div class="divider">
    <span class="divider-text">Title</span>
  </div>
  <div class="divider stretched-left">
    <span class="divider-text">another Title</span>
  </div>
  <div class="divider stretched-right">
    <span class="divider-text">Title</span>
  </div>
  <div class="divider stretched-right">
    <span class="divider-text">another Title</span>
  </div>
  <div class="divider stretched-left stretched-right">
    <span class="divider-text">another Title</span>
  </div>
</div>

With your original code you can try this:

#container {
  height: 100px;
  width: 400px;
  background: #EFEFEF;
  padding: 24px;
}

/* Normal use case */

.divider {
  position: relative;
  line-height: 23px;
  height: 1px;
  display: table;
  margin: 16px 0;
  color: rgba(0, 0, 0, 0.85);
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  text-align: center;
  background: transparent;
}

.divider::before, .divider::after {
  position: relative;
  top: 50%;
  display: table-cell;
  width: 50%;
  border-top: 1px solid #AAA;
  transform: translateY(50%);
  content: '';
}


.divider-text {
  display: inline-block;
  padding: 0 24px;
}

/* Trying to stretch the left line to further to the left without puting the title off-center */

.divider.stretched-left {
  left: -24px;
  width: calc(100% + 48px); /* Updated */
}
/* Added */
.divider.stretched-left:after {
  border-image:linear-gradient(to left,transparent 24px, #aaa 24px) 1;
}
<div id="container">
  <div class="divider">
    <span class="divider-text">Title</span>
  </div>
  <div class="divider stretched-left">
    <span class="divider-text">Title</span>
  </div>
</div>

Tags:

Html

Css