How to target CSS :after element with the tilde selector? - css

The ::after selector will inserts something after the content, is this targetable with the preceding selector ~?
For example, HTML:
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
::after
</ul>
CSS:
ul::after {
content: '';
display: block;
height: 50px;
width: 100%;
background: red;
}
ul li:hover ~ ::after {
background: blue;
}
CODE EXAMPLE
Below you are able to find a working version of what I am after. However I did this with the "sub-menu-bar" div included. Now it seems the ::after pseudo element is positioned at the exact location in the DOM inspector. It would be nice if it could be done without the div.
The reason why the submenu bar is on the UL is because I don't want the bar to move when switching between two items which have a submenu.
ul, li
{
list-style: none;
padding: 0;
margin: 0;
}
a
{
cursor: pointer;
display: block;
color: inherit;
text-decoration: none;
text-transform: uppercase;
}
a > *
{
user-select: none;
}
ul.menu
{
position: relative;
display: flex;
width: 100%;
flex-wrap: wrap;
justify-content: center;
background: #FFF;
}
ul.menu > li.menu-item > a
{
padding: 0px 10px;
height: 50px;
overflow: hidden;
transition: height 0.3s;
}
ul.menu > li.menu-item > ul.sub-menu
{
position: absolute;
right: 0px;
bottom: 0px;
left: 0px;
display: flex;
width: 100%;
height: 0px;
align-items: center;
justify-content: center;
transition: height 0.4s;
color: #FFF;
}
ul.menu > li.menu-item > ul.sub-menu > li.menu-item
{
overflow: hidden;
}
ul.menu > li.menu-item > ul.sub-menu > li.menu-item > a
{
padding: 0px 10px;
transform: translateY(100%);
opacity: 1;
transition-property: transform, opacity;
transition-timing-function: cubic-bezier(0.52, 0.16, 0.24, 1);
transition-delay: 0s;
transition-duration: 0.2s;
}
ul.menu > div.sub-menu-bar
{
content: '';
display: block;
width: 100%;
height: 2px;
flex-basis: 100%;
transition: height 0.4s;
background: #000;
}
ul.menu > li.menu-item-has-children:hover > ul.sub-menu
{
height: 50px;
}
ul.menu > li.menu-item-has-children:hover > ul.sub-menu > li.menu-item > a
{
transform: translateY(0%);
opacity: 1;
transition-delay: 0.2s;
}
ul.menu > li.menu-item-has-children:hover ~ div.sub-menu-bar
{
height: 50px;
}
<ul class="menu">
<li class="menu-item"><a>Item #1</a></li>
<li class="menu-item menu-item-has-children">
<a>Item #2</a>
<ul class="sub-menu">
<li class="menu-item"><a>Subitem #2.1</a></li>
<li class="menu-item"><a>Subitem #2.2</a></li>
</ul>
</li>
<li class="menu-item menu-item-has-children">
<a>Item #3</a>
<ul class="sub-menu">
<li class="menu-item"><a>Subitem #3.1</a></li>
<li class="menu-item"><a>Subitem #3.2</a></li>
</ul>
</li>
<li class="menu-item"><a>Item #4</a></li>
<li class="menu-item"><a>Item #5</a></li>
<div class="sub-menu-bar"></div> <!-- Can we avoid this with ::after pseudo element? -->
</ul>
<p>Content below the navigation.</p>

When I hover on a specific list item (li) targeted with a class name.
I like the background color of the ::after element to change, which is
located on ul::after.
Yes, you can achieve this effect using pointer-events.
The way to do it is to apply to both the <ul> and the <li> the style:
ul, li {
pointer-events: none;
}
and apply to the hoverable <li> the style:
li.hover-over-this {
pointer-events: auto;
}
Working Example:
ul {
position: relative;
margin-left: 0;
padding-left: 0;
font-weight: bold;
background-color: white;
cursor: pointer;
}
li {
width: 50%;
padding: 6px;
color: rgb(255, 255, 255);
line-height: 24px;
background-color: red;
list-style: none;
}
ul:hover::after {
content: 'Hovering!';
position: absolute;
top: 0;
right: 0;
width: 100px;
height: 100px;
line-height: 100px;
color: rgb(255, 0, 0);
text-align: center;
background-color: rgb(255, 255, 0);
}
ul, li {
pointer-events: none;
}
li.hover-over-this {
pointer-events: auto;
}
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li class="hover-over-this">Hover Over This</li>
<li>5</li>
</ul>
Further Reading:
https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events

