Fading Drop Down CSS from Image - html

I've followed a few tutorials and fiddled with it to create a drop down menu come out from the website's logo.
This all works perfectly as I aimed for it to. To add effect I'd like to be able to have the menu items calmly fade in instead of just bam there.
I've tried to follow tutorials but I think I've butchered the CSS list enough that it's hard to put in place.
I need to logo to be the parent link which when hovered over drops down the options and not have it's shape, padding, boarders etc. effected by the li class so I created the sub class to prevent that.
Here's the HTML in question.
<nav>
<ul>
<li><div id="logo"><img src="images/logo.png" width="318" height="85" alt="Logo of Website"/></div>
<ul>
<li class="sub"> Much
</li>
<li class="sub"> Navigation
</li>
<li class="sub"> Very
</li>
<li class="sub"> Links
</li>
<li class="sub"> Wow
</li>
</ul>
</li>
</ul>
</nav>
And my mess of a Stylesheet
li {
list-style:none !important;
}
.sub {
padding:5px;
width:300px;
margin-bottom:1px;
border:rgba(0, 0, 0, 0.2);
height:20px;
vertical-align:central;
}
nav ul {
padding:0;
margin:0;
}
nav ul li {
list-style: none;
float:left;
background-color:rgba(0, 0, 0, 0.5);
}
nav ul li a {
text-decoration:none;
color:white;
font-family:'Merriweather', Baskerville, "Century Schoolbook L", "Times New Roman", serif;
font-weight:300;
color:white;
font-size:0.9em;
}
li a:hover {
font-style:italic;
word-spacing:3px;
height:20px;
}
nav ul li ul {
display:none;
}
nav ul li:hover ul {
z-index:5;
display:list-item !important;
position:absolute;
margin-top:90px;
}
nav ul li:hover ul li {
float:none;
}
And a JSFiddle link which shows you a box which is the logo and when you hover over it the menu appears below it... I'm aiming to get that menu list to fade into existence and not just jump out behind the logo.
JSFiddle

Try CSS3 transitions if you don't want to use jQuery. I think your markup may need some rewriting, but try for example:
transition:All 1s linear;
-webkit-transition:All 1s linear;
-moz-transition:All 1s linear;
-o-transition:All 1s linear;

Related

Specific background for single nav link

Looking to find out how to change a single nav link to have a different background hover color than the others.
I've tried #nav #contact.hover and #nav #contact:hover to no avail.
<div id="nav">
<ul>
<li id="home">Home</li>
<li id="service">Service</li>
<li id="parts">Parts</li>
<li id="contact">Contact</li>
</ul>
<div class="clearall"></div>
</div>
</html>
CSS:
.clearall {
clear:both;
}
#nav {
background:#333;
}
#nav ul li {
float:left;
margin-right:0px;
}
#nav ul li a {
color:#fff;
text-transform:uppercase;
padding:10px 20px;
display:block;
text-decoration:none;
}
#nav ul li a:hover {
background-color:black;
}
Should change the contact element in the nav to have a background hover color of white
Just have to get the selector right. I think you were having issues because your base style for hover is overly specific which trumps most overrides.
#nav ul li:hover a
...could easily be changed to simpler selector that would be easier to override, the use of ID's instead of classes adds to the specificity issue as well.
.clearall {
clear:both;
}
#nav {
background:#333;
}
#nav ul li {
float:left;
margin-right:0px;
}
#nav ul li a {
color:#fff;
text-transform:uppercase;
padding:10px 20px;
display:block;
text-decoration:none;
}
#nav ul li:hover a {
background-color:black;
}
#nav ul li#contact:hover a {
background: url('https://picsum.photos/100');
}
<div id="nav">
<ul>
<li id="home">Home</li>
<li id="service">Service</li>
<li id="parts">Parts</li>
<li id="contact">Contact</li>
</ul>
<div class="clearall"></div>
</div>
You can accomplish this by using the :last-child psuedo-class in your CSS.
Here's a codepen with the fix but I'll describe below what I did: https://codepen.io/Athys/pen/WBdYdZ
I added :last-child to the li selector since the "contact" link appears as the last list item (the last li). Then, I added a :hover psuedo-class to the a selector and give it a different hover color and text-color than the other a elements. Hope this helps.

How to let little menu with 3 links act responsive inside header?

