How to add image on hover in <li>::after - html

I want a structure like this on <li> hover (Blue down arrow on center of every li)
But I'm unable to make this because i thought i will use this blue image as pseudo elements ::after but i have added ":" in between two <li>.
This is my html code :
<div class="quick-links col-md-12">
<p class="left" style="font-weight:600;font-family:calibri;">Go quickly
to</p>
<i class="fa fa-arrow-circle-right" style="color:#2ca5fa;padding:0px 3px 0px 12px;"></i>
<ul class="quick-ul">
<li>Mobiles</li>
<li>Sports</li>
<li>Tablets</li>
<li>Bath Towels</li>
<li>LED Bulbs</li>
<li>TV</li>
<li>Washing Machines</li>
<li>Laptops</li>
<li>Headphones</li>
<li>Fans</li>
<li>Travel</li>
<li>Books</li>
</ul>
</div>
This is my CSS code :
.quick-links {
height: 52px;
background-color: white;
margin-top: 20px;
display: inline-table;
padding-top: 13px;
border-top: 4px solid #0096ff;
}
.left {
float: left;
}
.quick-ul {
float: right;
display: inline-flex;
}
.quick-ul li {
font-family: calibri;
padding-right: 39px;
position: relative;
margin-left: -34px;
font-size: 15px;
}
.quick-ul li>a {
color: black;
}
.quick-ul li>a:hover {
color: #0096ff;
}
.quick-ul li::after {
content: ":";
color: black;
padding-left: 10px;
padding-right: 10px;
font-weight: 100 !important;
}
.quick-ul li:nth-last-child(1)::after{
content: "";
}
Any Kind of help would be highly appreciated.

All you need is this rule
.quick-ul li>a:hover::after
content: "\25bc";
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, -100%) scaleX(2);
color: #0096ff;
font-size: 20px;
}
It will add a filled arrow character using the pseudo ::after, that is easily colored and sized as any other character. The translate moves it into place and the scaleX makes it a little wider.
Stack snippet
.quick-links {
height: 52px;
background-color: white;
margin-top: 20px;
display: inline-table;
border-top: 4px solid #0096ff;
}
.left {
float: left;
}
.quick-ul {
float: right;
display: inline-flex;
list-style: none; /* added property */
}
.quick-ul li {
font-family: calibri;
padding-right: 39px;
position: relative;
margin-left: -34px;
font-size: 15px;
}
.quick-ul li>a {
color: black;
}
.quick-ul li>a:hover {
position: relative; /* added property */
color: #0096ff;
}
.quick-ul li>a:hover::after { /* added rule */
content: "\25bc";
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, -100%) scaleX(2);
color: #0096ff;
font-size: 20px;
}
.quick-ul li::after {
content: ":";
color: black;
padding-left: 10px;
padding-right: 10px;
font-weight: 100 !important;
}
.quick-ul li:nth-last-child(1)::after {
content: "";
}
<div class="quick-links col-md-12">
<p class="left" style="font-weight:600;font-family:calibri;">Go quickly to
</p>
<i class="fa fa-arrow-circle-right" style="color:#2ca5fa;padding:0px 3px 0px 12px;"></i>
<ul class="quick-ul">
<li>Mobiles</li>
<li>Sports</li>
<li>Tablets</li>
<li>Bath Towels</li>
<li>LED Bulbs</li>
<li>TV</li>
</ul>
</div>

Try this.
.quick-links {
height: 52px;
background-color: white;
margin-top: 20px;
display: inline-table;
padding-top: 0;
border-top: 4px solid #0096ff;
}
.left {
float: left;
}
.quick-ul {
list-style: none;
float: right;
display: inline-flex;
}
.quick-ul li {
font-family: calibri;
font-size: 15px;
position: relative;
}
.quick-ul li>a {
color: black;
position: relative;
}
.quick-ul li>a:hover {
color: #0096ff;
}
.quick-ul li::after {
content: ":";
color: black;
padding-left: 10px;
padding-right: 10px;
font-weight: 100 !important;
}
.quick-ul li:nth-last-child(1)::after {
content: "";
}
/* additional styles */
.quick-ul li a::before {
content: "";
position: absolute;
top: -17px;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
border-top: 10px solid #0096ff;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
opacity: 0;
transition: all ease 0.15s;
}
.quick-ul li:hover a::before {
opacity: 1;
}
<div class="quick-links col-md-12">
<p class="left" style="font-weight:600;font-family:calibri;">Go quickly to
</p>
<i class="fa fa-arrow-circle-right" style="color:#2ca5fa;padding:0px 3px 0px 12px;"></i>
<ul class="quick-ul">
<li>Mobiles</li>
<li>Sports</li>
<li>Tablets</li>
<li>Bath Towels</li>
<li>LED Bulbs</li>
</ul>
</div>

