Change priority for drawing border - html

I want draw <div> border over <li> border.
Now it see like that:
But i want draw that:
All my code on JsFiddle:
#mainmenu ul ul {
display: none;
}
#mainmenu ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}
#mainmenu ul li {
list-style-type: none;
text-align: center;
width: 120pt;
height: 20pt;
padding: 10pt 0pt 10pt 0pt;
border: 2px gray solid;
}
#mainmenu ul li:hover {
background-color: gray;
}
#mainmenu ul li:hover ul {
position: absolute;
top: 10px;
left: 130pt;
display: block;
}
#mainmenu h1 {
font-size: 14pt;
margin: 0px;
}
#mainmenu {
display: inline-block;
border: 2px red solid;
}
<div id="mainmenu">
<ul>
<li>
<h1>Семинар 1</h1>
<ul>
<li>Задача 1</li>
<li>Задача 2</li>
<li>Задача 3</li>
</ul>
</li>
<li>
<h1>Семинар 2</h1>
<ul>
<li>Задача 1</li>
<li>Задача 2</li>
<li>Задача 3</li>
</ul>
</li>
</ul>
</div>
Big thanks for your response!

Based on your screenshot, I'm guessing you're trying to change the border-color of the left-most boxes.
Rather than "covering" up the gray border with a red one, I'd recommend specifically targeting those top-level <li>s with CSS, and setting the border of those elements to red. You can use the CSS direct descendant selector to do that:
#mainmenu > ul > li {
border: 2px solid red;
}
Full Example Below (click "run code snippet"):
#mainmenu ul ul {
display: none;
}
#mainmenu ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}
#mainmenu ul li {
list-style-type: none;
text-align: center;
width: 120pt;
height: 20pt;
padding: 10pt 0pt 10pt 0pt;
border: 2px gray solid;
}
#mainmenu > ul > li {
border: 2px solid red;
}
#mainmenu ul li:hover {
background-color: gray;
}
#mainmenu ul li:hover ul{
position: absolute;
top: 10px;
left: 130pt;
display: block;
}
#mainmenu h1 {
font-size: 14pt;
margin: 0px;
}
#mainmenu {
display: inline-block;
}
<div id="mainmenu">
<ul>
<li><h1>Семинар 1</h1>
<ul>
<li>Задача 1</li>
<li>Задача 2</li>
<li>Задача 3</li>
</ul>
</li>
<li><h1>Семинар 2</h1>
<ul>
<li>Задача 1</li>
<li>Задача 2</li>
<li>Задача 3</li>
</ul>
</li>
</ul>
</div>

Your Image:
From your image (that I have posted above), I believe you are looking for something like this:
#mainmenu ul ul {
display: none;
}
#mainmenu ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}
#mainmenu ul li {
list-style-type: none;
text-align: center;
width: 120pt;
height: 20pt;
padding: 10pt 0pt 10pt 0pt;
}
ul li ul li {
border: 2px gray solid;
margin-left:6px;
}
#mainmenu ul li:hover {
background-color: gray;
}
#mainmenu ul li:hover ul {
position: absolute;
top: 10px;
left: 130pt;
display: block;
}
#mainmenu h1 {
font-size: 14pt;
margin: 0px;
z-index:2;
}
#mainmenu {
display: inline-block;
border: 6px red solid;
}
<div id="mainmenu">
<ul>
<li>
<h1>Семинар 1</h1>
<ul>
<li>Задача 1</li>
<li>Задача 2</li>
<li>Задача 3</li>
</ul>
</li>
<li>
<h1>Семинар 2</h1>
<ul>
<li>Задача 1</li>
<li>Задача 2</li>
<li>Задача 3</li>
</ul>
</li>
</ul>
</div>

Related

why my sub menu is not working in html css

