我似乎无法使用容器查询。我尝试使用容器查询更改HTML表格的样式,但容器中的样式没有被应用:
table.df-price-table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
container-type: inline-size;
container-name: dftable;
}
table.df-price-table caption {
font-size: 1.5em;
margin: .5em 0 .75em;
}
table.df-price-table tr {
background-color: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}
table.df-price-table th,
table.df-price-table td {
padding: .625em;
text-align: center;
}
table.df-price-table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
@container dftable (max-width: 600px) {
caption {
font-size: 1.3em;
}
thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}
td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}
td::before {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
td:last-child {
border-bottom: 0;
}
}
<table class="df-price-table">
<caption>Statement Summary</caption>
<thead>
<tr>
<th scope="col">Account</th>
<th scope="col">Due Date</th>
<th scope="col">Amount</th>
<th scope="col">Period</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Due Date">04/01/2016</td>
<td data-label="Amount">$1,190</td>
<td data-label="Period">03/01/2016 - 03/31/2016</td>
</tr>
<tr>
<td scope="row" data-label="Account">Visa - 6076</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Amount">$2,443</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td scope="row" data-label="Account">Corporate AMEX</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Amount">$1,181</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td scope="row" data-label="Acount">Visa - 3412</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Amount">$842</td>
<td data-label="Period">01/01/2016 - 01/31/2016</td>
</tr>
</tbody>
</table>
2条答案
按热度按时间7gyucuyw1#
通过w3c可知,如果满足以下任一条件,则为元素
inline-size
提供包含将无效:display: contents
或display: none
的情况)flvlnr442#
您必须添加一个 Package 器,因为根据CSS规范,容器查询不适用于表: