Reputation: 3
I just designed my first prototype of a website. I designed it on Figma and chose the desktop layout.
See The Final Prototype
But as I put the background on the CSS code its gets stretched to the screen. See The Screenshot
So how do I adjust the size of the background image so that I get the exact background as seen on the final prototype to add logo and nav menu This is the Background
I'm a complete beginner to CSS.
Upvotes: 0
Views: 139
Reputation: 111
body, html {
background-image: url("https://i.sstatic.net/s7afd.png");
/* Full height */
height: 100%;
width: 100%;
margin: 0;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
<!DOCTYPE html>
<html>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
there is your code
Upvotes: 0
Reputation: 127
It would help if you show the code that you are using, but I am guessing that you are looking for something like:
body {
background-position: center; /* Center the image */
background-repeat: no-repeat; /* Do not repeat the image */
background-size: cover;
}
Upvotes: 0
Reputation: 2480
use below code snippet
body, html {
height: 100%;
margin: 0;
}
.banner {
height: 100%;
background-image: url("https://i.sstatic.net/s7afd.png");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
<html>
<body>
<div class="banner"></div>
</body>
</html>
Upvotes: 1
Reputation: 11
Have you tried CSS background-size: cover;
Refer below link:
https://www.w3schools.com/cssref/pr_background-image.asp
Upvotes: 0