How to Add Background Image
Asked by KeerthiVasan about 5 months ago
How can I add zomato background image...I Tried in the usual way it didn't worked.....background: url('../images/BackGround.png');
3 Answers
Thank You so much Pranav!! Also I have an other doubt...How can I add that Location image before Chennai...If you could share the code it will help me a lot.
Can you share your playground URL Keerthi?
Usually it should be:
.selector {
background: url('https://full-image-url.com/image.jpg')
}
https://codedamn.com/project/zomato-landing-page-clone/guided/step0/GIbVIndYUe6xNJfdoWLGc How can I add the background.png image that is in assets/images/background.png
Hey Keerthi, make sure that you've linked your css file with your index.html
file.
background-image: url(assets/images/BackGround.png);
The above line should be able to set the background image of the HTML element.
I'm share the code snippet that I've built to demonstrate this to you here along with a preview of it.
HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Zomato Clone</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section id="hero">
<h1 id="title">Zomato</h1>
<h3 id="tagline">Discover the best foods and Drinks in Chennai</h3>
</section>
</body>
</html>
CSS
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
height: 100vh;
}
#hero {
background-image: url(assets/images/BackGround.png);
padding: 50px;
background-size: 100%;
background-repeat: no-repeat;
text-align: center;
}
#title, #tagline {
color: white;
font-family: 'Poppins';
}
#title {
font-style: italic;
font-size: xx-large;
font-weight: 900;
}
#tagline {
font-weight: 400;
}
Preview
Thank You so much Pranav!! Also I have an other doubt...How can I add that Location image before Chennai...If you could share the code it will help me a lot.