This code should work for you:
.quick-links {
height: 52px;
background-color: white;
margin-top: 20px;
border-top: 4px solid #0096ff;
text-align: center;
padding: 0px !important;
}
.left {
float: left;
}
.quick-ul {
list-style: none;
display: flex;
justify-content: center;
margin: 0px;
box-sizing: border-box;
}
.quick-ul li {
position: relative;
font-family: Arial;
padding: 0px;
font-size: 15px;
margin: 0px 1px;
display: inline;
box-sizing: border-box;
}
.quick-ul li:not(:last-child)::before {
content: ":";
position: absolute;
top: 30%;
right: 0px;
height: 100%;
width: auto;
}
.quick-ul li>a {
display: block;
width: 100%;
height: 100%;
color: blue;
padding: 12px 18px 0px;
box-sizing: border-box;
position: relative;
}
.quick-ul li>a:hover {
color: #0096ff;
}
.quick-ul li > a::after {
display: block;
content: "";
color: blue;
padding-left: 10px;
padding-right: 10px;
font-weight: 100 !important;
transform: rotate(90deg);
transform: translateX(-50%) rotate(90deg);
margin-top: -5px;
font-size: 18px;
position: absolute;
top: 0px; left: 50%;
transition: all 0.3s ease-in-out;
}
.quick-ul li>a:hover::after {content: '\25B6'}
<div class="quick-links col-md-12">
<ul class="quick-ul">
<li>Mobiles</li>
<li>Sports</li>
<li>Tablets</li>
</ul>

Related

Responsive menu horizontal to vertical and viceversa

