TechQA.

CSS3 Flip Dropdown Menu - Retain main-menu hover style when hovering over sub-menu

1.6k views Asked by user3413870 At 2015-06-25T13:52:54+00:00 25 June 2015 at 13:52 2025-12-25T00:13:56+00:00

Here's the fiddle for my query

https://jsfiddle.net/e7te8hf1/

<section id="action-bar">
<div id="logo">
<a href="#"><img src="img/logo.png"></a>
</div><!-- end logo -->

<nav class="navbar navigation main-navigation">
<ul class='menu main-menu'>
<li class='menu-item'>
<a href="#" class="three-d">
<span title='Women'>Women</span>
</a>
<ul>
<li>
<a href="casuals.html">Casuals</a>
<ul>
<li><a href="tops.html">Tops</a></li>
<li><a href="bottoms.html">Bottoms</a></li>
<li><a href="suits.html">Suits</a></li>
<li><a href="jumpsuits.html">Jumpsuits</a></li>
</ul>
</li>
<li><a href="formals.html">Formals</a></li>
<li>
<a href="prints.html">Prints</a>
<ul>
<li><a href="stitched.html">Stitched</a></li>
</ul>
</li>
<li><a href="anokhee.html">Anokhee</a></li>
<li><a href="abbayas.html">Abbayas</a></li>
<li>
<a href="accessories.html">Accessories</a>
<ul>
<li><a href="bags.html">Bags</a></li>
<li><a href="pouch.html">Pouch</a></li>
<li><a href="dupatta.html">Dupatta</a></li>
<li><a href="stole.html">Stole</a></li>
<li><a href="clutches.html">Clutches</a></li>
</ul>
</li>
</ul>
</li>
<li class='menu-item'>
<a href="#" class="three-d">
<span title='Men'>Men</span>
</a>
<ul>
<li>
<a href="casual.html">Casual</a>
<ul>
<li><a href="tops.html">Tops</a></li>
<li><a href="bottoms.html">Bottoms</a></li>
<li><a href="suits.html">Suits</a></li>
</ul>
</li>
<li><a href="formal.html">Formal</a></li>
</ul>
</li>
<li class='menu-item'><a href="#" class="three-d"><span title='Look Book'>Look Book</span></a></li>
<li class='menu-item'><a href="#" class="three-d"><span title='Stores'>Stores</span></a></li>
<li class='menu-item'><a href="#" class="three-d"><span title='Contact'>Contact</span></a></li>                         
</ul>
</nav>
</section>

and the CSS is

#action-bar .navbar {
    float: left;
}
#action-bar nav ul ul {
    display: none;
}
#action-bar nav ul li:hover > ul {
    display: block;
}
#action-bar nav ul {
    background: #fff;
    padding: 0;
    list-style: none;
    position: relative;
    display: inline-table;
    margin: 0;
    text-align: center;
    font-size: 15px;
    font-family:'Oswald', sans-serif;
    font-weight: bold;
}
#action-bar nav ul:after {
    content:"";
    clear: both;
    display: block;
}
#action-bar nav ul li {
    float: left;
}
#action-bar nav ul li:hover {
    background: #6f100d;
}
#action-bar nav ul li a {
    display: block;
    color: #757575;
    text-decoration: none;
    border-right: 1px solid #E5E5E6;
    border-bottom: 1px solid #E5E5E6;
    transition: .8s background-color;
}
#action-bar nav ul li a:hover {
    color: #fff;
}
#action-bar nav ul ul {
    background: #fff;
    padding: 0;
    position: absolute;
    top: 100%;
}
#action-bar nav ul ul li a {
    color: black;
}
#action-bar nav ul ul li {
    float: none;
    position: relative;
}
#action-bar nav ul ul li a {
    padding: 15px 40px;
    color: black;
}
#action-bar nav ul ul li a:hover {
    background: #6ABED6;
    color: #fff;
}
#action-bar nav ul ul ul {
    position: absolute;
    left: 100%;
    top:0;
}
#action-bar nav ul li:hover > a {
    color: #fff;
}
#action-bar #view-cart {
    float: right;
    display: inline-block;
    padding-top: 18px;
    padding-left: 5px;
}
#action-bar #user-menu {
    display: inline-block;
    padding-left: 160px;
}
.menu .menu-item {
    display: inline-block;
    margin: 0;
    padding: 0;
}
.main-menu .menu-item a {
    color: #fff;
    display: block;
    text-decoration: none;
    font-family:'Oswald:500', Arial, sans-serif;
    font-smoothing: antialiased;
    text-transform: uppercase;
    overflow: visible;
    background: #fff;
}
.three-d span, .three-d span::before, .three-d span::after {
    display: block;
    transition: all .3s ease-out;
    transform-style: preserve-3d;
}
.three-d {
    position: relative;
    cursor: pointer;
    transition: all .07s linear;
}
.three-d span {
    display: block;
    padding: 18px 35px;
    perspective: -200px;
}
.three-d span::before, .three-d span::after {
    padding: 18px 35px;
    content: attr(title);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: #fff;
    box-sizing: border-box;
}
.three-d span::before {
    transform: rotateX(0deg) translateZ(25px);
}
.three-d span::after {
    transform: rotateX(-90deg) translateZ(25px);
    background: #6f100d;
    color: #f9f9f9;
}
.three-d:hover span, .three-d:focus span {
    transform: translateZ(-25px) rotateX(90deg);
}

