Div没有正确扩展

问题描述 投票:2回答:1

每当我将div宽度设置为100%,并且我向其添加新元素时,它会在屏幕边框上展开。当我将div设置为像素值时,它工作正常,但在两种不同的屏幕分辨率下看起来不正常。所以我想要的是拥有一个适合屏幕边缘并正确扩展的div。

的jsfiddle:https://jsfiddle.net/272p06ng/4/

垃圾邮件添加选项卡几次以查看问题。然后在CSS中查找.l_tabs并阅读评论。我认为问题出在l_tabs的父类中。

Div with%value的行为如下:

enter image description here

带像素值的Div显示我想要的行为:

enter image description here

标签结构:

 <div class="l_tabs">
  <div>
    <ul id="myTab1" class="nav nav-tabs bordered">
     <li class="tab-add"></li>
     <li class="contentTab active "></li>
     <li.....></li>
    </ul>
  </div>
</div>

CSS:

.l_tabs {
    background: #474544 none repeat scroll 0 0;
    display: block;
    height: 57px;
    overflow: hidden;
    width: 100%; /* 1st picture */
    width: 1370px; /* second picture */
}
.l_tabs > div {
    background-color: #474544;
    height: 57px;
    padding-top: 4px;
    width: 100%;
}
.l_tabs > div > ul {
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
}

还有一些父包装,宽度也是100%。

编辑:添加position:absolutel.tabs解决了这个问题。

javascript html css tabs
1个回答
1
投票
.l_tabs {
  height: 57px;
  display: block;
  width: 100%;
  background: #474544 none repeat scroll 0 0;
  overflow: hidden;
}
© www.soinside.com 2019 - 2024. All rights reserved.