I like to create a menu only with HTML and CSS to use in my web application that:
some items could have sub menus
it is responsive
use a hamburger for mobile
could be switch between horizontal and vertical on desktops
For example, I have this horizontal menu at the top of the page
enter image description here
from this code (you can see the result in the full screen)
:root {
--main-bg-color: #000;
--main-txt-color: #FFF;
--hover-color: #fada04;
--mobile-bg-color: #f6f6f6;
--mobile-bg-color-level2: #fff;
--mobile-txt-color: #666;
--g1: #FDE100;
--g2: #D6A71D;
}
.menu-toggle {
display: block;
}
.headermenu {
padding: 8px 0;
vertical-align: sub;
letter-spacing: 1px;
margin: 0 0 0px 0;
display: block;
height: 26px;
width: auto;
clear: both;
z-index: 999;
}
.headermenu ul {
padding: 0;
margin: 0;
width: 100%;
float: left;
position: relative;
background-color: var(--main-bg-color);
list-style: none;
}
.top-menu li.active {
background-image: linear-gradient(var(--g1), var(--g2));
}
.top-menu li.active>a {
color: var(--main-txt-color);
}
.top-menu li {
position: relative;
background: var(--main-bg-color);
white-space: nowrap;
*white-space: normal;
-webkit-transition: background .2s;
transition: background .2s;
}
.top-menu ul {
position: absolute;
display: none;
top: 100%;
left: 0;
z-index: 999;
box-shadow: 2px 2px 6px rgba(0, 0, 0, .2);
min-width: fit-content;
}
.top-menu>li {
float: left;
}
.top-menu li:hover>ul {
display: block;
}
.top-menu a {
display: block;
position: relative;
padding: .75em 1em;
text-decoration: none;
color: var(--main-txt-color);
}
.top-menu a:hover {
color: var(--hover-color);
}
.top-menu ul ul {
top: 0;
left: 100%;
}
.top-menu .sf-with-ul {
padding-right: 2.5em;
*padding-right: 1em;
}
.top-menu .sf-with-ul:after {
content: '';
position: absolute;
top: 50%;
right: 1em;
margin-top: -3px;
height: 0;
width: 0;
border: 5px solid transparent;
border-top-color: rgba(255, 255, 255, .5);
}
.top-menu>li>.sf-with-ul:focus:after,
.top-menu>li:hover>.sf-with-ul:after {
border-top-color: white;
}
.top-menu ul .sf-with-ul:after {
margin-top: -5px;
margin-right: -3px;
border-color: transparent;
border-left-color: rgba(255, 255, 255, .5);
}
.top-menu ul li>.sf-with-ul:focus:after,
.top-menu ul li:hover>.sf-with-ul:after {
border-left-color: white;
}
.mobile-menu,
.hamburger {
display: none;
}
ul.top-menu.mobile {
display: none;
}
/* --- mobile (20201207 SDE)*/
#media all and (max-width: 1000px) {
element.style {
display: block;
}
.top-menu li.active {
background-image: initial;
}
.top-menu li.active>a {
color: initial;
}
ul {
list-style: none;
}
.headermenu ul {
padding: initial;
margin: initial;
width: initial;
float: initial;
position: initial;
background-color: initial;
list-style: none;
}
.top-menu li {
position: initial;
background: initial;
white-space: initial;
*white-space: initial;
-webkit-transition: initial;
transition: initial;
}
.top-menu ul {
position: initial;
display: initial;
top: initial;
left: initial;
z-index: initial;
box-shadow: initial;
min-width: initial;
}
/* .top-menu > li {
float: initial;
}*/
.top-menu>li {
float: initial;
/*margin: 1px 0;*/
border: 1px;
position: relative;
background-color: var(--mobile-bg-color);
/*background-color: #f6f6f6;*/
}
.top-menu li:hover>ul {
display: none;
}
.top-menu a:hover {
color: initial;
}
.menu-toggle {
display: block;
color: #fff;
padding: 15px;
font-size: 35px;
cursor: pointer;
font-weight: bold;
text-transform: uppercase;
background: #151515;
}
.sublist-toggle {
top: 0;
right: 0;
color: #fff;
width: 55px;
height: 55px;
padding: 15px;
cursor: pointer;
font-size: 15px;
font-weight: bold;
position: absolute;
text-transform: uppercase;
border-left: 1px solid #fff;
background: url(images/toggle-black.png) center no-repeat;
}
.top-menu {
display: none;
}
.top-menu>li {
float: initial;
position: relative;
background-color: var(--mobile-bg-color);
}
.top-menu .sublist {
display: none;
padding: 5px 0;
background-color: #fff;
}
.top-menu a {
color: #666;
padding: 18px;
display: block;
font-size: 25px;
text-decoration: none;
}
.top-menu .sublist li {
position: relative;
margin: 1px 0 1px 20px;
}
.sf-with-ul {
cursor: pointer;
}
/* BEOF Hamburger */
.hamburger {
padding: 15px 15px 0px 0px;
display: inline-block;
cursor: pointer;
transition-property: opacity, filter;
transition-duration: 0.15s;
transition-timing-function: linear;
font: inherit;
color: inherit;
text-transform: none;
background-color: transparent;
border: 0;
margin: 0;
overflow: visible;
float: right;
}
.hamburger:hover {
opacity: 0.7;
}
.hamburger.is-active:hover {
opacity: 0.7;
}
.hamburger.is-active .hamburger-inner,
.hamburger.is-active .hamburger-inner::before,
.hamburger.is-active .hamburger-inner::after {
background-color: #000;
}
.hamburger-box {
width: 40px;
height: 24px;
display: inline-block;
position: relative;
vertical-align: top;
}
.hamburger-inner {
display: block;
top: 50%;
margin-top: -2px;
}
.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
width: 40px;
height: 4px;
background-color: white;
border-radius: 4px;
position: absolute;
transition-property: transform;
transition-duration: 0.15s;
transition-timing-function: ease;
}
.hamburger-inner::before,
.hamburger-inner::after {
content: "";
display: block;
}
.hamburger-inner::before {
top: -10px;
}
.hamburger-inner::after {
bottom: -10px;
}
/* EOF Hamburger */
}
<ul class="top-menu">
<li class="active">Home</li>
<li><a class="sf-with-ul" href="/jeans">Jeans</a>
<div class="sublist-toggle"></div>
<ul class="sublist">
<li style="">Wide leg jeans</li>
<li style="">Straight jeans</li>
<li style="">Loose jeans</li>
</ul>
</li>
<li><a class="sf-with-ul" href="/shorts">Shorts</a>
<div class="sublist-toggle"></div>
<ul class="sublist">
<li style=""><a class="sf-with-ul" href="/sweet_jersey">Sweet jersey shorts</a>
<div class="sublist-toggle"></div>
<ul class="sublist">
<li style="">Jersey1</li>
<li style="">Jersey2</li>
</ul>
</li>
<li style="">Denim shorts</li>
</ul>
</li>
<li>Skirts</li>
<li>Blazers</li>
</ul>
I can't find a way to transform the menu above in vertical menu like this one
enter image description here
I have done a bit of the basics to point you in the right direction. You can build on this to make it responsive, hamburger, etc...
The menu should have this format. The submenu is nested in the list element of the parent. The span in the parent is the button we click to open the submenu. Each submenu parent has a corresponding span with a unique incremental id.
<div class="sidemenu">
<ul class="top">
<li>Home</li>
<li class="toggle">Jeans<span id="span1" onclick="openSub(1)">+</span>
<ul id="sub1">
<li>Wide</li>
<li>Straight</li>
<li>Loose</li>
</ul>
</li>
<li class="toggle">Shorts<span id="span2" onclick="openSub(2)">+</span>
<ul id="sub2">
<li>Sweet<span id="span3" onclick="openSub(3)">+</span>
<ul id="sub3">
<li>Jersey1</li>
<li>Jersey2</li>
</ul>
</li>
<li>Denim</li>
</ul>
</li>
<li>Skirts</li>
<li>Blazers</li>
</ul>
</div>
We will have to use JS to open and close the submenus when the correct span is clicked.
The first 6 lines hide the submenus by default when the page is loaded.
The openSub() function takes a number representing the submenu we want to open (1 for jeans, 2 for shorts, etc...)
The function then identifies the submenu we want to open, and toggles it to display. The next line changes the text of the span from "+" to "-" to represent an open submenu. If the span is clicked again, the submenu is closed and the text goes back to its default.
var toggle = document.getElementById("sub1");
toggle.style.display = "none";
var toggle = document.getElementById("sub2");
toggle.style.display = "none";
var toggle = document.getElementById("sub3");
toggle.style.display = "none";
function openSub(caller) {
var toggle = document.getElementById("sub"+caller);
toggle.style.display = toggle.style.display === 'none' ? '' : 'none';
document.getElementById("span"+caller).textContent = document.getElementById("span"+caller).textContent === "+" ? '-' : '+';
}
CSS used mostly for styling:
.sidemenu {
width: 250px;
height: 100vh;
background: lightblue;
}
ul.top {
list-style-type: none;
}
ul.top li {
width: 100%;
height: auto;
min-height: 50px;
margin: 10px 0;
padding: 20px 0 0 10px;
}
ul.top li span {
float: right;
}
#sub1, #sub2, #sub3 {
margin-top: 25px;
padding-left: 15px;
}
li {
width: 100%;
height: 50px;
}
span {
padding-right: 25px;
}