I have created my nav bar which was working fine but now i tried to add sub menu in my navbar and its not showing sub menu on hover. kindly check and correct me.
First I added <ul> in my <li> tag then I added css to hide nested <ul> then I tried to show <ul> on hover <li>
*{
margin: 0;
padding: 0;
}
nav{
background-color: red;
}
ul{
background-color: purple;
width: 50%;
}
nav ul li {
list-style: none;
padding: 5px;
display: inline-block;
}
nav ul li a{
text-decoration: none;
color:black;
font: bold 12px Arial;
}
nav ul li:hover{
background-color: blue;
color: red;
}
nav ul li:hover a{
color: red;
}
ul li ul {
display: none;
position:absolute;
}
nav ul li:hover ul {
display:block;
}
<nav>
<ul>
<li> Home</li>
<li> About Us</li>
<li> Contact Us</li>
<li> Privacy Policy</li>
<li>
<ul>
<li>Submenu 1</li>
<li>Submenu 2</li>
<li>Submenu 3</li>
<li>Submenu 4</li>
</ul>
</li>
</ul>
</nav>
Looks like your <li> wrap is incorrect!
here is the fiddle
After Privacy Policy you have created another <li> that shouldn't be needed. you have to wrap the sub-menus with in privacy policy tag not a new one that is one of the reason why the css was not showing data as expected and you were almost there regarding CSS I just fixed it for you! hope it helps.
* {
margin: 0;
padding: 0;
}
nav {
height: 30px;
}
nav ul {
display: block;
position: relative;
z-index: 100;
}
nav ul li {
float: left;
list-style: none;
margin: 0;
padding: 0;
}
nav ul li ul {
display: none;
}
nav ul li a {
width: 100px;
height: 30px;
display: block;
text-decoration: none;
text-align: center;
line-height: 30px;
background-color: black;
color: white;
}
nav ul li a:hover {
background-color: red;
}
nav ul li:hover ul {
position: absolute;
top: 30px;
display: block;
width: 100px;
}
nav ul li:hover ul li {
display: block;
}
<nav>
<ul>
<li> Home</li>
<li> About Us</li>
<li> Contact Us</li>
<li> Privacy Policy
<ul>
<li>Submenu 1</li>
<li>Submenu 2</li>
<li>Submenu 3</li>
</ul>
</li>
</ul>
</nav>
Why don't you start from this working snippet and try to change data according to your needs :)
HTML Sub-Nav
*{
margin: 0;
padding: 0;
}
nav{
background-color: red;
}
ul{
background-color: purple;
width: 50%;
}
nav ul li {
list-style: none;
padding: 5px;
display: inline-block;
}
nav ul li a{
text-decoration: none;
color:black;
font: bold 12px Arial;
}
nav ul li:hover{
background-color: blue;
color: red;
}
nav ul li:hover a{
color: red;
}
ul li ul {
display: none;
position:absolute;
}
nav ul li:hover ul {
display:block;
}
<nav>
<ul>
<li> Home</li>
<li> About Us</li>
<li> Contact Us</li>
<li> Privacy Policy</li>
<li>
test
<ul>
<li>Submenu 1</li>
<li>Submenu 2</li>
<li>Submenu 3</li>
<li>Submenu 4</li>
</ul>
</li>
</ul>
You have to add an anchor tag in the sub nav you have created. Because currently those sub-tabs are created but are not associated with any super-tab.
Subnav
So add this above your sub-nav code. You are good to go.

How can i add a sub-sub menu with CSS

Im trying to do a sub-sub menu in a webpage. I tried following the help in this post: how do I make a sub sub menu with css? but to be honest i didnt understand what code i had to add in each class and when i tried it didnt show anything. Here is the code of the menu:
<div class="l7menu">
<ul class="dpdown">
<li class="mainlist">Hombres
<ul class="sub_menu">
Prueba
Here goes the sub-submenu
<ul>
<li> Item 1 </li>
<li> Item 2 </li>
</ul>
</ul>
</li>
</ul>
</div>
Also the CSS of the classes are these ones (The sub_menu and l7menu class dont have any style applied):
.mainlist {
border-bottom: 2px solid #EAD704;
background: none;
margin-left: 2px !important;
}
.mainlist:hover {
color: #EAD704 !important;
}
ul.dpdown {
float: right;
position: relative;
z-index: 1000;
}
ul.dpdown li {
font-weight: bold;
float: left;
zoom: 1;
display: inline;
line-height: 20px;
list-style: none outside none;
margin-left: -25px;
}
ul.dpdown a:hover {
color: #EAD704;
}
ul.dpdown a:active {
color: #FFFFFF;
}
ul.dpdown li a {
color: #e8e8e8;
display: block;
padding-bottom: 4px;
text-align: center;
width: 150px;
}
ul.dpdown li:last-child a {
border-right: none;
} /* Doesn't work in IE */
ul.dpdown li.hover, ul.dpdown li:hover {
color: black;
position: relative;
}
ul.dpdown li.hover a {
color: white;
}
/*
LEVEL TWO
*/
ul.dpdown ul {
width: 150px;
visibility: hidden;
position: absolute;
top: 100%;
left: 0;
}
ul.dpdown ul li {
font-weight: normal;
background: #333;
color: #000;
float: none;
}
/* IE 6 & 7 Needs Inline Block */
ul.dpdown ul li a {
background-color: #101010;
border-right: medium none;
display: inline-block;
margin-top: 2px;
padding: 10px 0;
width: 150px;
font-size: 13px;
color: #999999;
}
ul.dpdown ul li a:hover {
background-color: #222222;
}
/*
LEVEL THREE
*/
ul.dpdown ul ul {
left: 100%;
top: 0;
}
ul.dpdown li:hover > ul {
visibility: visible;
}
As always thank you very very much !
Here's a FIDDLE, I fixed your CSS a little.
Your HTML should look like this
<div class="l7menu">
<ul class="dpdown">
<li class="mainlist">Hombres
<ul class="sub_menu">
<li>Prueba</li>
<li>Here goes the sub-submenu
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
</li>
</ul>
</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>