I want the main-menu to retain the hover style when I hover over the sub-menu, using CSS, but I am unable to achieve that.

Can anyone please help?

javascript html css flip
Original Q&A
1

There are 1 answers

1
Turnip Turnip On 2015-06-25T14:04:18+00:00 25 June 2015 at 14:04 BEST ANSWER

Change the last block of CSS...

.three-d:hover span, .three-d:focus span {
    transform: translateZ(-25px) rotateX(90deg);
}

to this...

li:hover .three-d span, .three-d:focus span {
    transform: translateZ(-25px) rotateX(90deg);
}

and change the rest of your a:hover { selectors to li:hover > a {

JSFIDDLE

Related Questions in JAVASCRIPT

  • Using Puppeteer to scrape a public API only when the data changes
  • inline SVG text (js)
  • An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
  • Storing the preferred font-size in localStorage
  • Simple movie API request not showing up in the console log
  • Authenticate Flask rest API
  • Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
  • How to request administrator rights?
  • mp4 embedded videos within github pages website not loading
  • Scrimba tutorial was working, suddenly stopped even trying the default
  • In Datatables, start value resets to 0, when column sorting
  • How do I link two models in mongoose?
  • parameter values only being sent to certain columns in google sheet?
  • Run main several times of wasm in browser
  • Variable inside a Variable, not updating

Related Questions in HTML

  • How to store a date/time in sqlite (or something similar to a date)
  • How to use custom font during html to pdf conversion?
  • Storing the preferred font-size in localStorage
  • mp4 embedded videos within github pages website not loading
  • Scrimba tutorial was working, suddenly stopped even trying the default
  • Is there any way to glow this bulb image like a real light bulb
  • With non-graphical maps in Leaflet, zoomDelta doesn't work
  • What can I do to improve my coding on both html and css
  • Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
  • Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
  • Displaying a Movie List on a Website Using Jinja2 and Bootstrap
  • How to redirect to thank you page after submitting a Google form embedded into a Google Site?
  • Storing selected language in localStorage
  • Fences (parenthesis, braces) in HTML and MathML
  • Understanding Scroll Anchoring Behavoir

Related Questions in CSS

  • How to use custom font during html to pdf conversion?
  • Storing the preferred font-size in localStorage
  • mp4 embedded videos within github pages website not loading
  • Is there any way to glow this bulb image like a real light bulb
  • What can I do to improve my coding on both html and css
  • Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
  • Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
  • How to increase quality of mathjax output?
  • Hover animation resetting( seemingly reverting back to original CSS and then again to hover)when moving mouse horizontaly accross a part of an element
  • Storing selected language in localStorage
  • How to clip grid cell and provide scroll as well?
  • KeyboardAvoidingView makes a messy the flexbox
  • Rotate an object around another object in javascript
  • Understanding Scroll Anchoring Behavoir
  • how to use only block layout in this css code?

Related Questions in FLIP

  • How to turn the page back and forth with flutter flip_page widget?
  • Make a book page with Flutter Flip_Page widget
  • flip an image vertically using loops in python
  • Stuck at animation a book page in css
  • How we can detect phone flip event in the flutter?
  • How to flip the back side of the card image
  • How to get HTMLElement properties before destroy in svelte?
  • Can someone help me get my Unity 2D character to flip in both directions?
  • How to invert or flip color ramp in with default color in levelplot function in R?
  • Position of flipped sprite is wrong in canvas, JavaScript
  • How to flip the entire screen in pygame (including sprites)?
  • How to flip a phylogeny horizontally?
  • I have json file with me and to display json text data with in the book of book
  • How can i implement Flutter flip animation for book reading app
  • How to correctly reverse a numpy array in 2 dimensions?

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)
  • Privacy
  • Terms
  • Cookies
  • Homegardensmart
  • Math
  • Aftereffectstemplates