Troubleshooting Problem with CSS Button Hover Effects

Is there a way to keep the white "Contact US" text active or white when the user hovers over the button and moves down to the list of links? It seems like a simple issue, but I can't figure it out. Currently, the text turns from red to white and back to red when hovering over the dropdown menu. How can I make sure it stays white when hovering over the menu below?

I'm still cleaning up the code and adjusting the button, but I have removed all unnecessary elements.

JSFiddle: https://jsfiddle.net/hvj675mo/6/

Answer №1

Both .new-contact-us-box and .new-contact-us have a hover effect applied. To simplify, you can update the CSS like this:

.new-contact-us-box:hover .new-contact-us {
  background-color: #ce1818;
  font-family: Arial;
  font-size: 14px;
  font-weight: bold;
  color: #ffffff;
}

Check out the demo below:

body {
  background-color: #000000;
}

.new-contact-us {
  background-color: transparent;
  -moz-border-radius: 9px;
  -webkit-border-radius: 9px;
  border-radius: 9px;
  border: 2px solid #ce1818;
  display: inline-block;
  cursor: pointer;
  font-family: Arial;
  font-size: 14px;
  font-weight: bold;
  padding: 14px 14px;
  text-decoration: none;
  line-height: 10px;
  color: #ce1818;
}

.new-contact-us-box:hover .new-contact-us {
  background-color: #ce1818;
  font-family: Arial;
  font-size: 14px;
  font-weight: bold;
  color: #ffffff;
}

.new-contact-us:active {
  position: relative;
  color: #ffffff;
  background-color: #ce1818;
}


/**** START BOX DIV ****/

.new-contact-us-box {
  position: relative;
  display: block;
}

.new-contact-us-box:active {
  color: #ffffff;
}


/**** START DROPDOWN ****/

.new-contact-us-box ul li {
  padding-bottom: 10px;
  font-size: 16px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #ababaa;
  text-transform: none;
}

.new-contact-us-box ul li a {
  color: #ce1818;
  text-decoration: none;
}

.new-contact-us-box ul li a:hover {
  text-decoration: underline;
}

.container-contact {
  float: left;
  width: 296px;
  margin 0px;
}