align ul next to each other dropdown menu

I have the next fiddle: http://jsfiddle.net/cristi_mvp/e8UkN/4/
I want the columns to be displayed next to each other, instead of one over another.
Each column has different widths.
I tried different things but they dont work.
Also I do not want to use css column.
It should be simple, but i just can't find the answer.
Thank you.
Here is the HTML code:
<div class="header-main">
<div class="header-main-menu">
<ul class="menu">
<li> <a href='#' title='Menu 1'> Menu 1</a>
<ul>
<li>Column 1 lenght xxxx</li>
<li>Column 1</li>
<li>Column 1</li>
<li>Column 1</li>
<li>Column 1</li>
<li>Column 1</li>
</ul>
<ul>
<li>Column 2 lenght</li>
<li>Column 2</li>
<li>Column 2</li>
<li>Column 2</li>
</ul>
<ul>
<li>Column 3</li>
<li>Column 3</li>
<li>Column 3</li>
<li>Column 3</li>
<li>Column 3</li>
</ul>
</li>
<li> <a href='#' title='Menu 2'> Menu 2</a>
<ul>
<li>Column 1-2</li>
<li>Column 1-2</li>
<li>Column 1-2</li>
<li>Column 1-2</li>
</ul>
<ul>
<li>Column 2-2</li>
<li>Column 2-2</li>
<li>Column 2-2</li>
</ul>
</li>
</ul>
</div>
</div>
Here is my css:
.header-main-menu .menu {
color: #fff;
float: left;
margin: 0;
}
.header-main-menu .menu li {
display: inline-block;
float: left;
position: relative;
margin: 0;
padding: 0;
}
.header-main-menu .menu li a {
display: block;
color: #00000;
text-decoration: none;
font-size: 15px;
line-height: 15px;
height: 20px;
padding: 10px 24px 6px 10px;
display: block;
}
.header-main-menu .menu ul {
background-color:rgba(0, 0, 0, 0.9);
position: absolute;
left: -9999px;
/* Hide off-screen when not needed (this is more accessible than display:none;) */
-webkit-border-radius: 0 0 3px 3px;
border-radius: 0 0 3px 3px;
z-index: 5000;
}
.header-main-menu .menu ul li {
/*padding-top: 1px;*/
/* Introducing a padding between the li and the a give the illusion spaced items */
float: none;
background-image: none;
display: block;
min-width: 120px;
}
.header-main-menu .menu ul a {
white-space: nowrap;
/* Stop text wrapping and creating multi-line dropdown items */
display: block;
font-size: 13px;
line-height: 13px;
padding: 6px 24px 2px 14px;
}
.header-main-menu .menu li:hover ul {
/* Display the dropdown on hover */
left: 0;
/* Bring back on-screen when needed */
fload:left;
}
.header-main-menu .menu li:hover a {
/* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */
}
.header-main-menu .menu li:hover ul a {
/* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
text-decoration: none;
background: none;
}
.header-main-menu .menu li:hover ul li a:hover {
/* Here we define the most explicit hover states--what happens when you hover each individual link. */
background: #FF0000;
}
.header-main-menu .menu li a:hover {
background-color: #000;
}
.header-main-menu .menu li:hover {
background: #000;
}
.header-main-menu .menu ul li:hover {
background: none;
}
Please add padding: 0 to your code. Like this:
.header-main-menu .menu ul {
color: #fff;
float: left;
margin: 0;
padding: 0;
}
.menu
{
display:block;
}
ul
{
list-style-type:none;
}
ul li
{
float:left;
width:80px;
padding:10px;
background-color:#003366;
color:white;
text-align:center;
}
a
{
color:white;
text-decoration:none;
}
ul li ul
{
display:none;
}
ul li:hover ul
{
display:block;
margin-left:-50px;
}
fiddle

