Hovering over a class list will modify various element IDs

Is there a way to change the height of an element with id = "header_nav" when hovering over the class "header_nav" li element?

Here is the HTML Code:

<div class="header_nav" id="header_nav">
        <ul id="header_nav_mainmenu">
            <li><a href="index.php">Home</a></li>
            <li><a href="portfolio.php">Portfolio</a>
                <ul id="header_nav_submenu">
                    <li><a href="subpages\python.php">Python</a></li>
                    <li><a href="subpages\web_design.php">Web Design</a></li>
                    <li><a href="subpages\arma.php">ArmA Series</a></li>
                </ul>
            </li>
            <li><a href="forums\forums_home.php">Forums</a></li>
            <li><a href="support.php">Support</a>
                <ul>
                    <li><a href="subpages\contact_us.php">Contact Us</a></li>
                    <li><a href="subpages\faq.php">F.A.Q.</a></li>
                </ul>
            </li>
        </ul>
    </div>

This is the CSS Code:

.header_nav
{
    width: 80%; 
    background-color: #1F1F1F;
    float:left;
    left:1px;
    top:100px;
    border-radius: 6px;
    width:15%;
    height:135px;
    text-align: left;
    position: fixed;
    border:1px solid white;

}

.header_nav li
{
    list-style: none;
    display: block;
    position: relative;
    text-align: left;
    background-color: #1F1F1F;
    /*transition*/
    transition: background-color 1s;
    -webkit-transition:background-color 1s;
}

.header_nav li a
{
    text-decoration: none;
    color:white;
    font-size: 22px;
}

.header_nav li ul
{
    display: none;
    position: absolute;
}

.header_nav li:hover ul
{
    display: block;
    position: relative;
    left:0px;
}

.header_nav li:hover a
{
    background-color: #454545;
    font-weight: bold;
    color: #FFAE00;
}

.header_nav li:hover ul a
{
    margin-top:2px;
    color:white;
    background-color: transparent;
    font-weight: normal;
    /*transition*/
    transition: background-color 0.5s;
    -webkit-transition: background-color 0.5s;
}
.header_nav li:hover ul li
{
    width:155px;
}

.header_nav li:hover #header_nav
{
    height:200px;
}

If you have any advice or suggestions, I would greatly appreciate it as I am having trouble figuring out where the issue lies.

Answer №1

In CSS, you have the ability to customize the appearance of the element you've chosen, but you can't move back up the DOM tree. This means that when you select .header_nav li:hover, you're only able to style the li itself and not the parent container .header_nav.

If you're unable to adjust your HTML structure, JavaScript may be necessary for making these changes.

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

Bootstrap - Progress Bar Display

I have a mobile application that is built using Bootstrap 3. I am currently working on creating a responsive progress indicator for the app. This indicator will consist of three to five steps, each showing an icon, step name, and status. On mobile devices, ...

Position the text on the left side while also centering it within my div

I am attempting to center align some links within my div, while also ensuring that the text of the links is aligned to the left. However, I have been unsuccessful in achieving this. I can either align them to the left or center, but not both simultaneousl ...

Make the table in a bootstrap design appear with a border when you hover over a cell using the table

Looking for a solution to make the border work as expected when hovering over each td in a table like this example: https://jsfiddle.net/nmw82od1/ Here is the CSS code: .table1 td:hover { border: 1px solid black; } .table2 td:hover { border: 1px do ...

How to utilize the reduce method with an array of objects in JavaScript

Every week, a number of objects are delivered to me. Each object contains information such as date, hours, and other fields. I need to arrange these objects in an array based on the total hours for each day. Here is an example of the objects: var anArray ...

What is the method for inserting a newline into a textarea with an HTTPRequest?

Is it possible to print a newline in a textarea using the HTTPRequest property? Here's the code I have: <script> function sendRequest(str) { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } el ...

Update a section of my PHP webpage using setInterval()

