Making Link Padding Clickable - css

The padding around the link for my dropdown menu isn't clickable. When I mouse over the actual text, it changes color and becomes clickable. How can I make the padding clickable? I read that I should style it as an inline-block, but that didn't work. This is also my first post, so correct me for the countless things that I probably did wrong.
CSS:
body {
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align: left;
background-position:center;
background-image:url(sun.jpg);
}
a {
display:inline-block;
color: #6FF;
text-decoration: none;
}
a:hover {
color: #FFF;
}
ul {
color:#6FF
text-align: left;
display: inline-block;
margin: 0;
padding: 1px 1px 1px 0;
list-style: none;
}
ul li {
color: purple;
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -10px;
position: relative;
padding: 20px 20px;
background: #fff;
cursor: pointer;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding:0;
position:absolute;
top: 54px;
left: 0;
width: 150px;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
ul li ul li {
background-color:#555;
color:#6FF;
display: block;
}
ul li ul li:hover { background: #555; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}

You should put the padding to the link, no the list item because the link is what is clickable.
body {
font-family:'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align: left;
background-position:center;
background-image:url(sun.jpg);
}
a {
padding: 20px 20px;
display:inline-block;
color: #6FF;
text-decoration: none;
}
a:hover {
color: #FFF;
}
ul {
color:#6FF text-align: left;
display: inline-block;
margin: 0;
padding: 1px 1px 1px 0;
list-style: none;
}
ul li {
color: purple;
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -10px;
position: relative;
background: #fff;
cursor: pointer;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding:0;
position:absolute;
top: 54px;
left: 0;
width: 150px;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
ul li ul li {
background-color:#555;
color:#6FF;
display: block;
}
ul li ul li:hover {
background: #555;
}
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
<ul>
<li>First link
</li>
<li>First link
</li>
<li>First link
</li>
<li>First link
</li>
<li>First link
</li>
<li>First link
</li>
</ul>

Related

Animated after element has delay and twitching

I am trying to set behaviour for menu items in the header like here: http://www.germanamericanconference.org/partners/. There is a bar which slides back and forth when hovering on elements. In my case I can't add another element to my header and such effect should be purely CSS so instead I am using after pseudo-element.
Here, in the example: https://jsfiddle.net/1czmx08y/
As you can see there is a delay when moving between items but even if I decrease transition time, it starts twitching.
How can I avoid such behaviour? I feel like my transition is wrong.
Change all the transitions to 0.15s or 0.18s;
Isn't much better now? i think it would be better and it could be a better choice than using a plugin or more css or any js.
html {
font-family: 'Josefin Slab', 'Comfortaa', sans-serif;
font-size: 1.2em;
background: #eee;
}
ul {
position: relative;
width: 27em;
height: 2em;
margin: 100px auto;
padding: 0;
white-space: nowrap;
}
ul li {
display: inline;
text-align: center;
}
ul li a {
position: relative;
top: 0;
left: 0;
right: 25em;
bottom: 0;
display: inline-block;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: .4em .2em;
color: #09C;
text-decoration: none;
text-shadow: 0 1px 0 white;
/*transition*/
-webkit-transition: width .3s,right .3s;
-moz-transition: width .3s,right .3s;
-o-transition: width .3s,right .3s;
transition: width .19s,right .19s;
}
ul li:nth-child(1) a { width: 2em; }
ul li:nth-child(2) a { width: 4em; }
ul li:nth-child(3) a { width: 4em; }
ul li:nth-child(4) a { width: 12em; }
ul li:nth-child(5) a { width: 5em; }
ul li:last-child a::after {
content: "";
position: absolute;
right: inherit;
bottom: -3px;
width: inherit;
height: 3px;
background: #ccc;
pointer-events: none;
/*transition*/
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
transition: all .19s ease;
}
ul li:nth-child(1) ~ li:last-child a {
right: 25em;
width: 2em;
}
ul li:nth-child(2):hover ~ li:last-child a {
right: 21em;
width: 4em;
}
ul li:nth-child(3):hover ~ li:last-child a {
right: 17em;
width: 4em;
}
ul li:nth-child(4):hover ~ li:last-child a {
right: 5em;
width: 12em;
}
ul li:nth-child(5):last-child:hover a {
right: 0;
width: 5em;
}
ul li:hover ~ li:last-child a::after,
ul li:last-child:hover a::after { background: #c351fa; }
ul li:last-child a {
min-width: 5em;
max-width: 5em;
}
ul li a:hover,
ul li a:focus {
color: #c351fa;
background-color: rgba(255,255,255,.6);
/*transition*/
-webkit-transition: width .3s,right .3s,background-color .3s;
-moz-transition: width .3s,right .3s,background-color .3s;
-o-transition: width .3s,right .3s,background-color .3s;
transition: width .19s,right .19s,background-color .19s;
}
ul li a:focus { border-bottom: 3px solid #c351fa; }
<ul>
<li> ✿ </li><!--
--><li> Lorem </li><!--
--><li> Ipsum </li><!--
--><li> Consectetur adipisicing </li><!--
--><li> Sit amet </li>
</ul>

Unable to hide item in menu

So, I have a simple NAV that I came up with, and I'm trying to add a burger icon that will only show up when the screen is small.
Currently, my burger is just the word Menu, but I'd like to have this hidden by default. However, my code is overridden by a display:inline, that is earlier in the code. even if I add !Important.
Any one have any ideas as to how I can hide the menu element?
JSFIDDLE https://jsfiddle.net/Lwwgpx9k/
My code is below.
.html
<div class="nav">
<ul>
<li class="hidden">Menu</li>
<li class="home"><a class="active" href="#">Home</a></li>
<li class="gallery">Gallery</li>
<li class="tutorials">Tutorials</li>
<li class="about">About</li>
</ul>
</div>
.css
body {
background: #333;
}
.nav ul {
color: #e6e9e9;
position: fixed;
top: 60px;
padding-left: 5%;
text-align: center;
margin: 0;
}
.nav ul li {
line-height: 35px;
float: left;
width: 120px;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 0px 10px;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.nav ul li:hover {
background: #6A1B9A;
color: #e6e9e9;
}
.nav ul li ul {
padding: 0;
position: absolute;
top: 35px;
left: 0;
text-align: left;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
.nav ul li ul li {
width: 200px;
background: #555;
display: block;
color: #e6e9e9;
}
.nav ul li ul li:hover {
background: #6A1B9A;
}
.nav ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
transition-delay: 2s;
-webkit-transition-delay: 2s;
/* Safari */
}
.nav a {
font-size: 1.4em;
text-decoration: none;
color: #e6e9e9;
display: block;
transition: .3s background-color;
}
.nav a:hover {
background-color: #6A1B9A;
color: #e6e9e9;
}
.nav a.active {
background-color: #6A1B9A;
color: #e6e9e9;
cursor: default;
}
.nav ul {
color: #e6e9e9;
position: fixed;
top: 60px;
padding-left: 5%;
text-align: center;
margin: 0;
}
.nav ul li {
line-height: 35px;
float: left;
width: 120px;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 0px 10px;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.nav ul li:hover {
background: #6A1B9A;
color: #e6e9e9;
}
.nav ul li ul {
padding: 0;
position: absolute;
top: 35px;
left: 0;
text-align: left;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
.nav ul li ul li {
width: 200px;
background: #555;
display: block;
color: #e6e9e9;
}
.nav ul li ul li:hover {
background: #6A1B9A;
}
.nav ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
transition-delay: 2s;
-webkit-transition-delay: 2s;
/* Safari */
}
.nav a {
font-size: 1.4em;
text-decoration: none;
color: #e6e9e9;
display: block;
transition: .3s background-color;
}
.nav a:hover {
background-color: #6A1B9A;
color: #e6e9e9;
}
.nav a.active {
background-color: #6A1B9A;
color: #e6e9e9;
cursor: default;
}
.hidden {
display: none; !important
}
your problem is here
hidden {
display: none; !important<---- this important should be inside ";"
}
it should be
hidden {
display: none !important;
}

Disable hover effect on mobile. Make it a touch event

I made my website responsive for tablet and smartphone. I used hover for desktop size, but on mobile size there's hover to. I want to change the hover on the mobile device to a touch without using javascript. I heard something about the no-touch modernizr to change hover to touch event?
nav{
margin-left: 2.7em;
}
nav ul ul {
display: none;
background: #5f6975;
border-radius: 0em;
padding: 0;
position: absolute;
top: 100%;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
nav ul li:hover > ul {
display: block;
opacity: 1;
visibility: visible;
}
nav ul {
background: #333333;
padding: 0 1em;
border-radius: 1em;
list-style: none;
position: relative;
display: inline-block;
}
nav ul li {
float: left;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
nav ul li:hover {
background: #555555;
}
nav ul li:hover a {
color: #ffffff;
}
nav ul li a {
font: 90% helvetica;
display: block;
padding: 1.7em 2em;
color: #ffffff;
text-decoration: none;
}
nav ul ul li {
float: none;
border-top: 0.1em solid #6b727c;
border-bottom: 0.1em solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 1em 2em;
}
nav ul ul li a:hover {
background: #292F41;
}
#media only screen and (max-width:40em)
What do i need to put here to disable the hover function for mobile and make it a touch?

css drop down menu can hover on text only

When using my css dropdown menu only the text of the dropdown is active which makes it more difficult to select rather than the area which would be easier (especially with mobile devices).
CSS is:
#topMenu ul {
text-align: center;
display: inline;
margin: 0;
padding: 15px 20px 17px 20px;
list-style: none;
}
#topMenu ul li {
font: bold 12px sans-serif;
text-transform:uppercase;
color:#666;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 10px 40px;
background: #EEE;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
#topMenu ul li:hover {
background: #EEE;
color: #000;
}
#topMenu ul li ul {
z-index: 5000;
padding: 0;
position: absolute;
top: 38px;
left: 0;
width: 150px;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
#topMenu ul li ul li {
background: #EEE;
display: block;
color: #000;
border:solid 1px #999999;
}
#topMenu ul li ul li:hover { background: #EEE; }
#topMenu ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
Code may be a bit cumbersome.
Thanks
You can add display:block; to your anchor tag CSS to make it fill the li.
CSS:
#topMenu ul li ul a {
display: block;
}
HTML:
<ul id="topMenu">
<li>
<ul>
<li>
Link Text
</li>
<!-- more submenu items -->
</ul>
</li>
<!-- more topMenu items -->
</ul>
Try this <---> instead of use padding:10px 40px to determine the height use this:
line-height:30px <---- it replaces the padding top and bottom (20px) and add 10px of the font.
Then your CSS could be:
#topMenu ul li {
font: bold 12px sans-serif;
text-transform:uppercase;
color:#666;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 0px 40px;
line-height:30px;
background: #EEE;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
If you have a tags inside the li then make it block and the same line-height:
#topmenu ul li a {
display:block;
line-height:30px;
height:30px;
}

Navigation wont align Center

Can some one help me align my navigation center please
http://sketchedneo.com/Example.php
I have tried
left: 25%;
align:center;
alignment-adjust: middle;
It just doesnt seem to want to go middle.
Any suggestions are greatly appreciated
div#navigation{ position: absolute;
padding-top:-100px;
border-radius: 4px;
}
#navigation ul {
padding:5px 1px 1px 1px;
margin: 0;
list-style: none;
float:left; text-align:left;
}
#pad{padding:0px 0px 0px 70px;}
#navigation li {
float: left;
position: relative;
}
#navigation ul li a{
display:block;
padding:5px 1px 1px 1px;
margin:0px;
font-family: Verdana, Geneva, sans-serif;
font-size: 12px;
text-decoration: none;
white-space:nowrap;
}
#navigation ul ul{
position:absolute;
top:-99999px;
left:0;
opacity: 0; /* Hide sub level */
-webkit-transition: opacity .5s ease-in-out;
-moz-transition: opacity .5s ease-in-out;
-o-transition: opacity .5s ease-in-out;
z-index:497;
background:#95cfff;
padding: 2px; border:1px solid #000000; border-top:1px solid #000000;
border-bottom-left-radius:6px;
border-bottom-right-radius:6px;
}
#navigation ul ul ul {
position:absolute;
top:-99999px;
left:100%;
opacity: 0; /* Hide sub level */
-webkit-transition: opacity .5s ease-in-out;
-moz-transition: opacity .5s ease-in-out;
-o-transition: opacity .5s ease-in-out;
z-index:497;
background:#a1e8dc;
padding: 2px; border:1px solid #000000;
border-top-left-radius:6px;
border-top-right-radius:6px;
border-bottom-left-radius:6px;
border-bottom-right-radius:6px;
}
#navigation ul li:hover>ul{ opacity: 1; position:absolute; top:99%; left:0; }
#navigation ul ul li:hover>ul{ position:absolute; top:0; left:100%; opacity: 1; z-index:497; background:#95cfff; }
#navigation a:link,#navigation a:visited, #navigation a:active {
color: #002b4f;
font-weight: normal;
text-align: center;
text-decoration: none;
}
#navigation a:hover {
color: #0059d2;
font-weight: normal;
text-align: center;
text-decoration: none;
} a.top:link, a.top:visited, a.top:active {
color: #002b4f;
font-weight: normal;
text-align: center;
text-decoration: none;
}
I have used this guy's technique in the past a few time and it works great:
http://pmob.co.uk/pob/centred-float.htm

Resources