CSS: Only part of my menu are supposed to hide - html

I'm trying to hide part of my menu. When I call display:none The entire menu disappears. I have id's to separate them so I don't get why this happens. Here's the code:
HTML:
<ul id="menu">
<li>Categories 1
<ul id="cat1">
<li>temp1</li>
<li>temp2</li>
<li>temp3</li>
</ul>
</li>
</ul>
CSS:
#menu {
background-color: #0000FF;
height: 20px;
padding: 15px 0 10px;
margin-bottom: 20px;
font: 12px 'DroidSansBold', Tahoma,sans-serif;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
box-shadow: 3px 2px 3px #000;
border-radius: 5px;
text-align: center;
}
#menu li{
display: inline-block;
}
#menu li a {
color: #fff;
text-decoration: none;
margin: 0 120px;
}
#cat1 li{
display: block;
padding: 10px;
}
#cat1 li a{
background-color: #0000FF;
padding: 10px;
border-radius: 5px;
}
Somewhat working demo: http://jsfiddle.net/ZfN7t/

When you're dealing with ul inside ul, it's usually easier to style if you give them different classes:
<ul id="menu">
<li class="menu-item">Categories 1
<ul id="cat1">
<li class="cat1-item">temp1</li>
<li class="cat1-item">temp2</li>
<li class="cat1-item">temp3</li>
</ul>
</li>
</ul>
Hide the temp1, temp2, temp3 like this:
.menu-item #cat1{
display:none;
}
To display on hover:
.menu-item:hover #cat1{
display:block;
}

Related

readjust Horizontal menu to resolution

I'm new to this, so I'm clueless.
Whenever I go to my site with a different resolution the menu changes a lot and does not align correctly. Just tell me if i need more of the html or css.
My webpage is Aulan.co
My code:
ul {
font-size: 25px;
color: black;
text-align: center;
list-style-type: none;
margin-bottom: 2em;
line-height: 150%;
margin-left: 3em;
margin-right: 5em;
}
#menu {
list-style-type: none;
margin: auto;
width: 90%;
height: auto;
padding: auto;
overflow: hidden;
background-color: #353B4E;
text-align: center;
font-size: 18px;
}
li {
text-align: center;
}
li a {
display: block;
color: white;
text-align: center;
padding: 5px 70px;
text-decoration: none;
height: auto;
}
li a:hover {
background-color: #111;
display: inline;
}
#menus {
float: left;
<h1> AuLan </h1>
<ul id="menu">
<li id="menus"><a class="active">Forside</a></li>
<li id="menus">Informasjon</li>
<li id="menus">Regler</li>
<li id="menus">Crew</li>
<li id="menus">Kontakt oss</li>
<li id="menus">Seatmap</li>
<li id="menus">Timeplan</li>
</ul>
it's not really clear what you want to achieve, but I tried to change your code in a way that I think you might want. I took out a lot of unneccessary code from the CSS and added some. In the HTML, i change the menusID to a class, since IDs should only be used once per page.
You can adjust especially the min-width and padding setting in the menu li a rule to your needs (but also the other width and padding settings)
#menu {
font-size: 25px;
list-style-type: none;
width: 90%;
background-color: #353B4E;
font-size: 18px;
padding: 10px 20px;
}
#menu li {
display: inline-block;
line-height: 150%;
}
#menu li a {
display: block;
min-width: 100px;
color: white;
padding: 5px 15px;
text-decoration: none;
}
#menu li a:hover {
background-color: #111;
}
<h1> AuLan </h1>
<ul id="menu">
<li class="menus"><a class="active">Forside</a></li>
<li class="menus">Informasjon</li>
<li class="menus">Regler</li>
<li class="menus">Crew</li>
<li class="menus">Kontakt oss</li>
<li class="menus">Seatmap</li>
<li class="menus">Timeplan</li>
</ul>

Centering text on a navigation bar

