Stop button wrapping to newline - html

In design mode in VS the following code has all the buttons on a single row
HTML:
<!-- top -->
<div id="top">
<Label id="validCredentialsMessage" class="float-right" runat="server" ForeColor="Red" Text="" Visible="true"></Label>
<img src="images/logo.png" alt="" />
<div id="top-menu" class="float-right">
<ul class="main">
<li><a id="A1" href="home.aspx" runat="server" class="current"><span>Home</span></a> </li>
<li>
<span>Members</span>
<ul class="sub curved">
<li>Analysis</li>
<li>Results</li>
<li>Performance</li>
</ul>
</li>
<li><span>Blog</span> </li>
<li><span>Contact</span> </li>
<li><span>Account</span> </li>
<li><a id="iLogOut" runat="server" onserverclick ="LogOut_Click"><span>LogOut</span></a></li>
</ul>
</div>
</div>
<!-- //top -->
CSS:
/* top menu */
#top-menu {padding:19px 0 0 0;width:560px;}
#top-menu ul {list-style:none;padding:0;margin:0;}
#top-menu .main li, #top-menu .main li a, #top-menu .main li a span {display:block;float:left;cursor:pointer;}
#top-menu .main li a, #top-menu .main li a span {background:url(../images/top-menu-a.jpg) no-repeat 0 0;}
#top-menu .main li {position:relative;padding-bottom:4px;}
#top-menu.float-left .main li {padding-right:10px;}
#top-menu.float-right .main li {padding-left:10px;}
#top-menu .main li a {background-position:top left;padding:0 0 0 20px;color:#656565;}
#top-menu .main li a span {background-position:top right;height:25px;line-height:25px;text-align:center;padding:0 20px 0 0;font-family:LucidaGrandeBold, Arial, sans-serif;}
#top-menu .main li a:hover {background-position:bottom left;}
#top-menu .main li a:hover span, #top-menu .main li a.current span {background-position:bottom right;}
#top-menu .main li a:hover, #top-menu .main li a.current {color:#5790dc;background-position:bottom left;}
#top-menu .main .current-dynamic > a {color:#5790dc;background-position:bottom left;}
#top-menu .main .current-dynamic > a span {background-position:bottom right;}
#top-menu .sub {background:url(../images/top-menu-sub.jpg) repeat-x #fafafa;position:absolute;top:27px;left:10px;padding:15px 20px 10px 20px;border:1px solid #e0e0e0;min-width:110px;display:none;z-index:50;}
#top-menu.float-left .sub {left:0;}
#top-menu .sub li, #top-menu .sub li a, #top-mnu .sub li a span {display:block;float:none;background:none;padding:0;}
#top-menu.float-left .sub li, #top-menu.float-right .sub li {line-height:25px;padding:2px 0;}
#top-menu .sub li a {font-family:LucidaGrandeRegular, Arial, sans-serif;}
/* -- */
However, when running live the last button wraps even though there's enough room.
It's frustrating as the design view looks correct and only changes live which makes it difficult to track down which settings have an effect. Please can anybody advise a simple way to stop these buttons wrapping onto a new row?

In the first line of your css, #top-menu has a property width: 560px; which causes the buttons to wrap.
Around 605px seems to be the minimum setting here as it is the space needed by the buttons.
Check this jsFiddle.

Related

CSS hover picture transform and dont disable

