dhaneku.b dhaneku.b - 1 month ago 7
CSS Question

Background image not moving vertically using CSS


<html>
<head>
<title>MacOS Wallpaper</title>
<style type="text/css">
h1{
text-align:center;
color:black;
}
body{
background-image:url(macOS_wallpaper.jpg);
background-repeat:no-repeat;
background-position: 0% 50%;
}
</style>
</head>
</html>


I have an image that I want to use. It is positioned how I want it horizontally, but it is not moving vertically at all (I want to move the image down). I have tried using px and % to move the image, but it won't budge. How can I adjust the y-component in order for me to move my image down?

Answer

Use:

.class { 
    background-image: url('something.jpg');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: 0% 50%; 
}

Comments