css - css 宽度属性未正确应用
问题描述
如您所见,在 tr 中有三个名称为 price 和 quantity 类的表格单元格。我给了他们每个人 30% 的宽度。所以它们应该覆盖 90% 的页面,但看起来它们三个甚至没有覆盖页面的一半。虽然当我给它们每个宽度加起来达到 100% 时,它们确实可以工作,但我想要它们覆盖 90% 的页面,正如您在代码片段中看到的那样,这似乎不起作用。
#flexing .welcome .note {
padding-bottom: 0;
}
#flexing .welcome .checkout {
margin:10px;
}
#flexing .welcome .cart a {
color:white;
text-decoration: none;
font-size:15.5px;
}
#flexing .welcome table .name {
width:30%;
border:1px solid red;
color:red;
}
#flexing .welcome table .price {
width:30%;
border:1px solid red;
color:red;
}
#flexing .welcome table .quantity {
width:30%;
border:1px solid red;
color:red;
}
<div id="flexing">
<div class="welcome">
<h3>CHECK OUT</h3>
<div class="cart"><a href="storenav/cart.html">5.00 EUR</a></div>
<div class="note">
<div class="checkout">
<table>
<tbody>
<tr>
<td class="name">Name</td>
<td class="price">Price</td>
<td class="quantity">Quantity<td>
</tr>
<tr>
<td>Faction | Hero rank</td>
<td>5.00 EUR</td>
<td class="button">1
<a href="#">aa</a>
<a href="#">aa</a>
<a href="#">aa</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
解决方案
将 CSS 添加到您的表格并使其宽度为 100%(或 90%)。
#flexing .welcome .note {
padding-bottom: 0;
}
#flexing table {
width: 100%;
}
#flexing .welcome .checkout {
margin:10px;
}
#flexing .welcome .cart a {
color:white;
text-decoration: none;
font-size:15.5px;
}
#flexing .welcome table .name {
width:30%;
border:1px solid red;
color:red;
}
#flexing .welcome table .price {
width:30%;
border:1px solid red;
color:red;
}
#flexing .welcome table .quantity {
width:30%;
border:1px solid red;
color:red;
}
<div id="flexing">
<div class="welcome">
<h3>CHECK OUT</h3>
<div class="cart"><a href="storenav/cart.html">5.00 EUR</a></div>
<div class="note">
<div class="checkout">
<table>
<tbody>
<tr>
<td class="name">Name</td>
<td class="price">Price</td>
<td class="quantity">Quantity<td>
</tr>
<tr>
<td>Faction | Hero rank</td>
<td>5.00 EUR</td>
<td class="button">1
<a href="#">aa</a>
<a href="#">aa</a>
<a href="#">aa</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
推荐阅读
- r - 如何计算使用 nnet 包创建的多项 logit 模型的边际效应?
- c# - aspx c#中的问题在上传之前重命名文件并保存到数据库中的名称
- powershell - Powershell 提升并传递命令
- recursion - 类似 glob() 的 C 函数,但支持“**”递归语法?
- c# - 在 Razor 中有条件地显示标签
- maven - 强制从替代 Nexus 存储库下载同名工件
- c# - 读取 DataTable 并重新排列它,同时有效地更改时间戳列
- javascript - 如果另一个按钮悬停在 bootstrap3 中,如何使按钮消失?
- python - 如何获得房间的摄像机角度和旋转?
- reactjs - react-select 不显示在搜索列表中选择的默认选择值