CSS process flow arrows - bad formatting?

I modified 3 different peoples code to make css arrows and I think I made it more complicated than it needs to be. Any CSS expert than can help me clean this up?
I can't seem to modify padding and other attributes to get this where I want it within the divs.
css
<style>
/* These are the Stage Arrows - styles */
#testStatus {
position: relative;
width: auto;
height: 30px;
left: 10px;
}
.testStatus li {
position: relative;
text-indent: 10px;
height: 30px;
display: inline-block;
zoom: 1;
margin-left: -3px;
padding: 10px 10px 10px 10px;
color: white;
font-size: 12px;
text-align: center;
line-height: auto;
}
ul.testStatus {
list-style: none;
}
li.testStatus:first-child:after, li.testStatusGood:after, li.testStatusNoGood:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-top: 15px solid transparent;
border-left: 10px solid #767676;
border-bottom: 15px solid transparent;
margin: -10px 0px 0px 10px;
z-index: 3;
}
li.testStatus:last-child:before, li.testStatusGood:before, li.testStatusNoGood:before {
content: "";
position: absolute;
width: 0;
height: 0;
left: 0;
border-top: 15px solid transparent;
border-left: 10px solid #EEEEEE;
border-bottom: 15px solid transparent;
margin: -10px 0px 0px 0px;
z-index: 2;
}
li.testStatus:first-child {
padding-left: 10px;
margin-left: 0;
background-color: #767676;
}
li.testStatus:last-child {
padding-right: 10px;
background-color: #767676;
}
li.testStatusGood {
background-color: #77a942;
}
li.testStatusGood:after {
border-left: 10px solid #77a942;
}
li.testStatusNoGood {
background-color: #c42c00;
}
li.testStatusNoGood:after {
border-left: 10px solid #c42c00;
}
/* End arrow formatting */
</style>
html
<ul>
<li>
<div id="testStatus">
<ul class="testStatus">
<li class="testStatus">Step 1</li>
<li class="testStatusGood">Step 2</li>
<li class="testStatusNoGood">Step 3</li>
<li class="testStatusNoGood">Step 4</li>
<li class="testStatus">Step 5</li>
</ul>
</div>
</li>
</ul>
My arrows display nicely but I am having difficulty adjusting the padding to 0. I've tried the #, the ul class, the il class and I am a bit baffled why I cannot remove the 10px (I believe its the padding).
There is also a faintly darker border on the left side of the triangular portion of the arrows, if you look closely, that I'd like to have match the color exactly.
Duo's code output above image, Ojer code output below image
I'm going backwards :)
Here you go:
.breadcrumbs {
border: 1px solid #cbd2d9;
border-radius: 0.3rem;
display: inline-flex;
overflow: hidden;
}
.breadcrumbs__item {
background: #fff;
color: #333;
outline: none;
padding: 0.75em 0.75em 0.75em 1.25em;
position: relative;
text-decoration: none;
transition: background 0.2s linear;
}
.breadcrumbs__item:hover:after,
.breadcrumbs__item:hover {
background: #edf1f5;
}
.breadcrumbs__item:focus:after,
.breadcrumbs__item:focus,
.breadcrumbs__item.is-active:focus {
background: #323f4a;
color: #fff;
}
.breadcrumbs__item:after,
.breadcrumbs__item:before {
background: white;
bottom: 0;
clip-path: polygon(50% 50%, -50% -50%, 0 100%);
content: "";
left: 100%;
position: absolute;
top: 0;
transition: background 0.2s linear;
width: 1em;
z-index: 1;
}
.breadcrumbs__item:before {
background: #cbd2d9;
margin-left: 1px;
}
.breadcrumbs__item:last-child {
border-right: none;
}
.breadcrumbs__item.is-active {
background: #edf1f5;
}
/* Some styles to make the page look a little nicer */
body {
color: #323f4a;
background: #f5f7fa;
display: flex;
align-items: center;
justify-content: center;
}
html, body {
height: 100%;
}
.gray{
background-color:gray;
}
.breadcrumbs__item.gray:after{
background-color:gray;
}
.red{
background-color:red;
}
.breadcrumbs__item.red:after{
background-color:red;
}
.green{
background-color:green;
}
.breadcrumbs__item.green:after{
background-color:green;
}
<li class="breadcrumbs">
Prospect
Opportunity
Accound
Sales
Support
</li>
This can work for you.
Check this Pen
HTML:
<ul class="steps">
<li class="past">
<span>
<strong>Step 1</strong>
</span><i></i>
</li>
<li class="present">
<span>
<strong>Step 2</strong>
</span><i></i>
</li>
<li class="future">
<span>
<strong>Step 3</strong>
</span><i></i>
</li>
<li class="future1">
<span>
<strong>Step 4</strong>
</span><i></i>
</li>
<li class="present1">
<span>
<strong>Step 5</strong>
</span><i></i>
</li>
</ul>
CSS:
.steps {
padding-left: 0;
list-style: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
line-height: 1;
margin: 30px auto;
border-radius: 3px;
}
.steps strong {
font-size: 14px;
display: block;
line-height: 2.1;
}
.steps > li {
position: relative;
display: block;
/* border: 1px solid #ddd; */
padding: 12px 50px 8px 50px;
width: 140px;
height: 40px;
}
#media (min-width: 768px) {
.steps > li {
float: left;
}
.steps .past {
color: #fff;
background: blue;
}
.steps .present {
color: #000;
background: yellow;
}
.steps .future {
color: #fff;
background: green;
}
.steps .present1 {
color: #000;
background: red;
}
.steps .future1 {
color: #fff;
background: purple;
}
.steps .present1 {
color: #fff;
}
.steps li > span:after,
.steps li > span:before {
content: "";
display: block;
width: 0px;
height: 0px;
position: absolute;
top: 0;
left: 0;
border: solid transparent;
border-left-color: #f0f0f0;
border-width: 30px;
}
.steps li > span:after {
top: -4px;
z-index: 1;
border-left-color: white;
border-width: 34px;
}
.steps li > span:before {
z-index: 2;
}
.steps li.past + li > span:before {
border-left-color: blue;
}
.steps li.present + li > span:before {
border-left-color: yellow;
}
.steps li.future + li > span:before {
border-left-color: green;
}
.steps li.future1 + li > span:before {
border-left-color: purple;
}
.steps li:first-child > span:after,
.steps li:first-child > span:before {
display: none;
}
/* Arrows at start and end */
.steps li:first-child i,
.steps li:last-child i {
display: block;
position: absolute;
top: 0;
left: 0;
border: solid transparent;
border-left-color: white;
border-width: 30px;
}
.steps li:last-child i {
left: auto;
right: -30px;
border-left-color: transparent;
border-top-color: white;
border-bottom-color: white;
}
}

How to align the menu to the right side of the desktop?

I am have a menu for my website and which is currently align on the left side of the browser. I am try to align on the right side of the browser.
here is the demo: here
what I want is just put the hole menu and align it on the right side of the browser screen. currently its showing on the left side.
trying to do:https://i.stack.imgur.com/D0y00.png
html code:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<header>
<span class="toggle-button">
<div class="menu-bar menu-bar-top"></div>
<div class="menu-bar menu-bar-middle"></div>
<div class="menu-bar menu-bar-bottom"></div>
</span>
<div class="menu-wrap">
<div class="menu-sidebar">
<ul class="menu">
<li>Home</li>
<li class="children">News
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li class="children">Contact
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li class="children">About
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li>FAQ</li>
<li>Services</li>
</ul>
</div>
</div>
</header>
<div class="wrapper" style="background-color:;padding:15px;">
<section class="text" style="background-color:;">
<h2 class="heading" id="headings" style="background-color:;text-align:center;">Three Line Menu & CSS Transitions</h2>
<p class="buttons" style="min-width: 200px;margin:auto;background-color:;text-align:center;">
Learn More
</p>
</section>
</div>
CSS:
html {
background: url(https://s33.postimg.cc/tm1vd9yy7/Background_2.jpg);
background-attachment:fixed;
background-repeat: no-repeat;
background-size: cover;
}
.btn_one {
text-decoration: none;
color: white;
font-weight: 100;
border: 1px #fbbc05 solid;
padding: 1em 3em;
border-radius: 100px;
}
a {
text-decoration: none;
}
ul {
padding-left: 0;
}
li {
list-style: none;
}
* {
box-sizing: border-box;
}
body {
font-family: 'Montserrat', Arial, serif;
}
::selection {
background-color: #EBEBF2;
color: #83828D;
}
/* ==================================== */
/* Navigaton Menu */
/* ==================================== */
.menu-wrap {
background-color: #625871;
position: fixed;
top: 0;
height: 100%;
width: 280px;
margin-left: -280px;
font-size: 1em;
font-weight: 700;
overflow: auto;
transition: .25s;
z-index: 10;
}
.menu-show {
margin-left: 0;
box-shadow: 4px 2px 15px 1px #262424;
}
.menu-sidebar {
margin: 75px 0 80px 10px;
position: relative;
top: 70px;
}
.menu-sidebar li {
padding: 18px 22px 0;
}
.menu-sidebar li > a {
color: #f3f3f3;
font-size: 1.18em;
position: relative;
}
.menu-sidebar li > a::after {
content: "";
display: block;
height: 0.15em;
position: absolute;
top: 100%;
width: 100%;
left: 50%;
transform: translate(-50%);
background-image: linear-gradient(to right, transparent 50.3%, #FFFA3B 50.3%);
transition: background-position .2s .1s ease-out;
background-size: 200% auto;
}
.menu-sidebar li > a:hover::after {
background-position: -100% 0;
}
.menu-sidebar .children {
position: relative;
}
.menu-sidebar .children .child-menu {
display: none;
}
.arrow::after {
content: "\f107";
font-family: 'FontAwesome';
padding: 10px;
color: #FFFA3B;
position: relative;
}
.arrow:hover::after {
cursor: pointer;
color: #fff;
}
.arrow:active::after {
top: 2px;
}
/*Hamburger Button*/
.toggle-button {
position: fixed;
width: 44px;
height: 40px;
top: 50px;
left: 40px;
padding: 4px;
transition: .25s;
z-index: 15;
}
.toggle-button:hover {
cursor: pointer;
}
.toggle-button .menu-bar {
position: absolute;
border-radius: 2px;
transition: .5s;
}
.toggle-button .menu-bar-top {
border: 4px solid #fff;
border-bottom: none;
top: 0;
width: 80%;
}
.toggle-button .menu-bar-middle {
height: 4px;
background-color: #fff;
margin-top: 7px;
margin-bottom: 7px;
width: 40%;
top: 4px;
}
.toggle-button .menu-bar-bottom {
border: 4px solid #fff;
border-top: none;
top: 22px;
width: 60%;
}
.toggle-button:hover div
{
width: 80%;
}
.button-open {
left: 25px;
}
.button-open .menu-bar-top {
border-color: #fff;
transform: rotate(45deg) translate(8px, 8px);
transition: .5s;
}
.button-open .menu-bar-middle {
background-color: #fff;
transform: translate(230px);
transition: .1s ease-in;
opacity: 0;
}
.button-open .menu-bar-bottom {
border-color: #fff;
transform: rotate(-45deg) translate(7px, -7px);
transition: .5s;
}
/* Text Block */
.wrapper {
width: 40%;
margin: 100px auto 0;
color: #83828D;
}
.wrapper .text {
padding: 30px;
}
.wrapper .text .heading {
margin-bottom: 40px;
font-size: 2em;
color:#fff;
}
.wrapper .text p {
line-height: 1.6em;
}
.wrapper .text .buttons {
margin-top: 40px;
}
/* Buttons */
.wrapper .buttons .button {
display: inline-block;
margin-right: 20px;
padding: 20px 25px;
border-radius: 2em;
background-color: #70CE64;
color: #fff;
font-size: .9em;
font-weight: 700;
transition: background-color .3s;
}
.wrapper .buttons .button-secondary {
background-color: #FF6746;
}
.wrapper .buttons .button-primary:hover {
background-color: #84D07A;
}
.wrapper .buttons .button-secondary:hover {
background-color: #FF7D60;
}
/*Active state for the buttons*/
.wrapper .buttons .button-primary:active {
background-color: #70CE64;
}
.wrapper .buttons .button-secondary:active {
background-color: #FF6746;
}
/*Icons*/
.wrapper .buttons .button span {
position: relative;
display: inline-block;
padding-right: 20px;
}
.wrapper .buttons .button span::after {
position: absolute;
font-family: "FontAwesome";
right: -3px;
font-size: 14px;
top: 0;
transition: top .3s, right .3s;
}
.wrapper .buttons .button-primary span::after {
content: "\f019";
}
.wrapper .buttons .button-secondary span::after {
content: "\f178";
}
/*Slight icons animation*/
.wrapper .buttons .button-primary:hover span::after {
top: 4px;
}
.wrapper .buttons .button-secondary:hover span::after {
right: -6px;
}
#media screen and (max-width: 480px) {
#headings{
margin-bottom:20px;
font-size: 18px;
color:#fff;
}
.btn_one {
text-decoration: none;
color: #fff;
font-size:12px;
font-weight: 100;
border: 1px #fbbc05 solid;
padding: 8px 23px;
border-radius: 100px;
}
ul {
padding-left: 35px;
}
.menu-sidebar li
{
padding:0;
}
.menu-wrap {
width: 200px;
}
}
SCRIPT:
$(document).ready(function() {
var $toggleButton = $('.toggle-button'),
$menuWrap = $('.menu-wrap'),
$sidebarArrow = $('.arrow');
// Hamburger button
$toggleButton.on('click', function() {
$(this).toggleClass('button-open');
$menuWrap.toggleClass('menu-show');
});
// Sidebar navigation arrows
$sidebarArrow.click(function() {
$(this).next().slideToggle(300);
});
});
Here is the source code for reference: https://nofile.io/f/9bKHsuOoUza/source_code_new.zip
Can anybody guide me? Any input is appreciated.
Thank you so much.
change the toggle button to:
default:
.toggle-button {
position: fixed;
width: 44px;
height: 40px;
top: 50px;
left: auto;
padding: 4px;
transition: .25s;
z-index: 15;
right: 40px;
}
open:
.button-open {
left: auto;
right: 25px;
}
then change the menu to:
closed:
.menu-wrap {
background-color: #00000030;
position: fixed;
top: 0;
height: 100%;
width: 240px;
margin-left: 0;
right: -280px;
font-size: 1em;
font-weight: 700;
overflow: auto;
transition: .25s;
z-index: 10;
left: auto;
}
open:
.menu-show {
left: auto;
right: 0;
margin-left: 0;
box-shadow: 4px 2px 15px 1px #080707;
}
easy as that!

