- This topic has 7 replies, 4 voices, and was last updated 5 years, 4 months ago by
Elvin.
-
AuthorPosts
-
December 8, 2020 at 4:42 am #1571453
Heinrich
hi team,
i am struggling with a task which looks very simple at the first moment.gb container with a background image and a headline in it. the headline has a color background. on hover (the whole container) following should change:
– background image
– headline-text
– background color headlinehave tried countless plugins (flip, overlay..) and played around with display and visibility….
really appreciate useful thoughts on this.December 8, 2020 at 5:16 am #1571485David
StaffCustomer SupportHi there,
can you share a link to your site where i can see this layout?
December 8, 2020 at 5:25 am #1571493Heinrich
of course
December 8, 2020 at 6:23 am #1571546David
StaffCustomer SupportDo you have this layout setup on a GP site ? Need to see how you have created the containers etc.
December 8, 2020 at 7:27 am #1571753Heinrich
hi david,
yes of course.December 8, 2020 at 7:45 pm #1572247Tom
Lead DeveloperLead DeveloperYou will need to do something like this:
.gb-container.your-container-class:hover { background-image: url(URL TO YOUR HOVER BACKGROUND); } .gb-container.your-container-class:hover .gb-headline.your-headline-class { background: red; color: white; }Let me know if you need more info 🙂
December 9, 2020 at 11:51 am #1573369Heinrich
hi tom, one thing is missing, the text has to change too. not only the background color.
any idea?December 9, 2020 at 4:12 pm #1573648Elvin
StaffCustomer SupportHi,
To clarify: You’re trying to change different elements and their stylings when you hover the container?
If so, you’ll need a script to add event listeners to the container if you want it to be the hover trigger point to change all of its contents.
Example:
function add_hover_listeners(){ var switchingElem = document.querySelectorAll(".hover-container"); for( i=0; i<switchingElem.length; i++ ){ switchingElem[i].addEventListener("mouseover",function(){ //do your style changes here. // example: this.querySelector(".headline-text").style.display = "none"; // this.querySelector(".headline-text-onhover").style.display = "block"; }); switchingElem[i].addEventListener("mouseout",function(){ //do your style changes here. // example: this.querySelector(".headline-text").style.display = "block"; // this.querySelector(".headline-text-onhover").style.display = "none"; }); } } window.addEventListener("DOMContentLoaded",function(){ add_hover_listeners(); });And this is just a simple example of displaying/hiding a specific element. You can add in more as long as you know the right CSS selectors.
-
AuthorPosts
- You must be logged in to reply to this topic.