+ 2
How to make background image in HTML
I'm not satisfied with html plain color background that use "bgcolor". How I could fill the background with width size picture?
16 Antworten
+ 7
you can add
background-repeat: no-repeat;
background-size: 300px 100px;
to the style after the semicolon ";"
Feel free to adjust the background-size, the first number is for width and the second is for height.
don't forget to add background-repeat : no-repeat to make sure it's not become like desktop wallpaper
+ 7
You can do that in CSS:
background: url(.......)
no-repeat center center fixed;
background size: cover;
That's it. It will work 100%.
you can remove *fixed* from there if you want your image to move while scrolling down
+ 6
Thank you sir 👍
+ 5
By changing the padding value
Image size will change also
+ 4
actually this is how it works :
the background size is depend on the element size in default, so when you expand the element by adding padding or set width or height it also affect the background. But you also can make the background image have fix size by adjust it using "background-size"
+ 4
background img src = ""
+ 3
{Background-image: url(....) ;}
+ 3
could you guys tell me how to set the size of the picture?
+ 3
Use:
Padding
To set the size
+ 3
Ex :
{
Padding:40 px
Background-image:url(...)
}
+ 2
you can use background-image.
For example :
<div style="background-image: url(images/cute-kitten.jpg);"></div>
I hope this can answer your question
+ 2
<div style="background-image: url(images/example.jpg);"></div>
+ 2
you can add
background-repeat: no-repeat;
background-size: 300px 100px;
to the style after the semicolon ";"
+ 2
.test {
background-image: url
(1.jpg),
url(2.jpg);
background-repeat: no-repeat;
background-position: left top
,
right top;
}
+ 1
you can use this
background-image: url("image path")
the url could be a path or a link
i hope that 'll help
0
How do you align the background in CSS?