This does not require a ~. the ~ selector selects all siblings after the element. The pseudo element ::after is inside the li.
li:hover ~ li would for example target all li elements after the li that is hovered.
For what you want to do, use:
ul li:hover:after {
background: blue;
}
Edit:
Sorry, I didn't see the after applied to ul. This is not possible with pure CSS as there is no "parent" selector. You can only use ul:hover:after (or anything higher in hierarchy than ul) to target the after element.
What you could do:
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li></li>
</ul>
li:hover ~ li:last-of-type {
//something
}

Related

Adding Submenu to Existing Nav

I've been working on a navigation bar. I've got it styled the way I like, but for some reason am having issues getting submenus to work.
The code looks like:
<div id="head">
<input id="toggle" type="checkbox">
<label for="toggle" class="icon">
<div><!-- --></div>
<div><!-- --></div>
<div><!-- --></div>
</label>
<div id="nav">
<div>
<ul>
<li class="page_item page-item-8">Home</li>
<li class="page_item page-item-10 page_item_has_children">About
<ul class="children">
<li class="page_item page-item-22 page_item_has_children">Once More
<ul class="children">
<li class="page_item page-item-23 page_item_has_children">Another Sub Page
<ul class="children">
<li class="page_item page-item-25">Final Link</li>
<li class="page_item page-item-24">Something Else</li>
</ul>
</li>
</ul>
</li>
<li class="page_item page-item-21">Another Page</li>
<li class="page_item page-item-20">Subpage</li>
</ul>
</li>
<li class="page_item page-item-13 current_page_item">Shop</li>
<li class="page_item page-item-9">FAQ</li>
<li class="page_item page-item-11">Contact</li>
</ul>
</div>
</div>
</div>
The CSS looks like:
/* Toggle */
#toggle {
display: none;
}
/* Nav */
#nav li.current_page_item a {
background: #d2b48c;
border-radius: 40px;
color: #260f03;
}
#nav li a {
border-bottom: 1px solid transparent;
border-top: 1px solid transparent;
color: #fff;
display: inline-block;
font-family: 'Lato', sans-serif;
font-size: 14px;
letter-spacing: 4px;
margin: 20px;
padding: 10px 10px 10px 15px;
text-decoration: none;
text-transform: uppercase;
}
/* Media */
#media screen and (max-width: 600px) {
/* Icon */
.icon {
background: #260f03;
margin: 0 auto;
padding: 20px 20px 30px;
position: absolute;
width: 100%;
z-index: 500;
}
.icon div {
background: #d2b48c;
border-radius: 3px;
height: 2px;
margin: 10px auto 0;
position: relative;
transition: all 0.3s ease-in-out;
width: 3em;
}
/* Toggle */
#toggle:checked + .icon div:nth-child(1) {
margin-top: 25px;
transform: rotate(-45deg);
}
#toggle:checked + .icon div:nth-child(2) {
margin-top: -2px;
transform: rotate(45deg);
}
#toggle:checked + .icon div:nth-child(3) {
opacity: 0;
transform: rotate(45deg);
}
#toggle:checked + .icon + #nav {
top: 0;
transform: scale(1);
}
/* Nav */
#nav {
background: rgba(38, 15, 3, 0.95);
bottom: 0;
height: 100%;
left: 0;
overflow: hidden;
position: fixed;
right: 0;
top: -100%;
transform: scale(0);
transition: all 0.3s ease-in-out;
z-index: 200;
}
#nav div {
height: 100%;
overflow: hidden;
overflow-y: auto;
position: relative;
}
#nav ul {
padding-top: 90px;
text-align: center;
}
#nav li a:before {
background: #fff;
content: '';
height: 0;
left: -0.5em;
position: absolute;
transition: all 0.2s ease-in-out;
width: 0.25em;
}
#nav li a:hover:before {
height: 100%;
}
}
#media screen and (min-width: 601px) {
/* HIDE the dropdown */
#nav li ul { display: none; }
/* DISPLAY the dropdown */
#nav li:hover > ul {
display: block;
position: absolute;
}
/* Nav */
#nav ul {
background: #260f03;
font-size: 0;
text-align: center;
}
#nav li {
display: inline;
}
#nav li a:hover {
border-bottom: 1px solid #d2b48c;
border-top: 1px solid #d2b48c;
}
}
JS Fiddle (with submenus):https://jsfiddle.net/2v8zhL3e/1/
JS Fiddle (without submenus): https://jsfiddle.net/b0mj7gp4/
I've found a bunch of tutorials on how to do this, but they are all using a float on the li.
I did have a go at it...
I hid the dropdown: #nav li ul { display: none; }
Then I showed it on hover:
#nav li:hover > ul {
display: block;
position: absolute;
}
Which kind of works...but the links show to the left of the main navigation item, I'd like to just tweak this so the links are stacked and show centered under their corresponding header.
I feel like I'm close, can anyone point me in the right direction?
Thanks,
Josh
You can add display: flex to the li:hover ul, then make the flex-direction: column and make the non-hover event position: absolute, left: 0. This creates an issue with the ul child element floating to the far left. So to fix this issue, you need to style its parent to have a relative position. The following should do the trick.
#nav li {
position: relative;
}
#nav li ul {
left: 0;
position: absolute;
}
#nav li:hover > ul {
display: flex;
flex-direction: column;
}
You haven't position: relative in li.
And, it would be better to use position: absolute without hover, in default.
#nav li {
position: relative;
}
#nav li > ul {
position: absolute;
display: none;
}
#nav li:hover > ul {
display: block;
}

