简体   繁体   中英

AMP image with text inside

Who can I show an image with text inside using AMP?

Something that looks like this, but on AMP

html:

<div class="backgroud-image">
  <h2>Title</h2>
</div>

css:

.backgroud-image {
  background-image: url("image.jpg");
  background-position: center;
  background-size: cover;
}

As @Michael Coker said, you can use background images with AMP (as referred to your example). You may check on this forum .

You can add styling in the head element with the style amp-custom element. One possible problem is that in AMP the images are supposed to have their size declared in the code, but with a background image you declare with styling directives the size of the element containing the image, not of the image itself.

You can check on this blog for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM