I am trying to replicate the hover effects in my left navigation menu to my right sidebar as well. Currently, I have got so the hover box only covers the text. I want the hover box to fully cover the link area like in the left menu.
Website: http://chemipharmaceutical.com/wp/
CSS for the right side bar links:
#widget-link:hover, #widget-link.active {
background: none repeat scroll 0 0 #a00101;
line-height: 1.5rem;
}
.widget a, .widget a:link {
color: #fff;
padding: 10px 20px;
}
Any input is appreciated. Thank you
1) your #nav_menu-2 must have padding:0; (atleast for left and right)
2) your <a> in the menu must have display: block;
and that's it. Than you just have to play with margins and so one, to have identical spaces like in the left sidebar.
It looks like you are looking for the hover effects to be on the parent div, instead of the child div you are looking for.
Below is an example of a navbar with some transitions like the one you are looking at, and note the structure of it.
<li class="active">
<a href="#">
<span class="icon-home"></span>
<span class="text">home</span>
</a>
</li>
You are more than likely wrapping your hover effect around the <a> attribute, instead of the <li> tag
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Try a navbar like this example shows
It's even dynamic, as it collapses if the screen is resized.
$('li').click(function() {
$(this).addClass('active')
.siblings()
.removeClass('active');
});
* {
box-sizing: border-box;
}
body {
height: 100%;
background-color: #444;
}
h1 {
font-size: 1em;
text-align: center;
color: #eee;
letter-spacing: 1px;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}
.nav-container {
width: 300px;
margin-top: 10px;
box-shadow: 0 2px 2px 2px black;
transition: all 0.3s linear;
}
.nav {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
height: 50px;
position: relative;
background: linear-gradient(#292929, #242424);
}
a {
border-top: 1px solid rgba(255, 255, 255, 0.1);
border-bottom: 1px solid black;
text-decoration: none;
display: block;
height: 100%;
width: 100%;
line-height: 50px;
color: #bbb;
text-transform: uppercase;
font-weight: bold;
padding-left: 25%;
border-left: 5px solid transparent;
letter-spacing: 1px;
transition: all 0.3s linear;
}
.active a {
color: #B93632;
border-left: 5px solid #B93632;
background-color: #1B1B1B;
outline: 0;
}
li:not(.active):hover a {
color: #eee;
border-left: 5px solid #FCFCFC;
background-color: #1B1B1B;
}
span[class ^="icon"] {
position: absolute;
left: 20px;
font-size: 1.5em;
transition: all 0.3s linear;
}
#media only screen and (max-width: 860px) {
.text {
display: none;
}
.nav-container,
a {
width: 70px;
}
a:hover {
width: 200px;
z-index: 1;
border-top: 1px solid rgba(255, 255, 255, 0.1);
border-bottom: 1px solid black;
box-shadow: 0 0 1px 1px black;
}
a:hover .text {
display: block;
padding-left: 30%;
}
}
#media only screen and (max-width: 480px) {
.nav-container,
a {
width: 50px;
}
span[class ^="icon"] {
left: 8px;
}
}
<h1>Slowly resize screen to see the width transition</h1>
<div class="nav-container">
<ul class="nav">
<li class="active">
<a href="#">
<span class="icon-home"></span>
<span class="text">home</span>
</a>
</li>
<li>
<a href="#">
<span class="icon-user"></span>
<span class="text">about</span>
</a>
</li>
<li>
<a href="#">
<span class="icon-headphones"></span>
<span class="text">Audio</span>
</a>
</li>
<li>
<a href="#">
<span class="icon-picture"></span>
<span class="text">Portfolio</span>
</a>
</li>
<li>
<a href="#">
<span class="icon-facetime-video"></span><span class="text">video</span>
</a>
</li>
</ul>
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Without seeing your markup here (i don't do external site links, apart from jsfiddle/codepen), then it's hard to advise any further
Related
I have this problem.
When I give a transition time to the menu links (for :hover and :active), once I click them they turn blue for a sec.
I also have 2 button links, which have transition time but they don't turn blue when I click.
I tried wrapping the the li-tag with the anchor-tag and viceversa, but nothing changed.
Anybody knows why this happens for the menu links but not for the buttons?
.menu {
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
list-style: none;
line-height: 27px;
margin-top: 2px;
padding-top: 1px;
background: rgb(255, 224, 189);
}
.menuitem {
text-decoration: none;
font-family: 'Varela Round', sans-serif;
color: black;
cursor: pointer;
transition: .8s;
}
.menuitem:hover {
color: white;
text-shadow: 2px 2px 5px black;
}
.menuitem:active {
color: white;
text-shadow: 2px 2px 5px black;
transform: scale(.5);
}
<nav>
<ul class="menu">
<li class="item home"><a class="current menuitem" href="index1.html">Home</a></li>
<li class="item cani">Cani</li>
<li class="item gatti"> Gatti</li>
<li class="item comeaiutarci">Come aiutarci</li>
<li class="item contatti">Contatti</li>
</ul>
</nav>
Why the dropdown menu isn't working on css hover? I've seen people do it on youtube and it looks pretty simple.
HTML
<div class ="top-bar">
<div class="row">
<img class="logo" src="Images/logo-blanco.png" alt="logo">
<div class="nav">
<ul>
<li>Inicio</li>
<li>Demos
<ul class="drop-menu">
<li>Castellano</li>
<li>Ingles</li>
<li>Videos</li>
</ul>
</li>
<li><a href="#" >Como Trabajo</a></li>
<li>Quien Soy</li>
<li>Hablan de mi</li>
<li>Contacta</li>
<li>Blog</li>
</ul>
</div>
</div>
</div>
CSS
.nav {
width: 100%;
min-width: 80%;
position: relative;
left: 15%;
top: 20px;
}
ul {
margin: 0px;
padding: 0px;
list-style: none;
}
ul li {
float: left;
width: 100px;
height: 40px;
opacity: .8;
line-height: 40px;
text-align: center;
font-size: 65%;
margin-right: 2px;
}
ul li a {
text-decoration: none;
color: white;
display: block;
}
ul li a.color {
color: black;
border-bottom: 0.5px solid rgb(80, 80, 80);
border-left: 0.5px solid rgb(80, 80, 80);
border-right: 0.5px solid rgb(80, 80, 80);
font-size: 130%;
width: 150px;
text-align: left;
padding-left: 10px;
box-shadow: 1px 1px 2px rgba(179, 176, 176, 0.5);
}
ul li ul.drop-menu {
position: relative;
top: 20px;
text-align: left;
}
.drop-menu {
display: none;
}
.drop:hover .drop-menu{
display: block;
}
I'm pretty new to this so hopefully I've included enough code. I guess perhaps something else is stopping it somewhere else?
That is because your css is incorrect. Your .drop-menu class isnt in the drop class, it is next to it.
I think if you change your css to this:
.drop-menu {
display: none;
}
.drop:hover + .drop-menu{
display: block;
}
It is going to work. The + operator is for selecting css neighbours. But you can also just end your a after the whole .drop-menu like this.
<li>
<a href="#" class="drop">Demos
<ul class="drop-menu">
<li>Castellano</li>
<li>Ingles</li>
<li>Videos</li>
</ul>
</a>
</li>
Then your css is correct and you dont have to change that.
EDIT: i removed the a tag in your code as it is officialy only allowed to contain inline elements, Also, i removed the top from the ul li ul.drop-menu. Only use top, left, right, bottom on absolute elements.
I also changed the hover on the submenu in the CSS. I now used the > selector, which means: get the DIRECT child of the selected parent. Docs here
.nav {
width: 100%;
min-width: 80%;
position: relative;
left: 15%;
top: 20px;
}
ul {
margin: 0px;
padding: 0px;
list-style: none;
}
ul li {
float: left;
width: 100px;
height: 40px;
opacity: .8;
line-height: 40px;
text-align: center;
font-size: 65%;
margin-right: 2px;
}
ul li a {
text-decoration: none;
color: black;
display: block;
}
ul li a.color {
color: black;
border-bottom: 0.5px solid rgb(80, 80, 80);
border-left: 0.5px solid rgb(80, 80, 80);
border-right: 0.5px solid rgb(80, 80, 80);
font-size: 130%;
width: 150px;
text-align: left;
padding-left: 10px;
box-shadow: 1px 1px 2px rgba(179, 176, 176, 0.5);
}
ul li ul.drop-menu {
position: relative;
text-align: left;
}
.drop-menu {
display: none;
}
.drop:hover > .drop-menu {
display: block;
}
<div class ="top-bar">
<div class="row">
<img class="logo" src="Images/logo-blanco.png" alt="logo">
<div class="nav">
<ul>
<li>Inicio</li>
<li class="drop">Demos
<ul class="drop-menu">
<li>Castellano</li>
<li>Ingles</li>
<li>Videos</li>
</ul>
</li>
<li><a href="#" >Como Trabajo</a></li>
<li>Quien Soy</li>
<li>Hablan de mi</li>
<li>Contacta</li>
<li>Blog</li>
</ul>
</div>
</div>
</div>
On the main page of my site there are 4 hyperlinks that I want to appear on every page in the same way. Except I want the link of the page I'm on to be the same color as when I put my mouse on it.
I thought I could get that with this code:
.navigation {
padding: 40px 0px;
position: relative;
text-align: center;
width: 100%;
font-size: 30px;
}
.navigation a {
background: black;
border: 1px solid grey;
border-radius: 7px;
color: white;
display: inline-block;
margin: 100px 35px;
padding: 14px;
text-decoration: none;
opacity: 0.75;
font-family: impact;
}
.navigation a:hover {
background: white;
border: 1px solid black;
color: black;
}
#contact {
background: white !important;
color: black !important;
}
<div class="navigation">
Mes productions
DJ
<a target="_blank" href="./CV.pdf">Mon CV</a>
<div id="contact">
Me contacter
</div>
</div>
Problem is that it keeps the black background color with white font color and it goes under the other links and not inline with them.
But I think that it's a bad practice to place the link in the "div" in this situation. You can simply register a class for the link and compose styles for this class.
.navigation {
padding: 40px 0px;
position: relative;
text-align: center;
width: 100%;
font-size: 30px;
}
.navigation a {
background: black;
border: 1px solid grey;
border-radius: 7px;
color: white;
display: inline-block;
margin: 100px 35px;
padding: 14px;
text-decoration: none;
opacity: 0.75;
font-family: impact;
}
.navigation a:hover {
background: white;
border: 1px solid black;
color: black;
}
#contact a {
background: white !important;
color: black !important;
}
<div class="navigation">
Mes productions
DJ
<a target="_blank" href="./CV.pdf">Mon CV</a>
<div id="contact">
Me contacter
</div>
</div>
JavaScript
nav{
width: 100%;
height: 60px;
background: linear-gradient(to bottom, #fff, #bbb);
border-bottom: 1px solid #fff;
}
.wrapper{
max-width:1200px;
margin:0 auto;
}
li{
float:left;
width: 15%;
list-style: none;
margin-top: 5px;
}
a{
text-decoration: none;
box-sizing: border-box;
display: block;
padding: 10px 10px;
text-align: center;
color: #052537;
}
.nav01,
.nav03,
.nav05{
border-right: 1px solid #999999;
border-left: 1px solid #fff;
}
.nav02,
.nav04{
border-left: 1px solid #fff;
border-right: 1px solid #999999;
}
<nav>
<div class="wrapper">
<div class="nav-global">
<ul>
<li class="nav01">go1</li>
<li class="nav02">go2</li>
<li class="nav03">go3</li>
<li class="nav04">go4</li>
<li class="nav05">go5</li>
</ul>
</div>
</div>
</nav>
Nav bar
Hello, everyone, I have the problem to design the nav bar very first and the last border. I want to make borders like in the shared picture. I can't figure it out how to design nav01 first border and nav 05 last border because I want a combination of two borders as I did in nav02,nav03 and nav04. Please help me
One way is to use border and use different properties of border to get your desired result. You can experiment and be as creative as you can. Just for once, go through all the possibilities and what CSS is capable of. Then you can easily figure out which properties to combine to make your own prototype into code.
nav {
width: 100%;
background: #e4e4e4;
font-family: 'arial';
}
.navbar-ul a {
text-decoration: none;
list-style-type: none;
display: block;
float: left;
font-size: 20px;
width: 120px;
border: 1px solid #000;
text-align: center;
margin: 10px 0px;
border-left: none;
border-top: none;
border-bottom: none;
color: #1f1f1f;
}
ul a:last-child {
border-right: none;
}
li {
margin: 5px;
}
a:hover {
text-decoration: none !important;
}
li:hover {
margin: 5px;
background: #1f1f1f;
color: white;
text-decoration: none !important;
transition: all .2s;
border-radius: 4px;
}
.navbar-ul a:hover {
cursor: pointer;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="clearfix">
<ul class="navbar-ul">
<a>
<li>Home</li>
</a>
<a>
<li>Profile</li>
</a>
<a>
<li>Contact</li>
</a>
<a>
<li>Blogs</li>
</a>
</ul>
</nav>
I have a few list elements that has a css triangle arrow after them. I'd like to add box-shadow around the arrow, but can't figure out why my shadow isn't working. I have tried following other solutions, but those solutions use ::after pseudo element to make the triangle, but my triangle is a separate div. any help is much appreciated.
#shippingsteps li {
padding: 15px 15px 15px 35px;
background: #ececec;
float: left;
display: block;
}
#shippingsteps li a {
color: #4A4947
}
#shippingsteps li span {
background: #7c7a7b;
color: white;
}
#shippingsteps li.active {
background: black;
color: white;
font-weight: bold
}
#shippingsteps li.active a {
color: white;
}
#shippingsteps li.active span {
background: #C60001;
color: white;
border-color: #C60001
}
#shippingsteps li::after {
border: none;
}
#shippingsteps li .nav-arrow {
border-color: transparent transparent transparent #ececec;
border-style: solid;
border-width: 31px 0 30px 20px;
;
height: 0;
position: absolute;
right: -19px;
top: 0;
width: 0;
z-index: 150;
}
#shippingsteps li .nav-arrow::after {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
border-color: transparent transparent transparent #ececec;
border-image: none;
border-style: solid;
border-width: 31px 0 30px 20px;
box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.4);
content: "";
position: absolute;
right: 3px;
top: -32px;
transform: rotate(31deg);
z-index: 100;
}
#shippingsteps li.active .nav-arrow {
border-color: transparent transparent transparent #000;
}
<ul class="clearfix" id="shippingsteps">
<li class="first active">
<div class="nav-arrow"></div>
<span>1</span><a data-target="checkout_login" href="#">
Checkout Method </a>
</li>
<li>
<div class="nav-arrow"></div>
<span>2</span><a data-target="billing_shipping" href="#">
Billing & Shipping</a>
</li>
<li>
<div class="nav-arrow"></div>
<span>3</span><a data-target="order_review" href="#">
Your Order & Payment</a>
</li>
<li><span>4</span><a href="#">
Confirmation</a>
</li>
</ul>
PS: Trying to put shadow around the grey triangles, the black one doesn't need any.
As previously answered in CSS box shadow around a custom shape? , you want to use the property filter:drop-shadow(0 1px 2px rgba(0,0,0,.5)) with all vendor prefixes.