im tying to make these two items inline with each other, each list item has an image and button, the button should be underneath each image: i.e
<div id="cocktails">
<ul>
<li>
<img src ="http://bokertov.typepad.com/.a/6a00d83451bc4a69e2014e8a8f894b970d-800wi" width="100px" height="100px">
<button>Select</button>
</li>
<li>
<img src ="http://bokertov.typepad.com/.a/6a00d83451bc4a69e2014e8a8f894b970d-800wi" width="100px" height="100px">
<button>Select</button>
</li>
</ul>
</div>
The CSS:
#cocktails ul{margin:0;padding:0}
#cocktails ul li{list-style-type:none;display:inline;padding:0}
#cocktails ul li img{width:150px;height:150px;display:block;float:left;padding:0 10px}
#cocktails ul li button{display:block;float:left}
but the buttons are not positioned as expected the jsfiddle is here:
http://jsfiddle.net/8KWGJ/
enclose buttons in li tags :
<div id="cocktails">
<ul>
<li>
<img src ="http://bokertov.typepad.com/.a/6a00d83451bc4a69e2014e8a8f894b970d-800wi" width="100px" height="100px">
</li>
<li> <button>Select</button>
</li>
<li>
<img src ="http://bokertov.typepad.com/.a/6a00d83451bc4a69e2014e8a8f894b970d-800wi" width="100px" height="100px">
</li>
<li> <button>Select</button>
</li>
</ul>
and comment css as shown:
#cocktails{float:left;width:419px}
#cocktails ul{margin:0;padding:0}
#cocktails ul li{list-style-type:none;display:inline;padding:0}
/*#cocktails ul li img{width:150px;height:150px;display:block;float:left;padding:0 10px}*/
/*#cocktails ul li button{display:inline;}*/
http://jsfiddle.net/8KWGJ/3/
I floated the <li> left, instead of the button and image inside it
Change the float from the image to the li.
DEMO
#cocktails ul {
margin:0;
padding:0;
}
#cocktails ul li{
list-style-type:none;
display:inline;
float: left;
padding:0;
}
#cocktails ul li img{
width:150px;
height:150px;
display:block;
padding:0 10px;
}
#cocktails ul li button {
display:block;
}
Setting your image to display:block; and the li to float:left; should solve your problem.
Example
I've removed all of your CSS and implimented only the required to solve your problem.
You can do something like this: JSFIDDLE
Change
#cocktails ul li{list-style-type:none;display:inline;padding:0}
#cocktails ul li img{width:150px;height:150px;display:block;float:left;padding:0 10px}
#cocktails ul li button{display:block;float:left}
to
#cocktails ul li{list-style-type:none;display:inline;padding:0;float:left;}
#cocktails ul li img{width:150px;height:150px;display:block;padding:0 10px}
#cocktails ul li button{display:block;margin:auto}
Add
clear:both; for the buttons and images.
Also give some margin to the button.
#cocktails{float:left;width:419px}
#cocktails ul{margin:0;padding:0}
#cocktails ul li{list-style-type:none;display:inline;padding:0;}
#cocktails ul li img{width:150px;height:150px;display:block;float:left;padding:0 10px; clear: both;}
#cocktails ul li button{display:block;float:left;clear:both; margin-left: 60px;}
http://jsfiddle.net/8KWGJ/8/
Sometimes display block does not work. So in that use clear with display:block; You can clear either left,right or both. So use clear as per the requirement.
Hope this helps.
This did the trick for me.
#cocktails ul{margin:0;padding:0}
#cocktails ul li{list-style-type:none; width:150px; float:left; margin:10px;}
#cocktails ul li img{width:150px;height:150px; }
#cocktails ul li button{ margin-left:50px; width:50px}
Related
So i'm having a huge issue with my navigation. I'm trying to add a drop down menu but no matter what I try its not working out. Below is my current HTML/CSS code and if you have any idea how to fix it please help!! I also attached a picture of what i'm actually trying to make it look like.
Here's the HTML
<div class="logo"><img src="images/original/xlablogoheader.gif" width="auto" height="130"/><span> experimental social science laboratory</span></div>
<div class="menu">
<ul>
<li>About
<ul>
<li>Mission</li>
<li> Staff</li>
</ul>
</li>
<li>Participants
</li>
<li>Researchers
</li>
<li>Connect
</li>
</ul>
</div>
</div>
Here's the CSS
/* Menu */
.menu{float:right; padding:0 20px 0 0;}
.menu ul {list-style:none; margin:0; padding:0px;}
.menu ul * {margin:0; padding:0;}
.menu ul li {float:left; padding:0 20px 0 20px; height:35px;}
.menu ul li a{font-family: 'Source Sans Pro', sans-serif;color:#fff; font-size:16px;}
.menu ul li.selected a{color:#000;}
.menu ul li a:hover{color:#000;}
.menu ul ul { display: none; position: absolute; top: 25px }
.menu ul li:hover > ul { display: inherit; color:#000;}
I have modified your code, a little bit, by adding position: relative; to menu class, also some other minor changes, so it works, please check this https://jsfiddle.net/ysmr364m/
am doing a HTML website, and I have a main menu - Home, About etc.
I have several html pages and for each page I want the menu li to change color to #E38400.
Here is my code:
<div id="nav">
<ul>
<li class="youarehere"><h3>menuITEM</h3></li>
<li><h3>menuITEM</h3></li>
<li><h3>menuITEM</h3></li>
<li><h3>menuITEM</h3></li>
<li><h3>menuITEM</h3></li>
</ul>
</div>
and my style.css code:
.header #nav ul li .youarehere {
background:#E38400; border-radius:5px; color:#FFF;
}
but the first list item still shows the same color etc. I want to use neither jQuery nor any other script, but why is this not working?
you just need to remove li or place .youarehere just with li without space :
.header #nav ul li.youarehere {
background:#E38400;
border-radius:5px;
color:#FFF;
}
Hi now your define in your css this .header #nav ul li .youarehere but actually you define this .header #nav ul li.youarehere because your apply to this class in li .
as like this
.header #nav ul li.youarehere {
background:#E38400; border-radius:5px; color:#FFF;
}
=================================
Demo
#nav ul li.youarehere {
background:#E38400; border-radius:5px; color:#FFF;
}
<div id="nav">
<ul>
<li class="youarehere"><h3>menuITEM</h3></li>
<li><h3>menuITEM</h3></li>
<li><h3>menuITEM</h3></li>
<li><h3>menuITEM</h3></li>
<li><h3>menuITEM</h3></li>
</ul>
</div>
Remove the space between li and .youarehere
like this -
.header #nav ul li.youarehere {
background:#E38400; border-radius:5px; color:#FFF;
}
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
I'm working on a dropdown box but the only thing that doenst want to work is when I hover over the word Info in the unordered list the dropdownbox is not displayed.
I know I have display:none; in ul style but can you change that to display:block; when hovered over the word info?
HTML Code:
<ul id="Menu">
<li>Home </li>
<li>Info
<ul style="display:none;">
<li>Program</li>
<li>Getting Started<li>
<li>Credits</li>
</ul>
</li>
<li>Video </li>
<li>server </li>
<li>Profile </li>
<li>Help</li>
</ul>
CSS Code:
#Menu {
list-style:none;
font-size:16px;
font-weight:Bold;
padding:14px 0 0;
width:415px;
margin-top:0;
float:left;
margin-left:0;
}
#menu { list-style:none;}
li:hover > ul {display:list-item;}
li ul { margin:0; padding:0; position:absolute;z-index:5;padding-top:6px;}
li { float:left; margin-left:10px; }
li ul li { float:none; margin:0; display:inline;}
li ul li a {display:block; padding:6px 10px; background:#333; white-space:nowrap;}
li { display: list-item; text-align: -webkit-match-parent;}
ul { border:0; font-size:100%; font:inherit;vertical-align:baseline;}
Help in advanced. any help is apreciated :)
also post a code not only telling me whats wrong thanks!
use #Menu before your css class names : DEMO
like: #Menu li:hover > ul {display:list-item;}
NOTIC: css Class names are Case-Sensitive
I am thinking this is because the html code contains an inline display:none.
In the inner <ul>, we should remove <ul style="display:none;"> in the above html.
Original Question
I have a webpage with a css menu. The problem is that the menu is displaying properly except for menu items wit a submenu. I this case the menu items not displaying consistently and the the submenu is not showing at all.
I have uploaded the page at http://prova.webuda.com/account.html. Such a problem occurs with the menu item ACCOUNT.
Also, I have looked at it with firebug and I have seen that the relavant submenu unsorted list is grayed out, which makes me suppose that there must be some parsing issue. However, from my analysis it should be fine.
What am I doing wrong? Can somebody please help me?
Edit
Css
#mainMenu
{
font-size: 0.85em;
}
#mainMenu ul
{
margin: 0;
padding: 0;
text-transform: uppercase;
}
#mainMenu ul li, #mainMenu ul li:hover
{
height:50px;
float:left;
text-align:center;
font-weight:bold;
font-size:1.7em;
overflow:hidden;
margin-left:1.05em;
margin-right:1.05em;
}
#mainMenu ul li a, #mainMenu ul li span a
{
color:brown;
text-decoration:none;
color:#006;
}
.mainSubMenu
{display:none;}
#mainMenu ul li:hover #mainMenu ul li ul{display:block;}
#mainMenu ul li ul{position: absolute;left:-1px;top:98%;}
#mainMenu ul ul ul{position: absolute;left:98%;top:-2px;}
#mainMenu ul ul{
width:119.7px;
}
Html
<div class="mainMenu" id="mainMenu">
<ul>
<li class="menuItem" id="menuItem1"> Squadra </li>
<li class="menuItem" id="menuItem2"> Biglietti </li>
<li class="menuItem" id="menuItem3"> Abbonamenti </li>
<li class="menuItem" id="menuItem4"> Ritiro </li>
<li class="menuItem" id="menuItem5"> Fidelity Card </li>
<li class="menuItem" id="menuItem7"> <span> Account </span>
<ul class="mainSubMenu">
<li class="subMenuItem"><a class="pureCssMenui" href="profilo.html">Profilo</a></li>
<li class="subMenuItem"><a class="pureCssMenui" href="datiFatturazione.html">Dati Fatturazione</a></li>
<li class="subMenuItem"><a class="pureCssMenui" href="storicoTifoso.html">Storico Tifoso</a></li>
<li class="subMenuItem"><a class="pureCssMenui" href="esci.html">Esci</a></li>
</ul>
</li>
</ul>
</div>
Most significantly the part which is not working is #mainMenu ul li:hover #mainMenu ul li ul{display:block;}
There are a few issues with your CSS. First, the # selector only works for elements that have the id set to that. For example, #menuItem applies styling to any element with id="menuItem". However, your HTML has class="menuItem", so you must use the . selector instead.
Second, when the menu does appear, it appears too far down the page for the user to see, as per #mainMenu ul li ul{position: absolute;left:-1px;top:98%;} and #mainMenu ul ul ul{position: absolute;left:98%;top:-2px;}.
Here are the corrections:
.mainMenu
{
font-size: 0.85em;
}
.mainMenu
{
margin: 0;
padding: 0;
text-transform: uppercase;
}
.mainMenu ul li, .mainMenu ul li:hover
{
height:50px;
float:left;
text-align:center;
font-weight:bold;
overflow:hidden;
margin-left:1.05em;
margin-right:1.05em;
}
.mainMenu ul li a, .mainMenu ul li span a
{
color:brown;
text-decoration:none;
color:.006;
}
.mainSubMenu
{display:none;}
.mainMenu:hover .mainSubMenu {display:block}
.mainMenu ul li ul{position: absolute;left:1px;top:2%;}
.mainMenu ul ul ul{position: absolute;left:2%;top:2px;}
.mainMenu ul ul{
width:119.7px;
}
And a working fiddle: http://jsfiddle.net/Af7SE/
Also, here is another example of a menu like yours.
The first problem is because your last <a> is nested on a <span>, try using:
<li class="menuItem" id="menuItem7">
Account
<ul class="mainSubMenu">
....
</ul>
</li>
And your menu never show because has a problem with the overflow:hidden; and the static width on your submenu, try using the next code, it will show your submenu but you will need make more changes.
#mainMenu ul li:hover ul{display:block;}
instead of
#mainMenu ul li:hover #mainMenu ul li ul{display:block;}
remove all the overflow:hidden because it hide your submenu, I make some modifications for the example:
http://jsfiddle.net/NrA8A/
#mainMenu ul {
margin: 0;
padding: 0;
text-transform: uppercase;
list-style: none; /*remove the bullets*/
}
#mainMenu ul li, #mainMenu ul li:hover {
.....
/*Remove the overflow :hidden*/
}