I need to center these links while leaving Santos Fire Department where it is
BTW the only reason that Santos Fire Department has two different tags is to avoid the hover animation.
ul.nav{
display: block;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
height: 3.3em;
}
ul.nav li {
float:left;
}
ul.nav li a{
display: block;
color: white;
padding: 14px 16px;
text-decoration: none;
text-align: center;
}
ul.nav li .navlogo{
overflow: hidden;
background-color: #333;
height: 3.3em;
}
ul.nav li a.navlogo{
display: inline-block;
padding-top: 10px;
margin-left: 10px;
font-size: 150%;
z-index: -1;
}
<nav class="navbar">
<ul class="nav">
<li id="logo"><a class="navlogo">Santos Fire Department</a></li>
<li id="nav">TeamSpeak (Temp Server)</li>
<li id="nav">US Server</li>
<li id="nav">EU Server</li>
<li id="nav">SantosRP</li>
</ul>
</nav>
Santos Fire Department in original position, navbar centered :)
.navbar {
background-color: #333;
}
.nav {
display: table;
margin: 0 auto;
}
ul.nav li {
display: inline-block;
}
ul.nav li a {
display: block;
color: white;
padding: 14px 16px;
text-decoration: none;
text-align: center;
}
.navlogo a {
color: white;
font-size: 150%;
margin: 8px;
position:absolute;
}
<nav class="navbar">
<span class="navlogo"><a>Santos Fire Department</a></span>
<ul class="nav">
<li id="nav1">TeamSpeak (Temp Server)
</li>
<li id="nav2">US Server
</li>
<li id="nav3">EU Server
</li>
<li id="nav4">SantosRP
</li>
</ul>
</nav>
Update
position:absolute; on .navlogo a class, might not be the best way but gives you the results desired.
First of all you should eliminate multiple ids like id="nav" this is important for styling.
Now the parent needs to be text-align: center; and for your #logo you can float: left; like now. Otherwise, never avoid flexbox, but remember the browser support http://pleeease.io/play/

Menu dropdown isn't hidden beforehand

I've added submenus to some code I found online. I want the submenu, which is a drop-down list, only to show when I hover over the appropriate <a>. But the submenu is appearing right from the start without me hovering over it. What am I doing wrong?
div.menu3 {
/*width:500px;margin:0 auto;*/
/*Uncomment this line to make the menu center-aligned.*/
text-align: center;
font-size: 0;
height: 25px;
*position: relative;
*top: 1px;
/*Hacks for IE6 & IE7 */
}
div.menu3 a {
display: inline-block;
padding: 0 20px;
margin-right: 1px;
/* It specifies the distance between each tab */
background: #F7F7F7;
color: Black;
text-decoration: none;
font: normal 12px Trebuchet MS;
line-height: 24px;
border: 1px solid #CAD0DB;
border-bottom: 0;
color: #666;
vertical-align: top;
/*ChangeSet#2*/
text-decoration: none;
}
div.menu3 a:hover,
div.menu3 a.current {
background: #E9ECF0;
line-height: 25px;
color: #000;
}
div.menu3sub {
height: 6px;
border: 1px solid #CAD0DB;
background: #E9ECF0;
}
div.menu3sub a:hover,
div.menu3 a.current {
background: #E9ECF0;
line-height: 25px;
color: #000;
}
<div class="menu3">
Home
Employees
Department
<ul>
<li>Add Department</li>
<li>Delete Department</li>
</ul>
Asset
</div>
<div class="menu3sub"></div>
Your html is off. So your dropdown won't display properly. Use un-ordered lists instead of what you have. This should point you in the right direction.
ul.menu {
list-style-type: none;
}
ul.menu li {
display: inline-block;
}
ul.menu li.submenu ul {
display: none;
position: absolute;
}
ul.menu li.submenu:hover ul {
display: block;
}
ul.menu li.submenu ul li {
display: block;
}
<ul class="menu">
<li>Home
</li>
<li>Employees
</li>
<li class="submenu">Department
<ul>
<li>Add Department
</li>
<li>Delete Department
</li>
</ul>
</li>
<li>Asset
</li>
</ul>

CSS - Dropdown menu child item drags the whole style one level down

