I am working on a CSS3-navigation, but I have some troubles with the overflow of the hover-effect.
I tried to add overflow:hidden - without success.
This is what it looks like:

And this is what it should look like:

HTML:
<header>
<div id="header-top">
    <nav id="main-navigation" role="navigation">
        <ul class="menu">
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Events</a></li>
          <li><a href="#">Artists</a></li>
        </ul>
    </nav>
</div>
CSS:
#header-top {
    height: 70px;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 100;
}
#header-top:after {
    background: rgba(0,0,0,0.35);
    content: "";
    height: 120px;
    position: absolute;
    top: -50px;
    left: 0px;
    transform: skewY(-4deg);
    width: 100%;
    z-index: -1;
}
#main-navigation ul {
    display: inline;
    float: right;
    padding: 0;
    margin: 0;
}
#main-navigation ul li {
    display: inline;
    line-height: 30px;
}
#main-navigation ul li a {
    display: inline-block;
    font-size: 14px;
    font-weight: 400;
    color: #fff;
    padding: 20px;
}
#main-navigation ul li a:hover {
    padding: 20px;
    background-color: red;
}
Here is a fiddle: http://jsfiddle.net/v9dfjq4L/1/
Thanks in advance!
put the background color on the header and use the :after element to clip the bottom of the #header-top.
http://jsfiddle.net/ovtphrqL/

#header-top:after {
    background: rgba(255, 255, 255, 1);
    content: "";
    height: 120px;
    position: absolute;
    top: 74px;
    left: 0px;
    transform: skewY(-3deg);
    width: 100%;
    z-index: 5;
}
                        I would suggest you to play with clip-path and mask. Here are some useful links:
Link 1
Link 2
Problem explanation:
overflow: hidden will indeed not work, because you applied the skewY to the :after element, which doesn't influence the rest of the content of #header-top.
However, I found thissolution to your problem:
Remove the :after thing. Apply the skewY(-4deg) and background-color to the <nav>, and invert this transform for the inner <ul> using skewY(4deg). Now, overflow: hidden will work when applied to the <nav>.
A few new problems turn up: a little white triangle in the left top corner (fix: padding-top and negative margin-top for the <nav>), and the red hover isn't high enough for some items (fix: use a bigger padding-bottom).
Don't forget to use a crossbrowser fallback for transform (-webkit-, -moz-, -o-).
Applied solution:
This solution is applied in this JSFiddle: http://jsfiddle.net/v9dfjq4L/9/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With