I made my website as responsive as possible(don't wanna know something about bootstrap). The only thing that doesn't stay in its place (which needs to stay in the middle). Here is my code:
#header {
position:fixed;
display:block;
width:100%;
top:0;
left:0;
padding-left:0vmax;
padding-right:5vmax;
z-index:99999;
height:8vmax;
max-height:8vmax;
transition: .3s linear;
box-sizing:border-box;
background-color: rgba(243,243,243,1.00);
}
#menuwrapper {
display:block;
float:right;
width:55vmax;
margin-top:0.35vmax;
margin-right:17vmax;
height:8vmax;
max-height:8vmax;
overflow:hidden;
box-sizing:border-box;
position:relative;
}
#menu {position:absolute;height:100%;width:100%;display:table;padding: 2.5vmax; word-wrap:break-word;}
#menu ul {word-spacing:2vmax;font-size:1.35vmax;padding:0;padding-bottom:0vmax;margin: 0 1vmax;}
#menu li {display:inline-block;padding: 0vmax;}
.rechts {display: table-cell;width: 1px;vertical-align: middle;white-space: nowrap;}
#menu ul li a {height:8vmax;text-decoration:none;color:grey;transition: color .45s ease-in-out;margin-right:7.5vmax;}
#menu ul li a:hover {color:#3f92c3;}
<div id="header">
<div id="menuwrapper">
<div id="menu">
<ul class="pad">
</ul>
<ul class="rechts">
<li><a class="a1" id="page1" href="javascript:;">Services</a></li>
<li><a class="a1" id="page2" href="javascript:;">Portfolio</a></li>
<li><a class="a1" id="page3" href="javascript:;">Contact</a></li>
</ul>
</div>
</div>
</div>
I made a jsfiddle but i can't see that it goes to much to the left like i saw on a tablet.
It is a tablet of work and it has long height. On my website it's better noticable My website If i change the height inside the desktop version. Then you see that the menu goes left and the first menu word disappears.
Is there a way to fix this?
You're overriding default properties without reason.
I tried to clean your css code a little bit, deleting what's not necessary.
I think now works as you expect, if not, specify a little bit more and i'll edit the code to help you understand how to do what you need.
#header {
position:fixed;
display:block;
width:100%;
top:0;
left:0;
padding-left:0vmax;
padding-right:5vmax;
z-index:99999;
height:8vmax;
max-height:8vmax;
transition: .3s linear;
box-sizing:border-box;
background-color: rgba(243,243,243,1.00);
}
#menuwrapper {
display:block;
float:right;
margin-top:0.35vmax;
margin-right:17vmax;
height:8vmax;
max-height:8vmax;
overflow:hidden;
box-sizing:border-box;
position:relative;
}
#menu {padding: 2.5vmax; word-wrap:break-word;}
#menu ul {word-spacing:2vmax;font-size:1.35vmax;padding:0;padding-bottom:0vmax;margin: 0 1vmax;}
#menu li {display:inline-block;padding: 0vmax;}
.rechts {vertical-align: middle; white-space: nowrap;}
#menu ul li a {height:8vmax;text-decoration:none;color:grey;transition: color .45s ease-in-out;margin-right:7.5vmax;}
#menu ul li a:hover {color:#3f92c3;}
<div id="header">
<div id="menuwrapper">
<div id="menu">
<ul class="pad">
</ul>
<ul class="rechts">
<li><a class="a1" id="page1" href="javascript:;">Services</a></li>
<li><a class="a1" id="page2" href="javascript:;">Portfolio</a></li>
<li><a class="a1" id="page3" href="javascript:;">Contact</a></li>
</ul>
</div>
</div>
</div>

Setting "a" color withing a "li" on hover

I'm using a platform that allows the user to change the elements settings with css, and I'm trying to make the "a" change color when hovering over the "li", but the color of the "a" does not change, how should i fix this? And I know I can change the "a" if I hover over it, but I want it to change while hovering over the "li".
<div class="top">
<ul class="menu">
<li><a>Home</a></li>
<li>Products
<ul class="submenu">
<li><a>T-Shirts</a></li>
<li><a>Shirts</a></li>
<li><a>Tank Tops</a></li>
</ul>
</li>
</ul>
</div>
.submenu li{
background-color:#262626;
color:white;
}
.submenu li:hover{
background-color:white;
color:#262626;
}
Thanks in advance.
There's a couple of ways.
.submenu li:hover{
background-color:white;
}
.submenu li:hover a{
color:#262626;
}
or
.submenu li:hover{
background-color:white;
color:#262626;
}
.submenu li a{
color: inherit;
}

Odd behaviour of HTML5 navigation