I have this code:
<style>
.menypic:hover { transform:scale(1.1,1.1)}
.menu ul {list-style: none;padding: 0px;margin: 0px;}
ul.menu li {display: block;position: relative;float:left;border:0px solid #000;list-style-type: none;}
.menu li ul {display: none;border:0px;}
.menu ul li a {display: block;background: #fff;padding: 5px 5px 5px 5px;text-decoration: none;
white-space: nowrap;color: #000;border:0px; font-family: "Calibri", Times, serif;font-size: 14px;}
.menu ul li a:hover {background: #fff;}
.menu li:hover ul {display: block; position: absolute;border-bottom: solid thin #0066ff;border-left: solid thin #0066ff;border-right: solid thin #0066ff;background: #0066ff}
.menu li:hover li {float: none;}
.menu li:hover a {background: #ffffff;border:0px solid #000;}
.menu li:hover li a:hover {background: #0066ff;border:0px solid #000;color: #fff;text-decoration: none;}
#drop-nav li ul li {border-top: 0px;}
</style>
<ul>
<li class="menu">
<img src="1-4.png" class="menypic">
<ul class="menu">
<li class="menu"> Nyheter </li>
<li class="menu"> 20 1-4 </li>
</ul>
</li>
</ul>
And it works brillantly. When I hover the picture it transform to little bigger, and the new menu comes down. Works perfect. But when I hover the menu, the picture goes back to its old size. Is it possible to hold the transformation as long as I am in the menu?
You can set style for other child elements of (for e.g) menu element, while you are "on" menu element with your mouse cursor.
For e.g you can add:
.menu:hover .menypic { transform:scale(1.1,1.1);}
..and all your elements with .menypic class in .menu will be scaled while element with .menu class is in :hover state.
Here is a working fiddle: https://jsfiddle.net/eukjxuqc/3/
EDIT/UPDATE: After reading comments, I hope this is what you need.
Basically, I think this is what you need (this is not from your code, I created new example just to make things easier to understand):
ul.submenu li:hover ul.menu li, ul.menu li:hover {transform:scale(1.1,1.1);}
Also, new fiddle link: https://jsfiddle.net/Munja/eukjxuqc/5/

CSS: Menu Dropdown showing horizontally when I need vertical

I am working on a navigational menu. I have a problem with the dropdown submenus. When I hover over the submenu, it shows the entries horizontally, but I want it vertically. Can someone please show me what I can do to fix it? Thanks.
Here's a fiddle.
Here is my CSS code:
#nav {overflow:hidden;
margin:0px auto;
text-align:center;}
#nav ul li {display:inline-block;
list-style:none;
vertical-align:top;
width:100px;}
#nav>ul>li>a>img {text-align:center;
width:100px;
height:100px;}
#nav a {text-decoration:none !important;}
#nav a:hover {text-decoration:underline !important;}
#nav > ul > li > ul {display:none;
z-index:999;
position:absolute;}
#nav li:hover ul {display:block;}
.submenu li {border-bottom:solid 1px #333333;
font-size:12px;}
.submenu img {display:inline;
vertical-align:middle;
width:25px;
height:25px;
float:left;
margin:5%}
.submenu li:hover {background-color:#CCC;}
Here is my HTML Code:
<div id="nav">
<ul>
<li>
<a href="">
<img src="images/placeholder.png">
Home
</a>
</li>
<li>
<a href="">
<img src="images/placeholder.png">
Menu w/ Submenu
</a>
<ul class="submenu">
<li>
<a href="">
<img src="images/placeholder.png">
Submenu Item
</a>
</li>
<li>
<a href="">
<img src="images/placeholder.png">
Submenu Item
</a>
</li>
</ul>
</li>
<li>
<a href="">
<img src="images/placeholder.png">
Menu Item
</a>
</li>
<li>
<a href="">
<img src="images/placeholder.png">
Menu Item
</a>
</li>
</ul>
</div>
The easiest way is to comment position:absolute; in your submenu.
#nav > ul > li > ul {display:none;
z-index:999;
/* position:absolute;*/}
Check this in action:
http://jsfiddle.net/5Kjg4/
Here is a DEMO
You have css class #nav ul li which makes sub menu align horizonatally..
one way to solve this is using !important property and ovveriding display property.
Better solution would be using psuedo classes
#nav ul li:not(.subItem) {display:inline-block;
list-style:none;
vertical-align:top;
width:100px;}
.subItem{
display:block;
}
this way inline-block is not applied to subItems.
you can add this to you css
// if you need position: absolute
#nav ul li ul li {
float: left; // float left for inner li
display: inline-block;
}
#nav ul li ul {
width: 100px; // set width for you'r ul
}
Change the following css in your code and it should work fine.
Problem was that you are displaying inline-block for all ul li.
Take a look at fiddle DEMO
#nav ul li {
display:inline-block;
list-style:none;
vertical-align:top;
width:100px;
}
To
#nav > ul > li {
display:inline-block;
list-style:none;
vertical-align:top;
width:100px;
}
Here is the solution to you problem
You just had to add display:block and float to your submenu li

3 level css submenu hover state

