html - AMP 轮播中的字幕不起作用

标签 html css amp-html blogspot

我添加标题<div class="caption">在我的 amp-carousel 旁边 amp-img 。当设备变成移动设备时,标题看起来是半隐藏的。

enter image description here

这是我的代码:

<amp-carousel autoplay='' delay='6000' height='340' layout='responsive' type='slides' width='824'>
    <div>
        <div>
            <amp-img alt='' height='240' layout='responsive' src='image-link-here' width='824'/>
            <div class='caption'>
                <p class='text-inside'><em>Pertama</em>, kode yang ditulis dalam membangun website anda harus tervalidasi menggunakan versi HTML, PHP atau CSS kompatibel atau terupdate sehingga mesin pencari dapat melakukan <em>crawling website</em> anda.</p>
            </div>
        </div>

    </div>
    <div>
        <div>
            <amp-img alt='' height='240' layout='responsive' src='image-link-here' width='824'/>
            <div class='caption'>
                <p class='text-inside'><em>Kedua</em>, loading speed website harus cepat, aman dan <em>mobile friendly</em> (responsive sesuai device yang digunakan semua user).</p>
            </div>
        </div>
    </div>
    <div>
        <div>
            <amp-img alt='' height='240' layout='responsive' src='image-link-here' width='824'/>
            <div class='caption'>
                <p class='text-inside'><em>Ketiga</em>, konten website anda harus unik, berguna/bermanfaat bagi visitor dan teroptimasi (on page SEO) atau SEOptin sebut sebagai <b>website UMT</b> (<em>Unik, Manfaat, Teroptimasi</em>).</p>
            </div>
        </div>
    </div>
    <div>
        <div>
            <amp-img alt='' height='240' layout='responsive' src='image-link-here' width='824'/>
            <div class='caption'>
                <p class='text-inside'><em>Keempat</em>, tulisan di konten website anda sudah diakui (UMT) oleh website yang relevan (sama niche) atau website terbaik lainnya seperti wikipedia, website edu dsb.</p>
            </div>
        </div>
    </div>
</amp-carousel>

在 CSS 中:

amp-carousel{
margin-bottom:25px;
}
p.text-inside{
background:#fff;
padding:15px;
border-radius:0px 0px 3px 3px;
border-left:1px solid #DEDEDE;
border-right:1px solid #DEDEDE;
border-bottom:1px solid #DEDEDE;
font-family:&quot;Tahoma&quot;,sans-serif;
font-size:14px;
letter-spacing:1px;
color:#777;
}
p.text-inside em,p.text-inside strong,p.text-inside b{
font-family:&quot;Tahoma&quot;,sans-serif;
font-size:14px;
letter-spacing:1px;
color:#444;
}

Live preview

最佳答案

在本例中使用amp-fit-text

amp-fit-text : Expands or shrinks its font size to fit the content within the space given to it.

代码

<!doctype html>
<html ⚡>
 <head>
   <meta charset="utf-8">
   <link rel="canonical" href="carousel.html">
   <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
   <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
   <script async src="https://cdn.ampproject.org/v0.js"></script>
   <script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>
   <script async custom-element="amp-fit-text" src="https://cdn.ampproject.org/v0/amp-fit-text-0.1.js"></script>
   <style amp-custom>
    amp-carousel{
margin-bottom:25px;
}
p.text-inside{
background:#fff;
padding:15px;
border-radius:0px 0px 3px 3px;
border-left:1px solid #DEDEDE;
border-right:1px solid #DEDEDE;
border-bottom:1px solid #DEDEDE;
font-family:&quot;Tahoma&quot;,sans-serif;
font-size:14px;
letter-spacing:1px;
color:#777;
}
p.text-inside em,p.text-inside strong,p.text-inside b{
font-family:&quot;Tahoma&quot;,sans-serif;
font-size:14px;
letter-spacing:1px;
color:#444;
}
  </style>
 </head>
 <body>
 <amp-carousel controls autoplay='' delay='6000' height='440' layout='responsive' type='slides' width='824'>
    <div>
        <div>
            <amp-img alt='' height='240' layout='responsive' src='https://dummyimage.com/840x240/000/f00' width='824'/>
            <amp-fit-text layout="responsive"
      width="824"
      height="200">
            <div class='caption'>
                <p class='text-inside'><em>Pertama</em>, kode yang ditulis dalam membangun website anda harus tervalidasi menggunakan versi HTML, PHP atau CSS kompatibel atau terupdate sehingga mesin pencari dapat melakukan <em>crawling website</em> anda.</p>
            </div>
            </amp-fit-text>
        </div>

    </div>
    <div>
        <div>
            <amp-img alt='' height='240' layout='responsive' src='https://dummyimage.com/840x240/000/0f0' width='824'/>
            <amp-fit-text layout="responsive"
      width="824"
      height="200">
            <div class='caption'>
                <p class='text-inside'><em>Kedua</em>, loading speed website harus cepat, aman dan <em>mobile friendly</em> (responsive sesuai device yang digunakan semua user).</p>
            </div>
            </amp-fit-text>
        </div>
    </div>
    <div>
        <div>
            <amp-img alt='' height='240' layout='responsive' src='https://dummyimage.com/840x240/000/00f' width='824'/>
            <amp-fit-text layout="responsive"
      width="824"
      height="200">
            <div class='caption'>
                <p class='text-inside'><em>Ketiga</em>, konten website anda harus unik, berguna/bermanfaat bagi visitor dan teroptimasi (on page SEO) atau SEOptin sebut sebagai <b>website UMT</b> (<em>Unik, Manfaat, Teroptimasi</em>).</p>
            </div>
            </amp-fit-text>
        </div>
    </div>
    <div>
        <div>
            <amp-img alt='' height='240' layout='responsive' src='https://dummyimage.com/840x240/000/fff' width='824'/>
            <amp-fit-text layout="responsive"
      width="824"
      height="200">
            <div class='caption'>
                <p class='text-inside'><em>Keempat</em>, tulisan di konten website anda sudah diakui (UMT) oleh website yang relevan (sama niche) atau website terbaik lainnya seperti wikipedia, website edu dsb.</p>
            </div>
            </amp-fit-text>
        </div>
    </div>
</amp-carousel>
 </body>
</html>

Example Here

更多引用请访问:

  1. amp-fit-text

  2. Image Galleries with amp-carousel

关于html - AMP 轮播中的字幕不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50938853/

相关文章:

html - 背景图片只覆盖文字

javascript - 如何在 html 标签 href 中使用 es6 模板

html - 在移动设备上滚动时如何防止缩放表单字段?

overflow - AMP 轮播文本将被截断

html - 如何在我的 WordPress 网站的 amp 版本上隐藏图像?

javascript - 迭代表格单元格

html - 我可以在列表项中使用 div 吗?

css - rails 4 : how to apply custom CSS to Rails form file field

css - 使用 css 测量 div(如条形图)

html - Amp-sidebar : Does it absolutely have to be the child of the body? 为什么?