Pseudo Element Not displaying in nth-child

I was playing around with a little nav menu and pseudo elements and I was wondering why the tiny light orange square I have created displays on the first child element but not the other elements when it is copied over and put in the nth-child(2).
body {
margin: 0;
}
* {
margin: 0;
padding: 0;
}
#orangeNavBar {
height: 45px;
width: 627px;
background-color: #E87966;
margin-left: auto;
margin-right: auto;
margin-top: 15px;
}
ul {
list-style: none;
}
ul li {
float: left;
font-family: times new roman;
font-size: 1.1em;
font-weight: bold;
color: black;
height: 45px;
box-sizing: border-box;
padding: 10px 20px;
border: 1px solid black;
}
ul li:first-child::after {
content: "";
height: 8px;
width: 8px;
background: #F1BAAF;
display: block;
float: right;
position: relative;
left: 20px;
top: 7.5px;
}
ul li:nth-child(2)::after {
content: "";
height: 8px;
width: 8px;
background: #F1BAAF;
display: block;
float: right;
position: relative;
left: 20px;
top: 7.5px;
}
<div id="orangeNavBar">
<ul>
<li>Home</li>
<li>Products</li>
<li>Company</li>
<li>Contact</li>
</ul>
</div>
Because
ul li:nth-child(2)::after
only selects the second item
You need
ul li:nth-child(n+2)::after
so each child after the first one is selected.
body {
margin: 0;
}
* {
margin: 0;
padding: 0;
}
#orangeNavBar {
height: 45px;
background-color: #E87966;
margin-left: auto;
margin-right: auto;
margin-top: 15px;
}
ul {
list-style: none;
}
ul li {
float: left;
font-family: times new roman;
font-size: 1.1em;
font-weight: bold;
color: black;
height: 45px;
box-sizing: border-box;
padding: 10px 20px;
border: 1px solid black;
}
ul li:first-child::after {
content: "";
height: 8px;
width: 8px;
background: #F1BAAF;
display: block;
float: right;
position: relative;
left: 20px;
top: 7.5px;
}
ul li:nth-child(n+2)::after {
content: "";
height: 8px;
width: 8px;
background: #F1BAAF;
display: block;
float: right;
position: relative;
left: 20px;
top: 7.5px;
}
<div id="orangeNavBar">
<ul>
<li>Home</li>
<li>Products</li>
<li>Company</li>
<li>Contact</li>
</ul>
</div>