Accessible HTML5/CSS3 dropdown menu without Javascript

I have created a dropdown menu using pure css, which works fine with a mouse, but I would like to make it more accessible via the keyboard. I don't want to use Javascript to do this.
Here is a snippet of the html code, and a jsfiddle:
<nav>
<ul>
<li>Home</li>
<li>About us »
<ul>
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
<li>Option 4</li>
<li>Option 5</li>
</ul>
</li>
</ul>
</nav>
And here is the CSS:
BODY {
font-family : Arial, Helvetica, Swiss, Geneva, Sans-serif;
font-size: 0.8em;
width: 795px;
margin: 0px auto;
padding: 0px;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul, nav ul li:focus > ul, nav ul li:active > ul {
display: block;
}
nav ul {
background: #696969;
padding: 0px 0px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
border-bottom: 1px solid #FFF;
}
nav ul li:hover, nav ul li:focus, nav ul li:active {
background: #F8A509;
}
nav ul li:hover a, nav ul li:focus a, nav ul li:active a {
color: #fff;
}
nav ul li a {
display: block;
padding: 4px 14px;
color: #fff;
text-decoration: none;
}
nav ul ul {
background: #BDD575;
padding: 0px;
position: absolute;
top: 100%;
-moz-box-shadow: 2px 2px 4px 0px rgba(0,0,0,0.20);
-webkit-box-shadow: 2px 2px 4px 0px rgba(0,0,0,0.20);
box-shadow: 2px 2px 4px 0px rgba(0,0,0,0.20);
}
nav ul ul li {
float: none;
border-bottom: 1px solid #FFF;
position: relative;
}
nav ul ul li a {
padding: 4px 14px;
color: #fff;
white-space: nowrap;
border-right: 1px solid #FFF;
}
nav ul ul li a:hover, nav ul ul li a:focus, nav ul ul li a:active {
background: #9ED112;
color: #fff;
}
nav ul ul ul {
position: absolute; left: 100%; top:0;
}
Any ideas where I am going wrong?
TIA for any helpful advice.
The W3C's draft specification for Accessible Rich Internet Applications (WAI-ARIA) makes it possible to supplement HTML with attributes that explicitly communicate the roles, states, and properties of the various parts that make up a menu system. As assistive technology (AT) users interact with the menu, ARIA passes updated information to their AT, and their AT then communicates that information in meaningful ways.
See more about on Accessible Dropdown Menus
Working Demo
Markup
<nav role="navigation" aria-label="Main menu">
<ul id="nav" role="menubar" aria-hidden="false">
<li role="menuitem" aria-haspopup="false">Home</li>
<li tabindex="0" aria-haspopup="true">About us »
<ul data-test="true" role="menu" aria-hidden="true">
<li role="menuitem">Option 1</li>
<li role="menuitem">Option 2</li>
<li role="menuitem">Option 3</li>
<li role="menuitem">Option 4</li>
<li role="menuitem">Option 5</li>
</ul>
</li>
</ul>
</nav>

How do i get my drop down menu items the same size as the nav bar parent?

I am trying to make a drop down menu using only CSS, but i'm having a hard time getting the dropdown menu the same size (width and height) as it's parent:
Working fiddle: HERE
The <nav> section from my HTML:
<nav>
<ul>
<li>Home</li>
<li>Menu With Menus
<ul>
<li>opt 1</li>
<li>opt 2</li>
<li>opt 3</li>
</ul>
</li>
<li>Whatnot</li>
</ul>
</nav>
The CSS:
nav ul {
position: relative;
display: inline-table;
list-style: none;
}
nav ul li {
float:left;
list-style-type: none;
}
nav ul li a {
background-color: #dae8ec;
color: rgb(233,78,31);
display: block;
font-weight: bold;
margin: 0 auto;
padding: 9px 18px 9px;
text-decoration: none;
border: 1px solid black;
border-radius: 2px;
}
nav ul ul {
display: none;
position: absolute;
top: 100%;
}
nav ul li:hover > ul {
display: block;
}
nav ul ul li {
float: none;
position: relative;
}
nav ul ul li a {
padding: 7px 30px;
color: rgb(233,78,31);
}
nav ul li a:hover {
background: rgb(138, 92, 132);
color:#dae8ec;
}
Any suggestions? Thanks.
Js Fiddle Demo
<nav>
<ul>
<li>Home</li>
<li>Menu Withs
<ul>
<li>opt 1</li>
<li>opt 2</li>
<li>opt 3</li>
</ul>
</li>
<li>Whatnot</li>
</ul>
</nav>
Cheers !!