How can I refresh a PHP value every second using setInterval()? I am familiar with refreshing values in HTML, but now I want to do the same with PHP values. Here is my code: <script> setInterval(function() { <?php $urlMachineOnline = ' ...

Ways to obtain an attribute through random selection

Figuring out how to retrieve the type attribute from the first input element: document.getElementById('button').addEventListener('click', function() { var type = document.querySelectorAll('input')[0].type; document.getE ...

Creating three-dimensional text in Three.js

My script is based on this documentation and this resource. Here is an excerpt of my code: <script src="https://raw.github.com/mrdoob/three.js/master/build/three.js"></script> <script> var text = "my text", height = 20 ...

How can we add a class to a radio button using jQuery when it is checked, and remove the class when it

I'm looking for help with using jQuery to toggle between two radio buttons and display different divs based on the selection. jQuery(document).ready(function($) { if ($('#user_personal').is(':checked')) { $('.user_co ...

Vanished were the empty voids within our

It seems that the spaces between words have mysteriously vanished in a font I am currently using. Take a look at this website: I am utilizing a slightly modified Twitter Bootstrap with Google Web fonts, and the font causing the issue is Oswald from Googl ...

How to iterate and apply styles to properties of objects in an array using Vue.js?

Currently, I am working with Vue.JS and facing some challenges while outputting data using the v-for loop. My objective is to repeat a 'base' item with unique information. You can refer to the image below for better understanding. Progress has ...

Displaying the usernames of the users on the interface leads to encountering the 'Undefined Index' error

Hey there, I'm currently facing an issue with displaying the user's first name as a greeting message on index.php. I want it to say 'Hello, (user's first name)', but since I'm fairly new to PHP, I'm struggling to make it ...

Is it possible to include the contents of an .ics file and provide a link to it in HTML, all without relying on JavaScript?

The content of an .ics file is quite simple: BEGIN:VCALENDAR VERSION:2.0 PRODID:-//appsheet.com//appsheet 1.0//EN CALSCALE:GREGORIAN METHOD:PUBLISH BEGIN:VEVENT SUMMARY:Invitation from <<USEREMAIL()>> to talk about <<[MeetingTopic]>> ...

Effortlessly glide to a specific div ID upon page load using the URL address

One way to implement smooth scrolling to an anchor on page load is by using jQuery. Here's an example code snippet: $(function(){ $('html, body').animate({ scrollTop: $( $('#anchor1').attr('href') ).offset(). ...

Sending information to a server using JavaScript

Greetings everyone, this is my first time posting here and I would appreciate detailed guidance in your comments. Just a little background about myself: I am a second-year college student with one year of Python training. I only recently started learning ...

PHP offers a different solution instead of using an HTML hidden input tag

Is there a way to pass a value from one HTML form to another without using hidden input fields? I need this value for a prepared SQL statement. I'm concerned about security risks associated with using hidden input fields. Does anyone have an alternat ...

Scraping data from the web using R and creating interactive plots with hover text in Plotly without

I'm attempting to extract hover text content from plotly traces that have been shared online. This is a new type of scraping for me, and I'm exploring ways to accomplish this task in R without relying on selenium or phantomjs, possibly with the u ...

Why does the CSHTML button containing a JavaScript onclick function only function intermittently?

I've implemented a download button on a webpage that dynamically assigns an ID based on the number of questions posted. Below is the code for the button: <input data-bind="attr: { id: $index() }" type="button" value="Downlo ...

Dynamic change in the mutation observer is not causing the callback to trigger

I have created a nested structure with two <div> elements. I am monitoring changes in the width of the inner <div>, which is set to width:auto;. Despite adjusting the width of the parent <div>, the mutation observer callback doesn't ...

Tips for refreshing only a portion of a webpage using JavaScript/jQuery

I have two distinct navigational sections on my website. The left column has its own navigation menu, while the right column (main content area) contains a separate set of links: My goal is to click on a link in the left-hand sidebar (such as "Resume", "E ...