How to do margin-top only in Firefox browser

I have menu bar which need to be margin-top: 150px;
But visually in Firefox looking different as on Chrome.
Header code: https://codepen.io/bugerman21/pen/rNxvyOv
Chrome:
Correct display
Firefox:
Incorrect display
HTML:
<nav>
<ul class="nav">
<li class="category"><span>Category <i class="fas fa-sort-down"></i></span>
<ul>
<li>Qwerty 1</li>
<li>Qwerty 2</li>
<li>Qwerty 3</li>
<li>Qwerty 4</li>
</ul>
</li>
<li>Cuntact us</li>
<li>FAQ</li>
</ul>
CSS:
* {
margin: 0;
pading: 0;
}
.nav li ul {
position: absolute;
margin-top: 150px;
min-width: 150px;
list-style-type: none;
display: none;
}
How to do margin-top only for the Firefox browser?
Unsuccessful attempt:
#-moz-document url-prefix() {
.nav li ul {
margin-top: 150px;
}
}
Here ya go buddy, sorry I left for the day yesterday but see the changes made and I left outlines on the elements to give a better visual reference. As it is now it will display as expected on all browsers even old internet explorer. Although you could accomplish the same thing cleaner overall, this at least gets you back on track. Cheers and welcome to StackOverflow! :)
PS : since the nav menu items don't have a fixed height you might want to consider making that something static so you can change the top: 56px to a value that places the drop down consistently no matter the width of the screen. If you make the example full screen you'll see what I mean.
header {
display: flex;
margin: 0;
padding: 0 20px;
justify-content: space-between;
align-items: center;
background-color: silver;
}
.header {
grid-area: header;
background-color: #1f1f1f;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
}
/*---------- Logo ----------*/
.logo {
font-family: 'Gentium Book Basic', serif;
font-size: 2.5em;
color: #808080;
}
/*---------- Nav menu ----------*/
.nav {
list-style-type: none;
display: flex;
justify-content: flex-start;
margin: 0;
}
.nav > li {
text-decoration: none;
font-family: 'Roboto', sans-serif;
color: #ffffff;
transition: background-color .25s ease;
}
.nav a {
display: block;
padding: 20px;
color: #ffffff;
font-size: 1em;
}
.category {
padding: 0 20px;
display: flex;
align-items: center;
position: relative;
overflow: visible;
border: red 1px solid;
}
/*---------- Sub menu ----------*/
.nav li ul {
position: absolute;
top: 56px;
left: 0;
min-width: 150px;
margin: 0;
padding: 0;
list-style-type: none;
display: none;
border: green 1px solid;
}
.nav li > ul li {
border-bottom: 1px solid #ffffff;
background-color: #1f1f1f;
}
.nav li > ul li a {
text-transform: none;
}
.nav li:hover > ul {
display: block;
}
.nav > li:hover {
background-color: #404040;
/* box-shadow: -5px 5px #1f1f1f; */
}
.nav li ul > li:hover {
background-color: #404040;
}
/*---------- Search & Profile----------*/
.search_and_profile {
display: flex;
align-items: center;
}
.search_and_profile > p {
margin: 0;
color: #ffffff;
}
.search-container button {
float: right;
padding: 6px 10px;
background: #e0e0e0;
font-size: 17px;
border: none;
cursor: pointer;
}
.search-container input[type=text] {
padding: 6px;
font-size: 17px;
border: none;
}
<header class="header">
<span class="logo">Qwerty</span>
<nav>
<ul class="nav">
<li class="category"><span>Category <i class="fas fa-sort-down"></i></span>
<ul>
<li><a href=#>Qwerty 1</a></li>
<li>Qwerty 2</li>
<li>Qwerty 3</li>
<li>Qwerty 4</li>
</ul>
</li>
<li>Cuntact us</li>
<li>FAQ</li>
</ul>
</nav><!-- .nav -->
<div class="search_and_profile">
<div class="search-container">
<form action="#">
<input type="text" placeholder="Search.." name="search">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</div><!-- .search-container -->
</div><!-- .search_and_profile -->
</header>
It will work for me, additionally i included color too to make sure.
Also you try this option too
#media screen and (-moz-images-in-menus:0) {
/* your style */
}
* {
margin: 0;
pading: 0;
}
.nav li ul {
position: absolute;
margin-top: 150px;
min-width: 150px;
list-style-type: none;
display: none;
}
/* Added */
#-moz-document url-prefix('') {
.nav li ul {
margin-top: 150px;
color: orange;
}
}
<div class="nav">
<ul>
<li>Home</li>
<li>About
<ul>
<li>Some text</li>
<li>Some more text</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>