How to display (<li>) menu items over divs - z-index not working

I am using a ul & li a bit like a select dropdown to trigger a JS function (not shown).
It's working fine - except the menu items appear BEHIND divs that are shown below them.
I've mocked up the problem here: http://jsfiddle.net/bf8ugef7/1/
I'm fiddling with z-index and position:absolute but can't see how to make it work.
Can anyone help?
Here is the HTML and CSS:
body {
font-family: sans-serif;
color: gray;
font-weight: 100;
}
div, li {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
li {
color: #333333;
text-decoration: none;
/* background-image: url("images/mullion.gif"); */
}
div.images {
border: 1px solid #555555;
/* padding-left: 5px; */
width: 100%;
float: left;
clear: left;
margin-bottom: 20px;
/*
background-image: url("images/iMullion.gif");
background-repeat: no-repeat;
*/
}
div.lowerText {
width: 100%;
}
div.btn {/* +filter */
float: right;
width: 195px;
cursor: default;
text-align: right;
/* margin-left: 1px; */
display: inline-block;
}
div.btn1 {
float: left;
width: 153px;
cursor: default;
text-align: center;
margin-left: 1px;
display: inline-block;
position: absolute;
color: black;
background-color: #79c1ee;
left: 182px;
}
div.btn2 {
float: left;
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
background-color: white;
cursor: default;
position: absolute;
left: 162px;
z-index: 100;
}
div.btn2 ul {
list-style: none;
position: absolute;
display: block;
margin: 0px;
padding: 0px;
z-index: 100;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
margin-top: 1px;
z-index: 100;
}
div.btn2 ul li:first-child {
margin-top: 0px;
display: inline-block;
width: 20px;
z-index: 100;
}
div.btn2 ul:hover {
height: 200px;
}
div.btn2 ul:hover li {
display: block;
z-index: 100;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
z-index: 100;
}
/*
div.btn2 ul li:hover {
display: block;
width: 20px;
height: 100px;
}
*/
div.btn3 {
margin-left: 1px;
float: left;
width: 20px;
display: inline-block;
vertical-align: top;
text-align: center;
font-weight: 400;
color: white;
background-color: #13A3E2;
position: absolute;
left: 336px;
cursor: pointer;
}
div.btn3:hover {
background-color: red;
}
div.btn4 {
/* border: 1px solid black; */
padding-left: 5px;
float: left;
width: 153px;
display: inline-block;
color: #444444;
cursor: default;
background-color: white;
}
div.attr {
padding-left: 5px;
color: #444444;
background-color: #79C1ED;
float: right;
clear: none;
display: inline-block;
text-align: left;
}
div.filters {
width: 100%;
line-height: 1.8;
overflow: hidden;
display: block;
font-size: 14px;
text-decoration: none;
float: left;
}
div.toptext {
line-height: 2.2;
display: block;
max-height: 35px;
color: #444444;
background-color: #555555;/* matches border color */
color: white;
width: 100%;
padding-left: 5px;
cursor: not-allowed;
/* border: 1px solid pink; */
}
div.leftnav {
width: 350px;
float: left;
clear: left;
}
div#container {
padding: 0px;
margin: 0px;
}
<div class="leftnav">
<div class="images">
<div class="toptext">Filters
<div class="btn">+ filter</div>
</div>
<div id="container">
<div class="filters rem" id="f12">
<div class="btn4" id="b4f12">Pupil name</div>
<div class="btn2" id="b2f12">
<ul>
<li id="ddf_12_0">=</li>
<li id="ddf_12_1">></li>
</ul>
</div>
<div class="btn1" id="b1f12">Joe Bloggs</div>
<div class="btn3" id="if12">x</div>
</div>
<div class="filters rem" id="f13">
<div class="btn4" id="b4f13">Pupil name</div>
<div class="btn2" id="b2f13">
<ul>
<li id="ddf_13_0">=</li>
<li id="ddf_13_1">></li>
</ul>
</div>
<div class="btn1" id="b1f13">Bill Clinton</div>
<div class="btn3" id="if13">x</div>
</div>
</div>
</div>
</div>
Thanks
Emma
Try this code:
div.btn2 {
float: left;
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
background-color: white;
cursor: default;
left: 162px;
}
div.btn2 ul {
display: block;
margin: 0;
padding: 0;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
}
div.btn2 ul li:first-child {
display: inline-block;
border-top: none;
width: 20px;
}
div.btn2:hover li {
display: block;
position: absolute;
width: 20px;
border-top: 1px solid #fff;
}
div.btn2:hover li:first-child {
position: relative;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
}
# Claudiu Yes it should be comment, but i dont have enough points to add comments
div.btn2 {
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
cursor: pointer;
left: 162px;
}
div.btn2 ul {
display: block;
margin: 0;
padding: 0;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
}
div.btn2 ul li:first-child {
display: inline-block;
width: 20px;
}
div.btn2:hover li {
display: block;
position: absolute;
width: 20px;
background: #000;
}
div.btn2:hover li:first-child {
position: relative;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
}
i have updated the fiddle