我在设置我的标签时遇到了麻烦,因为我几乎所做的每一项改变都会导致一切都无处不在。我想要的是使整个容器和标签响应屏幕尺寸,所以当屏幕变小时,一切都会变小,标签标签也应该居中到中间。我试图给位置vw
而不是百分比,但这不起作用,当屏幕变小时,标签和容器仍然保持相同的大小。
ul.tabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
height: auto;
width: 70vw;
position: relative;
margin-top: 15%;
}
ul.tabs li {
float: left;
margin: 0;
cursor: pointer;
padding: 0px 21px;
height: 31px;
line-height: 31px;
background-color: #666;
color: #ccc;
overflow: hidden;
position: relative;
}
.tab_last {
border-right: 1px solid #333;
}
ul.tabs li:hover {
background-color: #ccc;
color: #333;
}
ul.tabs li.active {
background-color: #fff;
color: #333;
border-bottom: 1px solid #fff;
display: block;
}
.tab_container {
border-top: none;
clear: both;
float: left;
width: 70vw;
background: #fff;
overflow: auto;
position: relative;
left: 15vw;
}
.tab_content {
padding: 20px;
display: none;
}
.tab_drawer_heading {
display: none;
}
@media screen and (max-width: 480px) {
.tab_container {
width: 100%;
left: 0;
position: fixed;
bottom: -100%;
}
.tabs {
display: none;
}
.tab_drawer_heading {
background-color: #ccc;
color: #fff;
border-top: 1px solid #333;
margin: 0;
padding: 5px 20px;
display: block;
cursor: pointer;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.d_active {
background-color: #666;
color: #fff;
}
}

<ul class="tabs">
<li class="active" rel="tab1">Tab 1</li>
<li rel="tab2">Tab 2</li>
<li rel="tab3">Tab 3</li>
</ul>
<div class="tab_container">
<h3 class="d_active tab_drawer_heading" rel="tab1">Tab 1</h3>
<div id="tab1" class="tab_content">
<h2>Tab 1 content</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac metus augue.</p>
</div>
<h3 class="tab_drawer_heading" rel="tab2">Tab 2</h3>
<div id="tab2" class="tab_content">
<h2>Tab 2 content</h2>
<p>Nunc dui velit, scelerisque eu placerat volutpat, dapibus eu nisi. Vivamus eleifend vestibulum odio non vulputate.</p>
</div>
<h3 class="tab_drawer_heading" rel="tab3">Tab 3</h3>
<div id="tab3" class="tab_content">
<h2>Tab 3 content</h2>
<p>Nulla eleifend felis vitae velit tristique imperdiet. Etiam nec imperdiet elit. Pellentesque sem lorem, scelerisque sed facilisis sed, vestibulum sit amet eros.</p>
</div>
</div>
</div>
&#13;