1

I am trying to change the height of the header while I'm hovering over a div in the header. The div is a dropdown button and the header is supposed to extend a specific amount of pixels to fit the drop down-content.

HTML:

<header>
    <nav class="menyer">
        <div class="dropdown">
            <button class="dropbtn">Dropdown</button>
                <div class="dropdown-content">
                    <a href="#">Link 1</a>
                    <a href="#">Link 2</a>
                    <a href="#">Link 3</a>
                 </div>
         </div>
     </nav>
 </header>

You can find all source code here

Leo the lion
  • 3,213
  • 2
  • 19
  • 39
Lukkinen
  • 13
  • 2

1 Answers1

0

You can't change the height of an element while hovering over a child-element. All you can do is to expand the height of the inner element so that the outer element stretches accordingly. That only works if there is no fixed height on the base-element (your header)

basic example:

<header> <ul> <li>Item 1</li> <li> Item 2 </li> </ul> </header>

CSS:

li{display:block;height: 30px;}
li:hover{height: 50px;}
header{background-color:red}

That way the header extends if you hover over a li element. If you need a minimum height for your header to work (because of the design, ... ) then set a min-height for the header.

cloned
  • 4,562
  • 3
  • 18
  • 31
  • So.. is there any other option? You could paste the code that should work for OP. – Variable Apr 28 '16 at 11:38
  • It would really depend on what he would want to do exactly. srry edit coming up – cloned Apr 28 '16 at 11:48
  • _I am trying to change the height of the header while I'm hovering over a div in the header_ – Variable Apr 28 '16 at 11:49
  • Sorry, posted my reply too fast, still new to this site. I know what he said in the post (and edited my post for a suggestion), to add to the solution in the duplicate link. – cloned Apr 28 '16 at 11:56