- This topic has 7 replies, 2 voices, and was last updated 4 years ago by
David.
-
AuthorPosts
-
June 2, 2022 at 1:48 am #2241095
Attila
Hi,
I´d like to have following hover effect on my hero background images.
I could make it with css opacity, but the problem is that also the title text is fading, which should have opacity:1 in both states..page-hero {
background-color: rgba(0,0,0,0.35);
background-image: url(https://hiidenvedenbbq.fi/wp-content/uploads/2022/05/hiidenveden-grilli-ja-bbq-ruokalista_1440x810.jpg);
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
color: #ffffff;
padding-top: 100px;
padding-bottom: 100px;
text-align: center;
opacity: 0.3;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}.page-hero:hover {
opacity: 1;
background-image: url(https://hiidenvedenbbq.fi/wp-content/uploads/2022/05/hiidenveden-grilli-ja-bbq-ruokalista_1440x810.jpg);
}Do you have another solution how to accomplish this task?
Thank you for your help in advance.
June 2, 2022 at 3:40 am #2241194David
StaffCustomer SupportHi there,
you can’t adjust the opacity of just the background-image.
Can i see the site so i can propose the best solution ?June 2, 2022 at 5:52 am #2241302Attila
Thank you for the quick reply.
June 2, 2022 at 6:22 am #2241319David
StaffCustomer SupportTry this CSS:
.page-hero .inside-page-hero:before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-color: #000; z-index: 1; opacity: 0.3; transition: opacity 0.3s ease-in; } .page-hero:hover .inside-page-hero:before { opacity: 0; }June 2, 2022 at 6:36 am #2241341Attila
Yes, I have tried but the h1 title has opacity in normal state as well, it should remain #fff all the time. Only the background image should be effected from the opacity change.
June 2, 2022 at 6:51 am #2241355David
StaffCustomer SupportAdd this CSS to prevent that:
.page-hero .inside-page-hero h1 { position: relative; z-index: 1; }June 2, 2022 at 7:00 am #2241362Attila
David you rock! Now it really works as it should, thank you very much.
Best regards,
AttilaJune 2, 2022 at 7:35 am #2241399David
StaffCustomer SupportAwesome – glad to hear that!
-
AuthorPosts
- You must be logged in to reply to this topic.