如何使标题在媒体尺寸中居中?
P粉316110779
P粉316110779 2024-02-26 10:05:23
0
1
411

我想放置一个以常规尺寸居中的媒体尺寸,当我将其最大宽度更改为 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>

P粉316110779
P粉316110779

全部回复(1)
P粉239089443

您需要将块元素居中:

@media only screen and (max-width: 480px) {
   caption {
      caption-side: Top;
      text-align: center;
      letter-spacing: 1px;
      margin:0 auto;
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板