How to sequentually increase CSS value for Padding property for Hierarchy structure?

I have hardcoded padding for each of the padding hierarchy level.
I need the solution for any of level without hardcoding padding for each level.
.jdm-nav li {
font-size: 16px;
position: relative;
}
.jdm-nav li a {
padding-left: 15px;
}
.jdm-nav li li a {
padding-left: 30px;
}
.jdm-nav li li li a {
padding-left: 45px;
}
.jdm-nav li li li li a {
padding-left: 60px;
}
li li li li ... a
Every next step could be increased by 15px.
Full code example.
There is the mobile menu with ability to dropdown each item by click dropdown icon in the right item corner. If there are the items to expand.
.jdm-nav {
background-color: white;
width: 100%;
padding: 0;
}
.jdm-nav ul {
padding: 0;
}
.jdm-nav {
list-style: none;
}
.jdm-nav li {
list-style: none;
}
.jdm-nav ul {
margin: 0;
}
.jdm-nav a {
text-align: left;
display: flex;
color: rgb(76, 92, 104);
font-weight: 500;
padding: .5em 0;
font-size: 16px;
border-bottom: 1px solid rgba(76, 92, 104, 0.1);
}
.jdm-nav li {
font-size: 16px;
position: relative !important;
}
.jdm-nav li a {
padding-left: 15px;
}
.jdm-nav li li a {
padding-left: 30px;
}
.jdm-nav li li li a {
padding-left: 45px;
}
.jdm-nav li li li li a {
padding-left: 60px;
}
.jdm-nav li {
position: relative;
}
.jdm-nav li>[data-jdm-sub-menu-switcher] {
font-size: 13px;
display: flex;
width: 100%;
height: 100%;
border-bottom: 1px solid rgba(76, 92, 104, 0.1);
position: relative;
}
.jdm-nav li {
position: relative !important;
}
.jdm-nav li.menu-item-has-children>ul {
max-height: 0;
overflow: hidden;
transition: 150ms max-height ease-out;
}
.jdm-nav li.menu-item-has-children>ul[data-jdm-state="expanded"] {
max-height: initial;
}
.jdm-nav li.menu-item-has-children> :first-child {
grid-column: 1;
}
.jdm-nav li.menu-item-has-children>[data-jdm-sub-menu-switcher] {
grid-column: 2;
}
.jdm-nav li.menu-item-has-children>ul {
grid-row: 2;
grid-column-start: 1;
grid-column-end: 3;
}
.jdm-nav li>[data-jdm-sub-menu-switcher]::after {
position: absolute;
}
.jdm-nav li>[data-jdm-sub-menu-switcher]::after {
position: absolute;
width: 1em;
height: 1em;
content: '';
clip-path: url(#prefix-mobile-dropdown-clip-mask);
font-size: 13px;
background-color: rgb(76, 92, 104);
display: inline-flex;
top: 50%;
right: 50%;
transform: translateY(-50%) translateX(50%);
}
.jdm-nav li.menu-item-has-children {
display: grid;
grid-template-columns: 100fr 15fr;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<div id="prefix-mobile-menu" class="mobile-menu-area prefix-mobile-menu" data-prefix-status="collapsed">
<nav id="mobile-menu" class="jdm-nav">
<ul id="primary-menu" class="menu-overflow">
<li id="menu-item-2420" class="menu-item-has-children">
1
<button data-jdm-sub-menu-switcher=""></button>
<ul class="sub-menu" style="" data-jdm-state="expanded">
<li id="menu-item-2418" class="menu-item-has-children">1.1
<button data-jdm-sub-menu-switcher=""></button>
<ul class="sub-menu" style="" data-jdm-state="expanded">
<li id="menu-item-2434" class="menu-item-has-children">1.1.1
<button data-jdm-sub-menu-switcher=""></button>
<ul class="sub-menu">
<li id="menu-item-2435">
1.1.1.1
</li>
<li id="menu-item-2436">1.1.1.2
</li>
<li id="menu-item-2437">1.1.1.3
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li id="menu-item-1832">2</li>
</ul>
</nav>
<svg width="0" height="0" viewBox="0 0 448 512">
<defs>
<clipPath
viewbox="0 0 448 512"
transform="scale(0.00223, 0.00195)"
clipPathUnits="objectBoundingBox"
id="prefix-mobile-dropdown-clip-mask">
<path fill="#000000"
d="M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"
class=""></path>
</clipPath>
</defs>
</svg>
</div>
Put the padding on the li and stretch the left of the a out by a large fixed amount.
Illustrated:
body > ul {
border: 1px solid #eee;
border-radius: 2px;
margin: 1em;
padding: 1em;
overflow: hidden;
}
ul {
list-style: none;
padding: 0;
}
li {
padding-left: 15px;
}
a {
display: block;
margin-left: -150px;
margin-right: -1em;
padding-left: 150px;
}
a:hover {
background-color: #cff;
}
<ul>
<li>
nested
<ul>
<li>
navigation
<ul>
<li>
forever
<ul>
<li>
and
<ul>
<li>
ever
</ul>
</ul>
</ul>
<li>
foo
<li>
bar
</ul>
<li>
baz
</ul>
(Notice how the clickable area of each link extends all the way to the left.)
you can use this code for solve your problem
.jdm-nav li {
font-size: 16px;
position: relative;
}
.jdm-nav li{
font-size:1.2em;
padding-left: 3em;
}
.jdm-nav li a {
background-color:red;
font-size:16px;
}
<ul class="jdm-nav">
<li>
<a>Item1</a>
<ul>
<li>
<a>Item2</a>
<ul>
<li>
<a>Item3</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
use pseudo function of css to increase the padding of every children by 15px.

Extra padding under menu with child

hey guys I am having a few issues with my menu, theres a weird padding that pushes my menu to the right a few pixels but I managed to fix it on the main parents, originally they were both pushing out the same amount.
Pic
and heres a better view
I am running through my css and adding padding-left:0px;
Heres my code if anyone can assist me.
<div class="css_menu_two_line">
<ul class="two_line_menu">
<li>Menu 1</li><li>
Menu 2</li><li class="current">Menu 3 SHOW
<ul>
<li>Submenu 3-1</li>
<li>Submenu 3-2</li>
<li>Submenu 3-3</li>
<li>Submenu 3-4</li>
<li>Submenu 3-5</li>
</ul>
</li><li>Menu 4</li><li>Menu 5</li>
</ul>
</div>
css:
.css_menu_two_line {
width:100%;
overflow:hidden;
}
.two_line_menu {
padding-left: 0;
position: relative;
margin-bottom: 40px;
background:#77f url('img_bg.gif') repeat-x;
}
.two_line_menu a {
display: block;
color: #fff;
text-decoration: none;
padding:10px;
}
.two_line_menu li:hover a {
color: #fff;
background: #aaf;
}
.current a {
color: #fff;
background: #aaf;
}
.two_line_menu li { display: inline-block; }
.two_line_menu li ul { display: block;
position: absolute;
left: 0;
width: 100%;
background: #aaf;
top: 38px; }
.two_line_menu li:hover ul {
display: block;
position: absolute;
left: 0;
width: 100%;
background: #aaf;
top: 38px;
}
.two_line_menu li ul li:hover a { color: #000; }
fiddle: http://jsfiddle.net/uf2cnakc/
You need to take away the padding from .two_line_menu li ul. To do this we can add the following style padding: 0;.
A lot of HTML elements have default styles, so beware of this.
Your CSS for this class should now look something like this:
.two_line_menu li ul {
display: block;
position: absolute;
left: 0;
width: 100%;
background: #aaf;
top: 38px;
padding: 0; /* Just added */
}
Demo Here
Your CSS contained display:inline which has block child element and position absolute as well. Try this CSS property.
.two_line_menu li { display: block; float:left; }
.two_line_menu li ul{ position:absolute; left:0; padding:0; width:100%; background: #aaf; top:38px; }
.two_line_menu li ul li{ float:left;}

Opacity on hover of parent is being transfered to submenu; how to prevent this using CSS

Right now the parent menu has an opacity shift on hover, this is being transferred to the sub menu (current & previous) as well. I want the sub menu to have a clear background so that the opacity band of the parent is the only thing that is visible. Is there a way to use an li class for the submenu that makes it exempt from the li class that is governing the parent. I've been trying different things but can't seem to make it work properly.
Demo
HTML
<div>
<ul id="mainmenu">
<li class="liHome">
<a class="maintextcolour" href="#item-x1y1" id="Home" rel=
"none">INFO</a>
</li>
<li class="liServices">
<a class="maintextcolour" href="#item-x1y2" id="Services" rel=
"SubMenuY2">EXHIBITIONS</a>
<ul class="submenu" id="SubMenuY2">
<li class="sub1">
<a class="maintextcolour" href="#">CURRENT</a>
</li>
<li class="sub1">
<a class="maintextcolour" href="#">PREVIOUS</a>
</li>
</ul>
</li>
<li id="liEnvironment">
<a class="maintextcolour" href="#item-x1y3" id="Environment"
rel="none">CV</a>
</li>
<li id="liCareer">
<a class="maintextcolour" href="#item-x1y4" id="Career" rel=
"none">NEWS</a>
</li>
<li id="liContact">
<a class="maintextcolour" href="#item-x1y5" id="Contact" rel=
"none">MORE</a>
</li>
</ul>
</div>
CSS:
#charset UTF-8;
/* CSS Document */
body {
background-color: #666;
background-size: 100%;
background-repeat: no-repeat;
}
#mainmenu {
margin: 0;
padding: 0;
list-style-type: none;
position: relative;
}
#mainmenu li {
clear: left;
position: relative;
}
#mainmenu a {
display: block;
overflow: hidden;
float: left;
width: 100%;
position: relative;
opacity: 1;
-webkit-transition: all .4s ease-in-out;
padding-left: 20px;
}
#mainmenu li:hover a {
background-position: 0 0;
background-color: clear;
background-color: rgba(255,255,255,0.5);
width: 100%;
opacity: 0;
-webkit-transition: none;
}
#mainmenu li.active a {
background-position: 0 0;
background-color: clear;
width: 100%;
}
.submenu {
list-style-type: none;
float: left;
display: none;
position: absolute;
left: 135px;
top: 0;
width: auto;
}
#mainmenu li a:hover + .submenu,.submenu:hover {
display: block;
}
.submenu li {
display: inline-block;
clear: none !important;
}
.submenu li a {
float: right;
margin-left: 10px;
}
.maintextcolour {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
color: #FFF;
text-decoration: none;
}
.maintextcolour:hover {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
color: #0FF;
text-decoration: none;
}
.headertext {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #FFF;
text-decoration: none;
}
Here is the updated Fiddle link. I have just added color to the following css:
#mainmenu > li:hover > a {
background-position: 0 0;
background-color:clear;
color:#0fffff;
background-color:rgba(255,255,255,0.5);
width:100%;
\
opacity: 0;
-webkit-transition: none;
}
Hope you want this.

Resources