我想放置一个以常规尺寸居中的媒体尺寸,当我将其最大宽度更改为 480 时,标题位于左侧。
但它粘在左边。如何更改代码,使标题在媒体大小时位于中间?
caption {
font-family: "Rock Salt", cursive;
padding: 20px;
font-style: italic;
caption-side: Top;
color: #666;
text-align: center;
letter-spacing: 1px;
}
@media only screen and (max-width: 480px) {
caption {
caption-side: Top;
text-align: center;
letter-spacing: 1px;
}
<section id="right">
<table>
<caption>Books everyone will enjoy!</caption>
<thead>
<th colspan="4">Recommended childrens books!</th>
<th colspan="2" style="display: none">Recommended childrens books!</th>
<tr>
<th colspan="1">Front of the book</th>
<th colspan="1">Title of the book</th>
<th colspan="1">Authors</th>
<th colspan="1">Book Summary</th>
</tr>
</thead>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
您需要将块元素居中:
@media only screen and (max-width: 480px) { caption { caption-side: Top; text-align: center; letter-spacing: 1px; margin:0 auto; }