I have an image and I’m attempting to add a gradient to it in my website and put some white text over it. I’m in modern version of chrome for my testing so it should be able to handle it. Here is my html and my css. I’ve tried this a couple of different ways but every time either the gradient shows, or the picture, but never both overlapped. Is it not possible with the colors I’ve selected?
.background {
background: linear-gradient(.25turn, rgb(12, 14, 22), rgb(172, 7, 197)), url("./PulseB2.jpg");
height: 500px;
width: 1663px;
max-width: 100%;
max-height: 100%;
position: relative;
left: 50%;
transform: translateX(-50%);
background-size: cover;
margin-bottom: 16px;
display: flex;
justify-content: center;
align-items: center;
}
.image-text {
color: #fff;
display: inline;
padding: 10px;
font-size: 40px;
text-transform: uppercase;
vertical-align: middle;
}
<div class="background">
<p class="image-text">I exist</p>
</div>
2
Answers
You need to add some transparency to your gradient (e.g. using
rgba
instead ofrgb
), so the background image won’t be completely obscured.Another aproach is to add some blend mode to the background using
background-blend-mode
. So the gradient serves as a blender layer.You might play with
background-blend-mode
property: