Search code examples
htmlcsstwitter-bootstrapmargin

DIV center is not working


I already tried fixing it with margin, table styles, and the bootstrap css but it isnt working

I need the A tags to center in the label-row-overview div and be responsive

HTML

<div class="label-row-overview">
  <a href="{URL}" target="_blank"><div class="label-img-overview"><span>EXTRA FOTO'S</span></div></a>
  <a href="{URL}" target="_blank"><div class="label-img-overview leftxspace"><span>MAATTABELLEN</span></div></a>
  <a href="{URL}" target="_blank"><div class="label-img-overview leftxspace"><span>PRODUCT SPECS</span></div></a>
  <a href="{URL}" target="_blank"><div class="label-img-overview leftxspace"><span>CERTIFICATEN</span></div></a>
</div>

Style.css

.label-row-overview a {
  color: #FFF;
  background-color: #12a19b;
  padding: 10px;
  display: inline-block;
  margin: 5px;
  overflow: hidden;
}

Solution

  • Applying display: block and text-align: center to the div does the trick:

    .label-row-overview a {
      color: #FFF;
      background-color: #12a19b;
      padding: 10px;
      display: inline-block;
      margin: 5px;
      overflow: hidden;
    }
    
    .label-row-overview {
      display: block;
      text-align: center;
    }
    <div class="label-row-overview">
      <a href="{URL}" target="_blank">
        <div class="label-img-overview"><span>EXTRA FOTO'S</span></div>
      </a>
      <a href="{URL}" target="_blank">
        <div class="label-img-overview leftxspace"><span>MAATTABELLEN</span></div>
      </a>
      <a href="{URL}" target="_blank">
        <div class="label-img-overview leftxspace"><span>PRODUCT SPECS</span></div>
      </a>
      <a href="{URL}" target="_blank">
        <div class="label-img-overview leftxspace"><span>CERTIFICATEN</span></div>
      </a>
    </div>