I have on main Menu that works totally fine without child menu items.
But now i have to add additional items and wanted to do a drop down Menu.
The Menu item "Services" is parent of "test" there should be a clean line, but when opening "Services" the border of the whole menu expands with "test" there should only be a small border the same length as "Services" surrounding "test".
For this to work i have to edit "current active deeper parent" or "nav-child unstyled small" if i'm correctly.
If possible you should even only need to hover over "Services" to trigger the dropdown menu.
.flowmenu {
background: none repeat scroll 0 0 #333333;
padding-left: 0px;
position: relative;
}
.flowmenu li {
display: inline-block;
list-style: none outside none;
padding: 0;
}
.flowmenu ul li {
position: relative;
}
.flowmenu li > a {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border-color: #000000;
border-style: solid;
border-width: 0 1px 0 0;
box-shadow: 1px 0 0 0 #555555;
margin-bottom: 0;
padding: 5px 15px;
text-transform: uppercase;
color: #FFFFFF;
cursor: pointer;
display: block;
font-family: 'Corbel', sans-serif;
font-size: 12px;
font-weight: normal;
line-height: 30px;
text-decoration: none;
}
.flowmenu li.active {
background: #222222;
}
<div class="navfix">
<ul class="nav menu flowmenu li">
<li class="item-435">Home
</li>
<li class="item-485">Communication
</li>
<li class="item-486 current active deeper parent">Services
<ul class="nav-child unstyled small">
<li class="item-579">Test
</li>
</ul>
</li>
<li class="item-487">Languages
</li>
<li class="item-488">Network
</li>
</ul>
</div>
The parent list item of the <ul> has to be position relative if you want a dropdown menu
the <ul> it self can be position absolute so it appears nicely under the parent. I made a jsFIDDLE
Most important changes:
.flowmenu > li {
position:relative;
display: inline-block;
list-style: none outside none;
padding: 0;
}
.flowmenu ul {
position: absolute;
display:block; /* or none */
width:100%;
background: #222222;
list-style:none;
margin:0;
padding:0;
}
Hope this helps! I didn't completly styled the dropdown maybe it's better to do that yourself
.flowmenu {
background: none repeat scroll 0 0 #333333;
padding-left: 0px;
position: relative;
}
.flowmenu > li {
position: relative;
display: inline-block;
list-style: none outside none;
padding: 0;
}
.flowmenu ul {
position: absolute;
display: none;
width: 100%;
background: #222222;
list-style: none;
margin: 0;
padding: 0;
}
.flowmenu ul > li {
display: block;
}
.flowmenu li > a {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border-color: #000000;
border-style: solid;
border-width: 0 1px 0 0;
box-shadow: 1px 0 0 0 #555555;
margin-bottom: 0;
padding: 5px 15px;
text-transform: uppercase;
color: #FFFFFF;
cursor: pointer;
display: block;
font-family: 'Corbel', sans-serif;
font-size: 12px;
font-weight: normal;
line-height: 30px;
text-decoration: none;
}
.flowmenu > li.active {
background: #222222;
}
.flowmenu > li:hover ul {
display: block;
}
<div class="navfix">
<ul class="nav menu flowmenu li">
<li class="item-435">Home
</li>
<li class="item-485">Communication
</li>
<li class="item-486 current active deeper parent">Services
<ul class="nav-child unstyled small">
<li class="item-579">Test
</li>
</ul>
</li>
<li class="item-487">Languages
</li>
<li class="item-488">Network
</li>
</ul>
</div>

Transparent menu with sections 'cut-out'

I'm asked to create a html/css menu such as the following picture:
This looks a simple menu to me, wasn't it by the fact that it has 'cut-out' sections between the menu items. I don't think it's clear from the image but the upper and lower part of the menu are connected with one another. Let me explain that with the use of a picture created in paint:
The grey area's are the 'cut-out' parts I was talking about. The upper and lower part are connected with each other.
I hope this is clear and I'm hoping for someone to help. Thanks in advance!
EDIT:
Herewith some code sample and JSFiddle, this is how far I got.
<div class="behandelingen-en-prijzen">
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
.behandelingen-en-prijzen
{
}
.behandelingen-en-prijzen ul li
{
display: inline-block;
padding: 20px;
background-color: #000;
background-color:rgba(0,0,0,0.3);
}
.behandelingen-en-prijzen ul li a
{
text-transform: uppercase;
color: #000;
}
you can do it without using images
HTML
<ul class="cutout">
<li>
home
</li>
<li>
about
</li>
<li>
contact
</li>
</ul>
CSS
body{ background: url(https://i.imgur.com/lsoomRq.jpg); }
.cutout{ list-style: none; padding: 0; border: 3px solid rgba(235, 235, 235, 0.8); }
.cutout, .cutout li{ height: 40px; line-height: 40px; overflow: hidden; }
.cutout li{ float: left; width: 33.33%; text-align: center; }
.cutout a{ display: block; margin-right: 3px; background: rgba(235, 235, 235, 0.8); color: #555; text-transform: uppercase; font-family: sans-serif; text-decoration: none;}
.cutout a:hover{background: #fff}
.cutout li:last-child{ float: right; }
.cutout li:last-child a{margin-right: 0; }
Updated the fiddle: http://jsfiddle.net/a7d9v/3/
Removed padding from li and left 1px, added padding to a and floated the li - left.
<div class="behandelingen-en-prijzen">
<ul>
<li>Home</li>
<li>About</li>
<li><a class="no-border" href="#">Contact</a></li>
</ul>
</div>
.behandelingen-en-prijzen ul {
list-style: none;
width: 100%;
}
.behandelingen-en-prijzen ul li
{
float: left;
padding: 1px;
background-color: #000;
background-color:rgba(0,0,0,0.3);
}
.behandelingen-en-prijzen ul li a
{
text-transform: uppercase;
color: #fff;
display: block;
padding: 20px;
border-right: 1px solid #fff;
}
.behandelingen-en-prijzen ul li a.no-border {
border: none;
}