.new-contact-us-box ul {
  padding-left: 0px;
  list-style: none;
  margin: 0px;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown:hover {
  position: relative;
  display: inline-block;
  background-color: #ce1818;
  color: #ffffff;
  -moz-border-radius: 9px;
  -webkit-border-radius: 9px;
  border-radius: 9px;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #ffffff;
  min-width: 160px;
  padding: 12px 16px;
  z-index: 1;
}

.dropdown:hover .dropdown-content {
  display: block;
  left: auto !important;
  right: 0 !important;
}

</style>
<div style="width: 700px; padding-left: 600px">
  <!-----WILL REMOVE THIS DIV AFTER. HERE FOR TESTING--->
  <div class="new-contact-us-box dropdown">
    <a href="#" class="new-contact-us">CONTACT US</a>
    <div class="dropdown-content">
      <ul style="width: 296px; left: auto !important; right: 0 !important; padding: 20px;">
        <li>
          <div class="container-contact">
            <ul>
              <li>Hello</li>
              <li><img src="####" style="margin-right: 10px;"><a href="#" target="_blank">#########</a></li>
              <li style="margin-left: 28px; margin-top: -9px"> <a href="#" target="_blank">BlAH BLAH</a></li>
            </ul>
          </div>
        </li>
      </ul>
    </div>
  </div>
</div>
<!-----WILL REMOVE THIS DIV AFTER. HERE FOR TESTING---->

Answer №2

Revise your CSS

.contact-us:hover {
    background-color:#ce1818;
    font-family:Arial;
    font-size:14px;
    font-weight:bold;
    color: #ffffff;
}

to the following:

.dropdown:hover .contact-us {
    background-color:#ce1818;
    font-family:Arial;
    font-size:14px;
    font-weight:bold;
    color: #ffffff;
}

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

Utilizing jQuery to determine the placement of a tooltip within a slider

I am currently utilizing both a jQuery Tooltip and a jQuery Slider (jQueryUI) simultaneously. While the slider is functioning correctly, I am encountering an issue where tooltips are being displayed in the wrong position after scrolling (view screenshot or ...

Achieving Navbar overlap on Carousel with Bootstrap

Is there a way to make the bootstrap navbar overlap with the carousel without causing any issues with #test? HTML <nav class="navbar navbar-expand-lg navbar-dark bg-dark floating-navbar"> <div class="container"> & ...

Tips for achieving consistent outcomes on both IE and Chrome when utilizing the `min` attribute in HTML input tags

The display of input fields is inconsistent between IE (version 11) and Chrome (version 46.0.2490.71) when using the min option in the HTML input tag. In Chrome, the input fields appear extra long, while in IE they display correctly (same as when min is no ...

How can I design a side navigation menu using Bootstrap?

I've come across various tutorials online on how to create a side collapsible menu, but they all involve a lot of code. I just need to toggle the visibility of a specific div within this structure: <div class="row"> <div class="col-md-2" ...

Getting the IDs of selected nodes all the way up to the root node in jsTree

How can I retrieve the IDs of all parent nodes from a selected node to the root node in jsTree? If node C is selected, how can I obtain the IDs of all its parent nodes? Tree Structure: B C +C1 +c2 The following code snippet only returns the imme ...

Ways to incorporate a smooth transition between the opened and closed fab functionality

I am currently utilizing VueJS and Vuetify in my project. I have successfully implemented Vuetify's FAB component, which displays a list of fab buttons as demonstrated in the documentation: <div id="fab-button"> <v-speed-dial v-mo ...

Tips for incorporating an anchor tag within an img tag in HTML?

Is it possible to add an anchor tag inside an img tag in HTML? <img src="img.jpg" alt="no img" /> I want to include the following inside the img tag: <a onclick="retake();" > Retake </a> The goal is to allow users to retake a photo by ...

Is there a way to incorporate a dropdown feature into a search bar using Ant Design?

I'm currently working on a project that requires me to incorporate two drop-down menus inside the search box. Despite following the guidelines provided in the documentation (https://ant.design/components/input), I encountered a problem when trying to ...

Using PHP and MySQL to handle data submission through the POST method

When I send data to post[submit] and post[request], it's coming from two separate buttons. Even though I successfully submitted user_id to post[submit], I'm encountering difficulty in echoing the user_id in the request portion (post[request]). ...

What causes a fixed position div to extend beyond the boundaries of the main container?

Below is the CSS for the fixed div: .top-container { position: fixed; width: 100%; z-index: 999; } Upon zooming out the screen, the div causes the main container to break on the right side while the left side remains unchanged. Refer to the screenshot be ...

How can I customize the visibility toggles for the password input field in Angular Material?

Currently immersed in the Angular 15 migration process... Today, I encountered an issue with a password input that displays two eyes the first time something is entered in the field. The HTML code for this is as follows: <mat-form-field appearance=&qu ...

Using CSS to cut out a triangle shape from an image

Our designer has a vision for this: However, I'm struggling to find a suitable method for creating the triangle crop effect: Implementing an :after element that spans the entire width and utilizes border tricks to form a triangle shape Creating a l ...

AngularJs fails to apply style to dynamic content in IE8 when using HTML5

Currently, I am in the process of developing a website with AngularJs and utilizing numerous JS scripts to address compatibility issues with Internet Explorer. I have organized the data in JSON format, and each page is designed to fetch and display differ ...

I recently created a Python3 script utilizing selenium to automate message sending, but unfortunately, it is not functioning as expected

I've written a script (https://pastebin.com/dWLFvirn) that I'm trying to run through the terminal, but it's giving me an error. Here's a screenshot of the error (https://ibb.co/NSfLgL8). I would like to use "" as the link to make the s ...

Link not functioning correctly on mobile-responsive CSS

Having some trouble with hyperlinks over a background image. The hyperlinks work fine normally, but in mobile view, nothing happens when clicking on them. Below is the code for the hyperlinks. You can also visit the site and see that the "Post a Project" ...

Transferring the chosen dropdown value to the following page

I am attempting to transfer the currently selected value from a dropdown to the next page using an HTTP request, so that the selected value is included in the URL of the subsequent page. The form dropdown element appears as follows: <form name="sortby ...

Tips for eliminating the bottom border on a nav-tab in Bootstrap 4

When a vertical navigation menu item is selected, a border appears below the item. How can I remove this border? .nav-tabs li, .nav-tabs li a { border-bottom: none; } Here is a picture of the border: ...

Customizing hyperlink styles with JavaScript on click

Hey there! I'm experimenting with something new. I've managed to change the background color of each link after it's clicked, but now I'm facing a challenge: How can I revert the original style when another link is clicked? Here's ...

Aligning SVG clipping path using CSS

This problem has me stumped! I need to center the SVG clip within the surrounding div, just like in this example: http://jsfiddle.net/ztfdv9qh/ - Make sure to check the link because the SVG is quite long! <div class="svg-wrapper"> <div class ...

Adding an automatically generated link within an HTML form

I am working on a web page that displays dynamic content and includes a form for user submissions. How can I add a unique reference to each of these pages within the form? <div class="detalle-form-wrap"> <div> <h1> ...