Currently, I have a website where images are clashing with the text over it.
I’m new to HTML/CSS and have looked around online but haven’t ha dmuch luck. Basically, when a user isn’t hovered over a box, an image should show a bit faded with text on top. When the use is hovered over the box, the image should be?
.showcase {
overflow: hidden;
margin-left: -1px;
@include flexbox;
@include justify-content(center);
}
.custom_showcase {
position: relative;
padding: 1px 0 0 1px;
@include flexbox;
img {
width: 100%;
max-width: none;
}
.inside {
display: inline-block;
max-width: 100%;
width: 100%;
background: $color_1;
@include flexbox;
@include align-items(center);
}
.textblock {
padding: 20px;
}
img + .textblock {
position: absolute;
left: 50%;
top: 50%;
width: 100%;
max-width: 455px;
padding: 0 20px;
color: $color_3;
@include transform(translate(-50%,-50%));
}
h2 {
color: $color_3;
margin: 16px 0 5px;
text-transform: uppercase;
}
p {
margin: 0;
color: $color_3;
}
h2,
p {
span {
display: inline-block;
padding-left: 0;
@include transition(.4s);
}
}
.text {
width: 100%;
}
.btn_wrapper {
position: absolute;
right: 40px;
top: 50%;
@include transform(translate(0%,-50%));
.btn {
padding: 0 10px;
min-width: 140px;
text-align: center;
opacity: 0;
@include transition(.4s);
@include transform(translate(100%,0%));
/* border-color: $color_3; */
}
}
a:not(:hover) {
//h2,
//p {
// span {
// padding-right: 0 !important;
// }
//}
opacity: .5;
transition: opacity 0.5s ease;
}
a:hover {
h2,
p {
span {
padding-left: 0 !important;
}
}
.btn_wrapper {
.btn {
opacity: 1;
@include transform(translate(0%,0%));
}
}
}
5
Answers
I’m not sure of those classes, but considering the description of your problem, here’s what you can probably do:-
Hope that helps 🙂
Please correct me if I misunderstood your point.
One possible solution is to set the image as the background of a div, then nest another div inside of it that matches the width and height of the image div.
Add a background color with opacity to that inside div, and your text, then set it to invisible when hovered over.
This is the best I could do with the info you have provided.
Hopefully it is helpful to you.
Try this:
You can nest the text in an element that wraps the image, then on
:hover
alter the opacity of the image and the text to hide/show.