CSS3 Background property is used to add a background on web pages.
<style>
body {
background: black url("image.svg") no-repeat fixed center;
}
</style>
<style>
body {
background: black url("image.svg") no-repeat fixed center;
}
</style>
<!--body-->
<body>
</body>
Here we will use some background Properties for adjusting image file on background.
<style>
div{background-image:url('image.svg')}
</style>
<!DOCTYPE html>
<html>
<head>
<!--internal style sheet-->
<style>
div{color:rgb(255,255,255);
background-image:url('image.svg');
background-color:black;
height:400px;
border-radius:5px}
</style>
</head>
<!--Body-->
<body>
<div>
</div>
</body>
</html>
Apply background-repeat property to allow or disallow the repeating of an image
<style>
div{background-image:url('image.svg');
background-repeat:no-repeat;}
</style>
<style>body{background-repeat:repeat-x;}</style>
<style>body{background-repeat:repeat-y;}</style>
<!DOCTYPE html>
<html>
<head>
<!--style sheet-->
<style>
div{
color:rgb(255,255,255);
background-image:url('image.svg');
background-color:black;
background-repeat:no-repeat;
background-size:200px;
height:380px;
border-radius:5px
}
</style>
</head>
<!--Body-->
<body>
<div>
</div>
</body>
</html>
Try to set the position of background images
<style>
div{
background-image:url('image.svg');
background-position:top right;
}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
div{color:rgb(255,255,255);
background-image:url('image.svg');
background-position:top right;
background-color:black;
background-repeat:no-repeat;
background-size:100px;
height:380px;
border-radius:5px}
</style>
</head>
<!--Body-->
<body>
<div>
</div>
</body>
</html>
Create background with multiple colors
<style>
body {
background: linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);
}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
/*linear gradient*/
.class1{background: linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%);height:100px}
/*radial gradient*/
.class2{background: radial-gradient(white, gray, black);height:100px}
/*multiple linear gradients*/
.class3{background: linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);
height:300px;}
</style>
</head>
<body>
<div class="class1"></div><br>
<div class="class2"></div><br>
<div class="class3"></div>
</body>
</html>
Adjust background image on your Web Page
<style>
.class1{background-size:200px;}
</style>
<style>
.class2{background-size:200px 300px;}
</style>
<style>
.class3{background-size:auto;}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
div{color:rgb(255,255,255);
background-image:url('image.svg');
background-color:black;
background-repeat:no-repeat;
height:380px;
border-radius:5px}
.class1{background-size:200px;}
.class2{background-size:auto;}
</style>
</head>
<!--Body-->
<body>
<div class="class1"></div>
<div class="class2"></div>
</body>
</html>
background shorthand technique
<style>
body{background:bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
div{
color:rgb(255,255,255);
background:black
url('image.svg')
center
no-repeat
fixed;
height:400px;
border-radius:5px
}
</style>
</head>
<!--Body-->
<body>
<div></div>
</body>
</html>
Share TDB SCHOOL
Share this E-Learning Website on social media platforms with your friends and followers