What specific component of the coding determines the appearance of the hover feature on the sub menu?

I am new to web development. I recently grabbed this code snippet from bootstrap.com and I'm trying to customize it. I've managed to change the color of the navigation menu by modifying the CSS, but I'm struggling to identify which part of the code controls the hover state of the sub-menu items. Any help would be appreciated!

<nav class="navbar navbar-expand-lg">
  <a class="navbar-brand" href="#">Do You Know Jennipher</a>

  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
            
        </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>

      <li class="nav-item">
        <a class="nav-link" href="#">About Me</a>
      </li>

      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Portfolio</a>

        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="#">Egyptian Paradise</a>
          <a class="dropdown-item" href="#">Movie Madness</a>
          <a class="dropdown-item" href="#">George's Safari Adventure</a>
        </div>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Gallery</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Say Hello</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0">
      <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
    </form>
  </div>
</nav>

The CSS I added looks like this:

 .navbar{
     background-color: #55C9EA;
     font-family:Gotham, "Helvetica Neue", Helvetica, Arial, "sans-serif";
    }

  .dropdown-menu{
      background-color: #55C9EA;
    }

Answer №1

Is your submenu comprised of "Egyptian Paradise, Movie Madness, and George's Safari Adventure"? If so, you can target the classes just like you did with .navbar and .dropdown-menu. Instead of using .dropdown-menu, try using .dropdown-item and utilize the CSS pseudoselector :hover to change colors on hover.

.navbar{
 background-color: #55C9EA;
 font-family:Gotham, "Helvetica Neue", Helvetica, Arial, "sans-serif";
}

.dropdown-menu{
  background-color: #55C9EA;
}

.nav-link {   <---- Targets home, about me, portfolio, gallery, say hello
  color: red;
}

.nav-link:hover {
  color: yellow;
}

.dropdown-item { <--- Targets portfolio submenu
  color: green;
}

.dropdown-item:hover {
  color: purple;
}

You can view a working example in this fiddle.

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

A unique approach to handling ngdisabled for fields that are required only

Starting off with a requirement to disable the submit button when a required field is left empty. <form name="form"> <input type="text" placeholder="First Name" data-ng-model="model.firstName" name="FirstName" ng-required="true" /><br/> ...

Utilize Bootstrap to position the button right next to the input field

I am having trouble aligning the button on the right next to the email textbox. Unfortunately, my attempts have not been successful. Fiddler: https://jsfiddle.net/Vimalan/mt30tfpv/4/ <div class="col-xs-3"> <div class="fo ...

Ensuring Radiobuttons are Selected on a Page After Clicking the Submit Button

Seeking assistance with this issue: I am working on a page that includes radio buttons: <label>Delivery type:</label> <input type="radio" name="delivery" value="7" class="delivery-item" id="del-type-7" onclick=""><label class="label" ...

Arrange Bootstrap columns based on the available space within a loop

The content is contained within a md-8 div and generated through a PHP loop. The loop includes sections for: 1. about us 2. areas we cover 3. job board 4. candidates 5. join us 6. contact Due to the limited height of the "areas we cover" section, th ...

Display the initial three image components on the HTML webpage, then simply click on the "load more" button to reveal the subsequent two elements

I've created a div with the id #myList, which contains 8 sub-divs each with an image. My goal is to initially load the first 3 images and then have the ability to load more when clicking on load more. I attempted to follow this jsfiddle example Bel ...

Set the title attribute according to the content of the <p> tag

Recently, I encountered a situation where I had numerous p tags with a specific class (let's call it .text). My task was to include the title attribute containing the text of each tag. For example: <p> Hello, world </p> This would resul ...

Verify if the checkbox has been selected by utilizing the prop function

<form action=""> <input type="checkbox" id="cbk" class="cbk" name="cbk"> <input type="submit"> </form> <script type="text/javascript"> if($('#cbk:checked').prop('checked')) { alert('Checked'); ...

Text area in the footer of a Bootstrap-4 modal that can be scrolled through

In my Angular-6 project, I am implementing a Bootstrap-4 modal. The Modal-Header has a fixed height, Modal-Body is scrollable, and Modal-Footer has a variable height but is not scrollable. Below is a snippet of my basic HTML: /*for debugging purpose*/ ...

Unable to view the CSS for background color

For the codeContainer class, the background-color is not displaying as expected. It seems like it may be covered by the menu bar. How can I adjust the background-color or positioning to make sure it shows up correctly? http://jsfiddle.net/5qd5bL7o/ <d ...

The code functions properly in Chrome's Developer Tools, but fails to display correctly on an actual handheld

Contact form in Developer Tools Contact form on Chrome for Mobile Upon examining the images, it becomes apparent that the CSS is not rendering correctly on the mobile device. Media queries are being utilized for styling on mobile platforms. <meta nam ...

Unpacking Django's request processing: Understanding the logic behind choosing one URL pattern over another

Currently enrolled in a free online Django course and faced with a perplexing issue related to request processing in Django. The application I am working on consists of a single module with two pages that inherit from a layout template - an index page with ...

Ways to obtain distinct JavaScript key codes for [ and { and ' and "

Greetings all! I'm currently working on a text editor that has the ability to automatically complete brackets and quotes by using jQuery. In order to achieve this, I am utilizing key codes. However, I have encountered an issue where the characters [ a ...

What was the inspiration behind Spotify's section design?

Spotify has cleverly hidden the overflowing content without showing a scrollbar, allowing users to swipe through the list. How did they achieve this? I am currently using tailwindcss if that makes a difference. https://i.stack.imgur.com/z59yv.png ...

Styling Images with CSS Attributes

Having a little trouble with WordPress and CSS. My goal is to make my images span the full width of my posts (800px), but currently they're restricted to 620px. When I check Inspect Element, here's the CSS code that shows up: img[Attributes Styl ...

Is offline mode supported in ASP.NET Core MVC for both viewing and submitting data?

We are currently developing a web application that utilizes various technologies including:- ASP.NET Core MVC SQL Server Entity Framework Core Bootstrap IIS Is it possible for our web application to operate in offline mode for specific screens? For insta ...

Consolidate the indexes of arrays into a single object

Is there a way to combine array indexes into one object using a key-value pair format, like {authors[i]: quotes[i]} in my example? If you'd like to review the code, please visit my Codepen: http://codepen.io/anon/pen/Ndezeo Thank you. ...

How to open a file using JavaScript without relying on NodeJS

I am looking for a way to access all the mp3 files within a directory named music on my server. My goal is to create a list of these songs and allow users to play them without relying on a Node server. Instead, I want to achieve this using the JavaScript c ...

Tips for customizing layout with an Asp.net Repeater

I have a database table with the columns "Car" and "Color". In my Asp.net application, I am using a repeater inside a table to display the data. The repeater code is as follows: <asp:Repeater ID="repeater_CarsColors" runat="server"> ...

Utilizing JavaScript/jQuery to activate a Bootstrap navbar post-page load

Having trouble triggering Bootstrap's navbar with plain JavaScript/jQuery while using Bootstrap 3.3.6 and jQuery 1.11.3. The data structure provided for my application cannot be modified in terms of adding classes or ids. <ul> <li ...

Is it possible for an HTML number input's arrows to change in increments that are different from its designated step attribute?

Within my design, I have implemented an <input type="number" step="1"> element for selecting font size. However, in the context of working on a large canvas, adjusting the number by 1 is hardly noticeable. It would greatly enhance ...