Changing colors when hovering over different elements

I am struggling to create a hover color change effect that applies to all elements (icon, text, and button) from top to bottom. Currently, the hover effect only changes the color of either the text and icon or the button individually.

Below is the code snippet along with a link to the JSFiddle for reference:


    <div class="col-1-left">
      <div class="content">
        <div class="icon">
          <img src="#" />
        </div>
        <div class="text">
          <h4>
           Title text
          </h4>
        </div>
      </div>
      <div class="button">
       <a href="#">Read More</a>
      </div>
    </div>

    .col-1-left {
    width: 100%;
    background: #555;
    padding: 10px;
    margin: 0;
    color: red;
    }

    .col-1-left:hover {
    color: white;
    }
    .button a {
    color: #000;
    }
    .button a:hover {
    color: white;
    }

UPDATE: I have tried some solutions on JSFiddle, but none seem to work on my live site. I have provided an updated HTML code structure below in hopes of resolving this issue. Any help would be appreciated. Thank you!


    <div class="et_pb_column et_pb_column_1_3 col-1-left et_pb_column_93 cboxElement">

            <div class="et_pb_blurb et_pb_module et_pb_bg_layout_light et_pb_text_align_center mp_m_blurb_pulse fins-color-aqua et_pb_blurb_50 et_pb_blurb_position_top">
              <div class="et_pb_blurb_content">
                  <div class="et_pb_main_blurb_image">
                    <span class="et-pb-icon et-waypoint et_pb_animation_off et-animated" style="color: #28375c;">?</span>
                  </div>
                  <div class="et_pb_blurb_container">
                    <h4>Title</h4>
                    <h5>Subhead</h5>
                  </div>
              </div> 
            </div>
            <div class="et_pb_button_module_wrapper et_pb_module et_pb_button_alignment_center">
               <a class="et_pb_button et_pb_button_26 et_pb_module et_pb_bg_layout_dark" href="#">Find Out More</a>
            </div>

    </div>

Answer №1

Feel free to give this a shot:

.col-1-left:hover * {
   color: white;
}

Answer №2

I have created a code snippet for you to try out. Please check it and let me know if it meets your requirements.

The key thing to remember is that in order to change the color of child elements, you need to apply the hover effect to the parent element, specifically .col-1-left.

.col-1-left {
  width: 100%;
  background: #555;
  padding: 10px;
  margin: 0;
  color: red;
}

.col-1-left:hover, .col-1-left:hover .button a {
  color: white;
}
.button a {
  color:#000;
}
<div class="col-1-left">
  <div class="content">
    <div class="icon">
      <img src="#" />
    </div>
    <div class="text">
      <h4>Title text</h4>
    </div>
  </div>
  <div class="button">
    <a href="#">Read More</a>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In HTML, an important concept to understand is how float:left is necessary when the combined widths of child blocks equal

Apologies if my question seems redundant, I was having trouble finding the right search terms. Let's discuss a scenario with a parent <div> containing two inline-block children, each with a width of 50%. If we don't apply overflow: hidden ...

Alignment of content layout across two wrapper elements

My goal is to achieve a specific layout where each pair of cards in a two-column layout is aligned based on the card with the largest content. Both cards share the same content layout and CSS. If you have any ideas or implementations that could help me ac ...

Any solutions for dealing with longer labels in Bootstrap form-floating?

Is there a way to use Bootstrap's form-floating feature with longer labels so that the text box automatically expands to accommodate the text but doesn't cut off on white-space wrap when too long? I'd like to avoid using position-relative to ...

Is Asp.net 4 resetting the array with every new run?

I have developed a basic asp.net web page to generate HTML content. The concept is to store previous user inputs in an array each time they click a button, and display them along with the most recent input. However, I encountered an issue where the array a ...

Styling Overflow in Coda Slider using CSS

Currently utilizing the Coda Slider for my project. For those unfamiliar with the Coda Slider, it initially hides the overflow-x position until a tab is clicked. This triggers an animation that slides the hidden DIV in either from the right or left side. ...