Here is the html code of the page's navigation:
<nav>
<ul id="navigation">
<A class="scroll" href="#first">Hjem</A>
<A class="scroll" href="#second">Info</A>
<A class="scroll" href="#third">Pris</A>
<li style="display: inline;"><A class="scroll" href="#">Brugervejledninger »</A>
<ul>
<li>arbejdsleder</li>
<li>medarbejder</li>
</ul>
</li>
<a id="login-button" href="http://mintimeseddel.dk/scheduling/users">Log ind</a>
</ul>
</nav>
And following is the css used to style it:
ul#navigation li:hover > ul
{
visibility:visible;
opacity:1;
}
ul#navigation ul, ul#navigation ul li ul {
list-style: none;
margin: 0;
padding: 0;
visibility:hidden;
position: absolute;
z-index: 99999;
width:180px;
background:#f8f8f8;
box-shadow:1px 1px 3px #ccc;
opacity:0;
-webkit-transition:opacity 0.2s linear, visibility 0.2s linear;
-moz-transition:opacity 0.2s linear, visibility 0.2s linear;
-o-transition:opacity 0.2s linear, visibility 0.2s linear;
transition:opacity 0.2s linear, visibility 0.2s linear;
}
ul#navigation ul {
top: 43px;
left: 43%;
}
ul#navigation ul li ul {
top: 0;
left: 181px;
}
ul#navigation ul li {
clear:both;
width:100%;
border:0 none;
border-bottom:1px solid #c9c9c9;
}
ul#navigation ul li a {
background:none;
padding:7px 15px;
color:#616161;
text-shadow:1px 1px 0px #fff;
text-decoration:none;
display:inline-block;
border:0 none;
float:left;
clear:both;
width:150px;
}
Everything works as expected on the localhost, but the problem occurs once the site is uploaded to the live server, the navigation menu gets messed up. Even though it is browser specific: on firefox it always shows up properly, while the other browsers need to reload the page a few times to get it right.
A live example of it can be seen at: www.mintimeseddel.dk
Any help is much appreciated.
Your HTML is not valid. Browsers will interpret the invalid html differently in an effort to figure out what it is supposed to mean.
Namely, you can't put anchors ('a') directly inside of unordered lists ('ul'), the only valid child of a list is a list item ('li'). In other words, you need to wrap an 'li' tag around the 'a' tags.
Some browsers will close the list and display the anchors inside of the list's parent element (a 'nav' in this case). Other browsers will transparently wrap the anchors in a list entry. Others still will try to render the anchors where they are.
If you fix the HTML, the rest should start to work consistently (although you might have to go back and redo the CSS).
EDIT To respond to OP's comment: The HTML should look like this:
<nav>
<ul id="navigation">
<!-- note the new 'li' tags here -->
<li><a class="scroll" href="#first">Hjem</a></li>
<li><a class="scroll" href="#second">Info</a></li>
<li><a class="scroll" href="#third">Pris</a></li>
<li style="display: inline;"><A class="scroll" href="#">Brugervejledninger »</A>
<ul>
<li>arbejdsleder</li>
<li>medarbejder</li>
</ul>
</li>
</ul>
<!-- and another additional 'li' tag here -->
<li><a id="login-button" href="http://mintimeseddel.dk/scheduling/users">Log ind</a></li>
</nav>

CSS/HTML Drop Menu hiding some list entries

I am working on a HTML/CSS drop down menu and now whenever I hover my mouse over the top of the menu not every entry is showing in the drop menu. The top one or two entries are always missing. Here is my HTML:
<!-- Navigation Bar -->
<ul id="navi">
<li>Engines
<ul>
<li>DiniJS</li>
<li>Foxen2D</li>
<li>Vivon3D</li>
</ul>
</li>
<li>Team
<ul>
<li>Rob Myers</li>
<li>Nate Mast</li>
</ul>
</li>
<li>Contact
<ul>
<li>Email</li>
<li>Twitter</li>
</ul>
</li>
</ul>
and here is the CSS:
#navi ul {
list-style:none;
margin:0px;
padding:0px;
}
#navi li {
float:left;
width:120px;
padding-top: 13px;
padding-bottom:8px;
background-color:black;
text-align:center;
font-family:"Courier New";
}
#navi li:hover {
background-color:#303030;
}
#navi li ul li {
float:none;
width:116px;
text-align:left;
padding-left:4px;
border-top:1px solid #303030;
display:none;
font-size:85%;
position:absolute;
z-index:2;
}
#navi li:hover ul li {
display:block;
}
#navi a {
text-decoration:none;
color:red;
}
I am open to any Javascript or JQuery suggestions if that is a better way to go about fixing this. Thank you.
Your problem is that all of the submenu items are stacking one on top of another. Simply moving position: absolute; from the #navi li ul li block to a new #navi li ul block should fix this.
When using nested list items. use class names to target. for your menu use class="sub"
for submenu (ul) and set display none and absolute for the sub ul and not for the li.