Vimpil Vimpil - 3 months ago 7
CSS Question

Can't customize bootstraps tab's border-top - have blank space with 100% width in absolute position

Can't customize bootstrap's tabs border-top - have blank space with 100% width in absolute position after the line.
http://jsfiddle.net/Vimpil/0mmv73oh/

li.active:after {
position: absolute;
width: 97%;
padding: 1px;
top: -1px;
content: '';
background: #000;
height: 4px;
}

Answer

This extra space is because of margin-right applied to links in Bootstrap's default styles.

You can fix this by overriding that styles or remove width and use left: 0 and right: 2px to stretch line.

jQuery(function () {
    jQuery('#myTab a:last').tab('show')
})
@import url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css');

li.active:after {
  position: absolute;
  padding: 1px;
  top: -1px;
  content: '';
  background: #000;
  height: 4px;
  right: 2px;
  left: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<ul class="nav nav-tabs" id="myTab">
  <li class="active"><a data-target="#home" data-toggle="tab">Home</a></li>
  <li><a data-target="#profile" data-toggle="tab">Profile</a></li>
  <li><a data-target="#messages" data-toggle="tab">Messages</a></li>
  <li><a data-target="#settings" data-toggle="tab">Settings</a></li>
</ul>

<div class="tab-content">
  <div class="tab-pane active" id="home">Home</div>
  <div class="tab-pane" id="profile">Profile</div>
  <div class="tab-pane" id="messages">Message</div>
  <div class="tab-pane" id="settings">Settings</div>
</div>