Customized icons for Contact Form 7 on your Wordpress website

Currently, I am in the process of customizing a contact form by incorporating placeholder icons and text using the 'Contact Form 7' plugin within Wordpress. This particular contact form is situated on a website that I am constructing with the &ap ...

Notification continuously appears when clicking outside of Chrome

I have implemented the use of onblur on a text box to display an alert. However, I encountered an issue where if I click outside my Chrome browser after entering text in the text box and then click on the Chrome browser button in the task bar, the alert ap ...

Is there an error when iterating through each table row and extracting the values in the rows?

Here is a basic table that I am attempting to iterate through in order to retrieve the value of each cell in every row where there are <td>s present. However, I encounter an error indicating that find does not exist despite having added jQuery. Any ...

Utilizing flex-box for smooth transitions in React Router with react-tranisition-group

Currently, I am working on implementing transitions for my react-router page using react-transition-group. All of my page content is wrapped inside a container, and I have applied flex-box to center the container. Unfortunately, I am facing issues with g ...

Utilizing jQuery to implement a CSS style with a fading effect, such as FadeIn()

I have a jQuery script that applies a CSS style to an HTML table row when the user clicks on a row link: $(this).closest('tr').css("background-color", "silver"); Is there a way to soften this color change effect, such as by gradually fading in ...

Preventing default form submission in jQuery: How to cancel it when a certain condition is met

I have a contact form where I validate the input values upon clicking on the submit button. If there is at least one empty input, I trigger an alert and prevent the form submission by using preventDefault. However, if all inputs are filled and submitted, t ...

What causes the significant difference in website speed between Internet Explorer and Firefox?

While operating an asp.net website, I have noticed that one specific page is running significantly slower in Internet Explorer compared to other pages. Interestingly, this same page performs well in Firefox. Does anyone have insight into why this discrep ...

Issue with JavaScript Onclick Event Handler

Rephrasing Full JavaScript Code. Javascript <div id="PopUp1" style="display: none; color: #FFFFFF;"></div> <div id="Mask"></div> <script type="text/javascript"> var Content = '<p>Content!!!!!</p><input ty ...

What is the best way to customize the interval time for my specific situation?

I'm working on setting an interval in my app and I have the following code: HTML <div class="text"> {{currentItem.name}} </div> <ul> <li ng-repeat="item in items" ng-click="pickItem($index)">{{item.type}}</li> ...

The inserted button's click event does not trigger the contentEditable DIV

I have a contentEditable DIV that I manage using the directive below: <div class="msg-input-area" [class.focused]="isMsgAreaFocused" contenteditable [contenteditableModel]="msgText" (contenteditableModelChang ...

How can you apply a class to a different element by hovering over one element?

Is there a way to darken the rest of the page when a user hovers over the menu bar on my website? I've been playing around with jQuery but can't seem to get it right. Any suggestions? I'm looking to add a class '.darken' to #conte ...

"Trouble with jQuery: Selecting an image to change isn't

Can someone help me figure out why my simple image change on a dropdown isn't working correctly? You can find the code on this Jsfiddle. Thank you for any assistance! $("#display_avatar").change(function(){ $("img[name=preview]").attr("src", $( ...

Tips for Accessing a New Website Using the Floating Layer Close Button

How can I trigger the opening of a new browser window when a visitor clicks the close "x" on my floating layer ad? The close button is within an HTML link code ("a href"), but simply putting a URL in there does not seem to work. <script language=" ...

Using the Chrome WebDriver for Selenium to interact with a text input element with dynamically changing IDs

I seem to be encountering difficulties with accessing an input element on a specific webpage. If the link has timed out, you can click on this following link: and then select the "RL_reactors" hyperlink to navigate to the page in question. On this page, ...

Can you use "or" or "not" syntax with CSS input type selectors?

In the world of programming, if they actually exist, Suppose I have created an HTML form with the following input fields: <input type="text" /> <input type="password" /> <input type="checkbox" /> I wish to style all input fields that a ...