I got a css menu with 3 levels. You can see my actual code right here http://jsfiddle.net/7rMgu/
As you can see, my secondary level don't keep the light blue background when navigating in the 3rd level. I've looked over the website for similar thread but I just found similar problems with only 2 levels. Also, can someone explain when I should use the '>' in css as I'm a bit confused.
CSS
html{height:100%;background-color:#0d497d;}
body{width:100%;height:100%;margin:0px;padding:0px;color:#575757;font:0.75em "Lucida Grande","Lucida Sans Unicode",Helvetica,Arial,Verdana,sans-serif;}
div.menuAdmin ul{margin:0;padding:0;float:right;height:100%;}
div.menuAdmin ul li{display:block;float:left;height:23px;margin-bottom:0;}
div.menuAdmin ul li a{color:#fff;padding:0.1em 0.3em 0.2em 0.3em;text-decoration:none;font-size:12px;display:block;margin:0.85em 0em 0em 0em;width:130px;background-color: #0d497d;border:1px solid #78B9EF;border-radius:5px;}
div.menuAdmin ul li:hover a{color:#000;border-radius:5px;background-color:#78B9EF;}
div.menuAdmin ul li ul{display:none;}
div.menuAdmin ul li:hover > ul {display:block;height:20px;width:139px;position:absolute;margin:0;}
div.menuAdmin ul li:hover > ul li a {line-height: 20px;color:#fff;text-decoration: none;margin: 0;padding-bottom: 0.1em;background-color: #0d497d;border:1px solid #78B9EF;border-radius:5px;}
div.menuAdmin ul li:hover > ul li a:hover {color:#000;text-decoration:none;text-shadow:none;background-color: #78B9EF;}
div.menuAdmin ul ul li:hover > ul {display:block;position:absolute;left:100%;top:0;width:139px;}
div.menuAdmin ul > ul > ul li:hover > a {color:#444;background-color:#78B9EF;}
HTML
<div class='menuAdmin'>
<ul>
<li>
<a href=''>A</a>
<ul>
<li>
<a href=''>1</a>
<ul>
<li>
<a href=''>A1</a>
</li>
<li>
<a href=''>A2</a>
</li>
<li>
<a href=''>A3</a>
</li>
<li>
<a href=''>A4</a>
</li>
</ul>
</li>
<li>
<a href=''>2</a>
</li>
<li>
<a href=''>3</a>
</li>
<li>
<a href=''>4</a>
</li>
</ul>
</li>
<li>
<a href=''>B</a>
</li>
<li>
<a href=''>C</a>
</li>
<li>
<a href=''>D</a>
</li>
</ul>
</div>
Thanks
To keep the :hover effect you need to make the change on hover the li element not just the a tag, so you have this:
div.menuAdmin ul li:hover > ul li a:hover
Must be:
div.menuAdmin ul li:hover > ul li:hover > a
With the hover on the li element keeps the effect since the ul wich is the submenu is part of the li.
Check the Demo http://jsfiddle.net/7rMgu/1/.
Now your second question when use this >; when you only want to affect the direct children, it let you avoid the same style on nested elements. An example with the same selector I have fix, if you remove the last > check what happen:
http://jsfiddle.net/7rMgu/3/
It changes all a inside the li even if are inside some nested elements.
Here is an updated fiddle:
http://jsfiddle.net/ryanwheale/7rMgu/2/
Essentially, you always want the :hover selector to be on the LI. You had it on the A.
Also, the > selector in CSS means "direct children"... best explained by example:
<div class="my-div">
<p>This should be blue</p>
<div>
<p>This should be green</p>
</div>
</div>
and this css:
.my-div p { color: green }
.my-div > p { color: blue }
You have a few redundant rules, I've tried to boil it down for you:
.menuAdmin ul{ /* all lists */
margin:0;
padding:0;
list-style: none;
}
.menuAdmin li { /* all list items */
margin:0;
padding:0;
}
.menuAdmin > ul { /* first level list*/
float: right;
}
.menuAdmin > ul > li { /* first level list items*/
float: left;
}
.menuAdmin ul ul { /* second and third level list */
position: absolute; /* remove from flow */
display: none; /* hide by default */
}
.menuAdmin ul ul ul { /* third level list */
top: 0;
left: 100%;
}
.menuAdmin li:hover > ul { /* first level list inside of a hovered item */
display: block;
}
.menuAdmin a { /* all links */
color:#fff;
padding:0.1em 0.3em 0.2em 0.3em;
text-decoration:none;
font-size:12px;
display:block;
width:130px;
background-color: #0d497d;
border:1px solid #78B9EF;
border-radius:5px;
}
.menuAdmin li:hover > a { /* links inside hovered list item */
color:#000;
background-color:#78B9EF;
}
As already answered, > means "child" (a.k.a. direct descendant)
See demo at http://jsfiddle.net/7rMgu/5/

css dropdown menu in navigation bar

I have a navigation bar with 6 elements. The first two of them have an additional dropdown menu, which should be displayed on mouse over. The problem is this menu is displayed when the mouse is over the space of the dropdown menu and not when the mouse is over the navigation bar element.
(if it's not clear you can have a look at www.buscocolegio.com and approach the mouse from bottom to top to the first two elements of the navigation bar, you will see the dropdown menu is displayed before reaching the navigation bar element)
here are the JSP and CSS I have implemented:
<div id="main-nav">
<ul id="navbar" class="main-nav-btn">
<li class="buscador-btn">
Buscador Colegios
<ul>
<li>España</li>
<li>Exterior</li>
</ul>
</li>
<li class="buscador-btn">
Opinión Usuarios
<ul>
<li>Ranking</li>
<li>Comentarios</li>
</ul>
</li>
<li class="criterios-btn">Criterios de Selección</li>
<li class="admision-btn">Admisión por Comunidades</li>
<li class="ayuda-btn">Foro</li>
<li class="contacto-btn">Contacto</li>
</ul>
</div><!--MAIN NAV ENDS-->
and CSS
#CHARSET "UTF-8";
#main-nav {height: 51px;width: 100%;background-color: #204865;}
.main-nav-btn { padding: 0; width: 775px;margin: 0 auto;}
.main-nav-btn li {float: left;text-align: center;line-height: 51px;margin-right: 1px;list-style-type: none;}
.main-nav-btn li a {color: #FFF;text-align: center;text-decoration: none;height: 51px;display: block;vertical-align: 30px;}
.main-nav-btn li:hover{background-position: center -51px;background-repeat: no-repeat;}
li.buscador-btn {height: 51px;width: 140px;background-image: url(../img/botones/buscador_colegios.png);background-repeat: no-repeat;}
li.buscador-exterior-btn {background-image: url(../img/botones/buscador_colegios_exterior.png);background-repeat: no-repeat;height: 51px;width: 185px;}
li.criterios-btn {background-image: url(../img/botones/criterios_btn.png);background-repeat: no-repeat;height: 51px;width: 145px;}
li.admision-btn {background-image: url(../img/botones/buscador_colegios_exterior.png);background-repeat: no-repeat;height: 51px;width: 185px;}
li.ayuda-btn, li.contacto-btn {background-image: url(../img/botones/ayuda_btn.png);background-repeat: no-repeat;height: 51px;width: 76px;}
#navbar li:hover ul, #navbar li.hover ul {display: block;position: absolute;margin: 0;padding: 0;}
#navbar li:hover li, #navbar li.hover li {float: none;}
#navbar li:hover li a, #navbar li.hover li a {background-color: #B2DFEE;border-bottom: 1px solid #fff;color: #000;width: 140px;height: 35px;text-align: left;padding-left: 5px;line-height: 35px;position: relative;z-index: 1;}
#navbar li:hover li a:hover, #navbar li.hover li a:hover {background-color: #009ACD;border-bottom: 1px solid #fff;color: #fff;}
Add this to your CSS
.main-nav-btn li ul {
display:none;
}
FIDDLE DEMO >>
Hope it will help.
Try this :
CSS:
li.buscador-btn > ul{
display:none;
}
li.buscador-btn:hover > ul{
display:block;
}

CSS Menu List double Nesting

I want a menu with a mouseover show property Inside it I want to use a second unordered list to show the second hidin menu. The problem is that my first rule overwrites the second menus properties and all list items show .
This is my menu html.
<ul id="menu">
<li class="current">ANASAYFA</li>
<li>HAKKIMIZDA</li>
<li>HİZMETLERİMİZ
<ul>
<li>Eğitim Hizmetlerimiz
<ul class="menu2">
<li class="current">Ygs-Lys hazırlık programları</li>
<li>Sbs'ye Hazırlık programı'</li>
<li>Ana sınıg 1'e 1 test programı</li>
<li>Okul destek programı</li>
</ul>
</li>
<li>Neurofeedback</li>
<li>Bioofeedback</li>
</ul>
</li>
<li>GALERİ</li><li>STYLINGS
<li>SANAL TUR</li>
<li>BİZE ULAŞIN
<ul>
<li>İletişim Formu</li>
<li>İletişim Bilgileri</li>
</ul>
</li>
</ul>
And this is my css file for menu orginal and menu2 nested ul
#sidebar #sidebar-content #menu2 {margin: 0px auto;width: 100%;z-index: 30;float: left;}
#sidebar #sidebar-content #menu2 li {line-height: 32px;text-align: center;width: 100%;background-image: url('../images/menu_li.png');
background-repeat: no-repeat;background-position: bottom center;clear: left;float: left;color: #999999;}
#sidebar #sidebar-content #menu2 li a, #sidebar #sidebar-content #menu2 .current ul li a {font-size: 12px;font-weight: normal;display: block;color: #999999;}
#sidebar #sidebar-content #menu2 li:hover{background-image: url('../images/menu_li_hover.png');}
#sidebar #sidebar-content #menu2 li a:hover, #sidebar #sidebar-content #menu2 .current a, #sidebar #sidebar-content #menu2 li ul li a:hover{color: #ffffff; }
#sidebar #sidebar-content #menu2 li ul{display: none;}#sidebar #sidebar-content #menu2 li ul li{background-image: url('../images/menu_subli.png');}
#sidebar #sidebar-content #menu2 li ul li a{font-size: 11px;}
Can you show me a way to make it work?
You can prevent your first rule to override properties using
menu > li { /* css properties */ }
which will just affect the immediate li's
Or you can also use something like this -
#menu2 ul li { /* write the css again so the override does not happen */ }