-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I overlay an image over the background one ? #167
Comments
You can use a element for this purpose.
and following CSS .container { background-image: url('background-image.jpg'); position: relative; } .overlay { |
Hi, I've created a Word doc with a few different examples of an overlay with CSS. |
You can overlay an image over a background using CSS by using the HTML: <div class="container">
<img src="overlay-image.jpg" alt="Overlay Image">
<p>Content goes here</p>
</div> CSS: .container {
position: relative;
}
.container::before {
content: "";
background: url('background-image.jpg');
background-size: cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.5; /* Adjust the opacity as needed */
z-index: -1; /* Place the overlay behind the content */
} In this example, the Make sure to adjust the paths to your actual image files, and customize the styles to match your design. |
The HTML will look like this: <header>
<section class='hero-header'>
<h1>Software development</h1>
<h2>Javascript developer</h2>
<button>Hire Me</button>
</section>
</header>
The css will look like this header {
height: 100vh;
width: 100%;
text-align: center;
padding-top: 100px;
color: white;
overflow: hidden;
background: #c04848; /* fallback for old browsers */
background: linear-gradient(rgb(72, 0, 72, 0.8), rgb(192, 72, 72, 0.8)),
url("/luke-peters-B6JINerWMz0-unsplash.jpg");
background-size: cover;
background-repeat: no-repeat;
}
header h1,
h2 {
margin: 2rem;
font-size: 3rem;
}
header button {
padding: 1.5rem;
border-radius: 0.2rem;
background-color: white;
border: none;
font-size: 1.5rem;
color: rgb(72, 0, 72, 0.8);
font-weight: bold;
} The result will look like this |
No description provided.
The text was updated successfully, but these errors were encountered: