Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we use images in CSS background in Google AMP?

Tags:

html

css

amp-html

Can we use images in CSS background in Google AMP?

<pre>

    <div style="background-image: url(assets/img/business1.jpg);></div>


</pre>
like image 504
Rakib Uzzaman Avatar asked Aug 18 '17 16:08

Rakib Uzzaman


People also ask

Can I add image in CSS for background?

The background-image CSS property allows you to then place the image behind any HTML element you wish. This could either be the whole page (by using the body selector in CSS which targets the <body> element in our HTML), or just a standalone specific part of the page such as a section element like in the example below.

How do I combine background and image images in CSS?

Use background-blend-mode and rgba to mix the background image and color. If you adjust the alpha value of the rgba color value (it's at . 85 in the example), you can control the transparency. Also, background-blend-mode has other values you can play with to get some really creative results.

Can we add images in the background of an element in HTML?

A background image can be specified for almost any HTML element.


1 Answers

You can do like this :

CSS on head section

<style amp-custom>
    .img-background { background-image: url(assets/img/business1.jpg); }
</style>

HTML

<pre>
<div class="img-background"></div>
</pre>
like image 162
Bachcha Singh Avatar answered Sep 18 '22 17:09

Bachcha Singh