Home >Web Front-end >CSS Tutorial >You can set a background image for the img element_Experience exchange

You can set a background image for the img element_Experience exchange

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 12:04:002262browse

The implementation method is very simple: set the img element as a block element (display:block;) and assign a padding value.


[Ctrl A Select all Note:If you need to introduce external Js, you need to refresh to execute]

Copy code The code is as follows:

img {
display:block; b
ackground:url('parallax.gif') no-repeat bottom left; padding:93px 100px 75px 100px;}

According to the above principle, by analogy, through a similar method, we can also set bilateral sides for the img element:
Copy code The code is as follows:

img {
display:block;
padding:1px;
background :red;
border:1px solid black;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn