我的CSS需要修改以顯示5個項目,但是如果項目小於5,它應該覆蓋寬度。根據項目數量顯示不同寬度的列表項目
/* new css added */
.product-section {
width: 100%;
float: left;
padding: 108px 80px 0;
}
.product-section h6 {
width: 100%;
float: left;
font-family: 'Open Sans';
font-weight: 600;
font-size: 17px;
line-height: 19px;
color: #585253;
text-transform: uppercase;
border-bottom: 1px solid #d0d0d0;
padding: 0 0 6px;
}
.veiwed-related {
width: 100%;
float: left;
padding: 66px 0 0;
}
.recently-veiwed-related ul {
width: 100%;
float: left;
list-style: none;
margin: 0 0 0 -33px;
padding: 0;
position: relative;
}
.veiwed-related ul li {
width: 16.5%;
float: left;
list-style: none;
margin: 0 0 20px 33px;
padding: 0;
}
.veiwed {
width: 100%;
float: left;
}
/* new css added */
<div class="product-section">
<h6>you may also like</h6>
<div class="veiwed-related">
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
</ul>
</div>
</div>
我怎樣才能讓這個如果有5個<li>
S,它涉及的是下寬,但如果我只有1或3,它涵蓋了寬?
你需要一個寬度JavaScript,這將數清單,然後除以寬度前。 100/5列表然後20的寬度將是20%; – bdalina