Vertical Align images inside li Chrome Issue - html

I want to vertically align images inside li, My code works fine in firefox but not in chrome. Can any body help me with this?
Here is the HTML:
<div class="brands container content">
<ul id="brandlogo">
<li><img src="https://images-na.ssl-images-amazon.com/images/I/12MlwaGE42L.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/12rC5bPL82L.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/220GuD5uB5L.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/12qBKSlxODL.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/127dR7ho7TL.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/22gR5V1VEFL.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/22Sr0En0GzL.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/12JRdD3GOjL.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/22bm9-FDvpL.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/12mGjpXipJL.png" alt=""/></li>
<li><img src="https://images-na.ssl-images-amazon.com/images/I/22D0pbgaokL.png" alt=""/></li>
</ul>
</div>
and CSS:
#brandlogo {
text-align: center;
padding: 0px;
margin: 30px 0px 0px;
position: relative;
list-style: outside none none;
}
#brandlogo li {
border: 1px solid #DDD;
float: none;
display: inline-block;
padding: 0px 35px;
width: auto;
margin: 10px 10px 10px 0px;
height: 150px;
line-height: 150px;
border-radius: 5px;
}
#brandlogo li a {
float: none;
width: 100%;
}
#brandlogo li a img {
vertical-align: middle;
}
http://jsbin.com/wizati/1/edit?html,css,output
Thanks in advance.

Add vertical-align: middle; to li element:
#brandlogo {
text-align: center;
padding: 0px;
margin: 30px 0px 0px;
position: relative;
list-style: outside none none;
}
#brandlogo li {
border: 1px solid #DDD;
float: none;
display: inline-block;
padding: 0px 35px;
width: auto;
margin: 10px 10px 10px 0px;
height: 150px;
line-height: 150px;
border-radius: 5px;
vertical-align: middle;/*Add vertical align middle*/
}
#brandlogo li a {
float: none;
width: 100%;
}
#brandlogo li a img {
vertical-align: middle;
}
<div class="brands container content">
<ul id="brandlogo">
<li>
<a href="http://scrub-market.hostedbywebstore.com/Alegria/b/11442638011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/12MlwaGE42L.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Cherooke/b/11442639011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/12rC5bPL82L.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Dickies/b/11442640011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/220GuD5uB5L.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Healing-Hands-Purple-Label/b/11442641011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/12qBKSlxODL.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Heart-Soul/b/11442643011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/127dR7ho7TL.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Koi/b/11442644011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/22gR5V1VEFL.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/New-Balance/b/11442645011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/22Sr0En0GzL.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Nurse-Mate/b/11442646011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/12JRdD3GOjL.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Renova/b/11442647011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/22bm9-FDvpL.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Skechers/b/11442648011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/12mGjpXipJL.png" alt="" />
</a>
</li>
<li>
<a href="http://scrub-market.hostedbywebstore.com/Wonderwink/b/11442649011" class="">
<img src="https://images-na.ssl-images-amazon.com/images/I/22D0pbgaokL.png" alt="" />
</a>
</li>
</ul>
</div>

CSS
#brandlogo li a {
float: none;
width: 100%;
height: inherit;
display: table-cell;
vertical-align: middle;
}
My using the above CSS property we just make the a tag to act as a table cell and occupy full height of its parent and vertical-align:middle its childern
JS BIN DEMO

Add a float: left; as shown:
#brandlogo li {
border: 1px solid #DDD;
float: left;
display: inline-block;
padding: 0px 35px;
width: auto;
margin: 10px 10px 10px 0px;
height: 150px;
line-height: 150px;
border-radius: 5px;

Related

How to align text with img in ul li HTML

I want to make a page similar to Instagram to train techniques etc, but I can not align the texts with the photos, follow the code and pictures.
.div-stories {
width: 100%;
height: 104px;
background: #FAFAFA;
position: absolute;
top: 45px;
border-bottom: 1px solid rgba(0, 0, 0, .1);
}
.stories {
overflow: auto;
white-space: nowrap;
scrollbar-width: none;
}
.stories ul {
list-style: none;
width: auto;
margin-top: -5px;
}
.stories ul li {
display: inline-block;
}
.pic-stories {
width: 58px;
height: 58px;
border-radius: 50px;
margin-left: 15px;
margin-top: 10px;
z-index: 5;
}
.more-stories {
position: static;
top: 63px;
left: 37px;
margin-left: -15px;
width: 18px;
height: 18px;
}
.txt-stories ul {
list-style: none;
}
.txt-stories ul li {
display: inline-block;
position: relative;
margin-left: 23px;
}
.effect-stories {
width: 70px;
height: 70px;
border: double 6px white;
border-radius: 50px;
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #C82D8D, #F99C4B);
background-origin: border-box;
background-clip: content-box, border-box;
}
<div class="div-stories">
<nav class="stories">
<ul>
<li><img class="pic-stories" src="img/stories1.jpg"><img class="more-stories" src="img/more-stories.webp"></li>
<li><img class="pic-stories effect-stories" src="img/stories2.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories3.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories4.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories5.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories6.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories7.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories8.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories9.jpg"></li>
</ul>
<nav class="txt-stories">
<ul>
<li>
<p class="text-stories">Seu story</p>
</li>
<li>
<p class="text-stories">shinigami...</p>
</li>
<li>
<p class="text-stories">italo_rmds</p>
</li>
<li>
<p class="text-stories">rodrigotea...</p>
</li>
<li>
<p class="text-stories">princejack...</p>
</li>
<li>
<p class="text-stories">viainfinda</p>
</li>
<li>
<p class="text-stories">designer.bot</p>
</li>
<li>
<p class="text-stories">mjacksonh</p>
</li>
<li>
<p class="text-stories">reyzeryt</p>
</li>
</ul>
</nav>
</nav>
</div>
I'm learning html and css
This might help you; using Flexbox you can align items either in rows or columns pretty easily without defining exact sizes. This also helps keep the names aligned even if they are not the same size.
The width I set on the container is just to demonstrate how each item spreads out and aligns with its name; you can set this however you want
.container {
overflow-x: auto;
width: 1000px;
}
.stories {
display: flex;
list-style: none;
padding: 0;
flex-wrap: nowrap;
justify-content: space-between;
}
.item {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.pic {
border-radius: 50%;
border: double 6px white;
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #C82D8D, #F99C4B);
background-origin: border-box;
background-clip: content-box, border-box;
}
<div class="container">
<ul class="stories">
<li class="item">
<img src="https://via.placeholder.com/80" alt="" class="pic">
<span>username</span>
</li>
<li class="item">
<img src="https://via.placeholder.com/80" alt="" class="pic">
<span>username large</span>
</li>
<li class="item">
<img src="https://via.placeholder.com/80" alt="" class="pic">
<span>username</span>
</li>
<li class="item">
<img src="https://via.placeholder.com/80" alt="" class="pic">
<span>username</span>
</li>
<li class="item">
<img src="https://via.placeholder.com/80" alt="" class="pic">
<span>username very large</span>
</li>
<li class="item">
<img src="https://via.placeholder.com/80" alt="" class="pic">
<span>username</span>
</li>
<li class="item">
<img src="https://via.placeholder.com/80" alt="" class="pic">
<span>username</span>
</li>
</ul>
</div>
If you remove height: 104px; from .div-stories it will wrap your content inside the gray background.
.div-stories {
width: 100%;
background: #FAFAFA;
position: absolute;
top: 45px;
border-bottom: 1px solid rgba(0, 0, 0, .1);
}
.stories {
overflow: auto;
white-space: nowrap;
scrollbar-width: none;
}
.stories ul {
list-style: none;
width: auto;
margin-top: -5px;
}
.stories ul li {
display: inline-block;
}
.pic-stories {
width: 58px;
height: 58px;
border-radius: 50px;
margin-left: 15px;
margin-top: 10px;
z-index: 5;
}
.more-stories {
position: static;
top: 63px;
left: 37px;
margin-left: -15px;
width: 18px;
height: 18px;
}
.txt-stories ul {
list-style: none;
}
.txt-stories ul li {
display: inline-block;
position: relative;
margin-left: 23px;
}
.effect-stories {
width: 70px;
height: 70px;
border: double 6px white;
border-radius: 50px;
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #C82D8D, #F99C4B);
background-origin: border-box;
background-clip: content-box, border-box;
}
<div class="div-stories">
<nav class="stories">
<ul>
<li><img class="pic-stories" src="img/stories1.jpg"><img class="more-stories" src="img/more-stories.webp"></li>
<li><img class="pic-stories effect-stories" src="https://via.placeholder.com/150"></li>
<li><img class="pic-stories effect-stories" src="https://via.placeholder.com/150"></li>
<li><img class="pic-stories effect-stories" src="https://via.placeholder.com/150"></li>
<li><img class="pic-stories effect-stories" src="https://via.placeholder.com/150"></li>
<li><img class="pic-stories effect-stories" src="https://via.placeholder.com/150"></li>
<li><img class="pic-stories effect-stories" src="https://via.placeholder.com/150"></li>
<li><img class="pic-stories effect-stories" src="https://via.placeholder.com/150g"></li>
<li><img class="pic-stories effect-stories" src="https://via.placeholder.com/150"></li>
</ul>
<nav class="txt-stories">
<ul>
<li>
<p class="text-stories">Seu story</p>
</li>
<li>
<p class="text-stories">shinigami...</p>
</li>
<li>
<p class="text-stories">italo_rmds</p>
</li>
<li>
<p class="text-stories">rodrigotea...</p>
</li>
<li>
<p class="text-stories">princejack...</p>
</li>
<li>
<p class="text-stories">viainfinda</p>
</li>
<li>
<p class="text-stories">designer.bot</p>
</li>
<li>
<p class="text-stories">mjacksonh</p>
</li>
<li>
<p class="text-stories">reyzeryt</p>
</li>
</ul>
</nav>
</nav>
</div>
Example codepen: https://codepen.io/brooksrelyt/pen/pGEZOp
I advice you to change your HTML but if you want keep your HTML, you can add this css rules :
ul {
list-style: none;
}
ul li {
margin-left:5px !important;
border:1px solid green;
width:82px;
text-align:center;
}
ul li p {
overflow: hidden;
text-overflow:hidden;
font-size:14px;
}
.pic-stories {
margin:0;
}
Full code :
.div-stories {
width: 100%;
height: 104px;
background: #FAFAFA;
position: absolute;
top: 45px;
border-bottom: 1px solid rgba(0, 0, 0, .1);
}
.stories {
overflow: auto;
white-space: nowrap;
scrollbar-width: none;
}
.stories ul {
list-style: none;
width: auto;
margin-top: -5px;
}
.stories ul li {
display: inline-block;
}
.pic-stories {
width: 58px;
height: 58px;
border-radius: 50px;
margin-left: 15px;
margin-top: 10px;
z-index: 5;
}
.more-stories {
position: static;
top: 63px;
left: 37px;
margin-left: -15px;
width: 18px;
height: 18px;
}
.txt-stories ul {
list-style: none;
}
.txt-stories ul li {
display: inline-block;
position: relative;
margin-left: 23px;
}
.effect-stories {
width: 70px;
height: 70px;
border: double 6px white;
border-radius: 50px;
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #C82D8D, #F99C4B);
background-origin: border-box;
background-clip: content-box, border-box;
}
ul {
list-style: none;
}
ul li {
margin-left:5px !important;
border:1px solid green;
width:82px;
text-align:center;
}
ul li p {
overflow: hidden;
text-overflow:hidden;
font-size:14px;
}
.pic-stories {
margin:0;
}
<div class="div-stories">
<nav class="stories">
<ul>
<li><img class="pic-stories" src="img/stories1.jpg"><img class="more-stories" src="img/more-stories.webp"></li>
<li><img class="pic-stories effect-stories" src="img/stories2.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories3.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories4.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories5.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories6.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories7.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories8.jpg"></li>
<li><img class="pic-stories effect-stories" src="img/stories9.jpg"></li>
</ul>
<nav class="txt-stories">
<ul>
<li>
<p class="text-stories">Seu story</p>
</li>
<li>
<p class="text-stories">shinigami</p>
</li>
<li>
<p class="text-stories">italo_rmds</p>
</li>
<li>
<p class="text-stories">rodrigotea</p>
</li>
<li>
<p class="text-stories">princejack</p>
</li>
<li>
<p class="text-stories">viainfinda</p>
</li>
<li>
<p class="text-stories">designer.bot</p>
</li>
<li>
<p class="text-stories">mjacksonh</p>
</li>
<li>
<p class="text-stories">reyzeryt</p>
</li>
</ul>
</nav>
</nav>
</div>
This solution have a new HTML and use "data-title" attribut :
Modern and short fast solution :
div.stories {
width: 100%;
background: #FAFAFA;
position: absolute;
top: 45px;
border-bottom: 1px solid rgba(0, 0, 0, .1);
}
div.stories ul {
list-style: none;
margin: 0;
}
div.stories ul li {
display: inline-block;
margin-left: 5px !important;
width: 82px;
text-align: center;
}
div.stories ul li::after {
content: attr(data-title);
font-size: 14px;
}
img {
z-index: 5;
width: 70px;
height: 70px;
border: double 6px white;
border-radius: 50px;
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #C82D8D, #F99C4B);
background-origin: border-box;
background-clip: content-box, border-box;
}
<div class="stories">
<nav>
<ul>
<li data-title="username one"><img src="https://randomuser.me/api/portraits/women/57.jpg"></li>
<li data-title="username two"><img src="https://randomuser.me/api/portraits/women/51.jpg"></li>
<li data-title="username tree"><img src="https://randomuser.me/api/portraits/women/52.jpg"></li>
<li data-title="username four"><img src="https://randomuser.me/api/portraits/women/53.jpg"></li>
<li data-title="username five"><img src="https://randomuser.me/api/portraits/women/54.jpg"></li>
</ul>
</nav>
</div>

Html5 and Css3 - Horizontal navigation bar issues

I am designing a webpage. I have two levels of navigation, the social media buttons on the first level and later a navigation bar. I am having issues getting the background colour of the navigation bar to go the complete length of the webpage, at present it starts and stops with the navigation bar. I am guessing it is an issue related to the location or my coding of the clearfix? Anyways I would appreciate your advice. My coding is below, I have attached a photo of my site so you can see what it looks like.
My Html code:
<div id="wrapper">
<header id="header" role="banner">
<div id="logo">
<img src="Images/title.png" alt="logo" width="1018" height="140">
</div>
<div id="social">
<ul>
<li>
<img src="images/twitter.png" alt="Twitter" width="32" height="32">
</li>
<li>
<a href="https://www.facebook.com/Save-NSW-Government-Disability-
Services-ADHC-709029659182219/" target="_blank"><img src="images/facebook.png" alt="Facebook" width="32" height="32"></a>
</li>
<li>
<img src="images/youtube.png" alt="Youtube" width="32" height="32">
</li>
</ul>
</div>
<div id="clearfix">
</div>
<nav id="page_nav">
<div class="menu">
<ul id="navmenu">
<li class="active">Home</li>
<li>About Us</li>
<li>Get Involved<span class="darrow">▼</span>
<ul class="submenu">
<li>Social Media</li>
<li>Union Meetings</li>
<li>Rally</li>
</ul>
</li>
<li>News<span class="darrow">▼</span>
<ul class="submenu">
<li>Shrew's News</li>
<li>Update</li>
</ul>
</li>
<li>Gallery</li>
<li>Contact Us</l>
</ul>
</div>
<div id="clearfix">
</div>
</div>
</nav>
</header>
</div>
My Css:
* {
margin: 0px;
padding: 0px;
}
body {
font-family: sans-serif;
background-color: black;
}
#wrapper {
width: 1366px;
height: auto;
background-color: black;
margin: 0 auto;
padding: 10px;
}
#header {
width: 100%;
height: 140px;
background-color: black;
}
#logo {
float: left;
margin: 0px 0px 20px 50px;
padding-left: 100px;
}
#social {
float: right;
top: 0px;
margin: 0 auto;
}
#social ul li {
float: left;
list-style: none;
padding: 5px;
}
#clearfix:after {
display: block;
clear: both;
}
#page_nav {
background-color: #c50a13;
}
ul#navmenu {
list-style-type: none;
width: 800px;
margin: auto auto 5px auto;
}
ul.submenu {
list-style-type: none;
}
ul#navmenu li {
outline: 1px solid white;
width: 125px;
text-align: center;
position: relative;
float: left;
margin-right: 4px;
color: #26b0f1;
}
ul#navmenu a {
text-decoration: none;
display: block;
width: 125px;
height: 25px;
line-height: 25px;
background-color: #c50a13;
border: 1px solid white;
border-radius: 5px;
color: white;
}
ul#navmenu .submenu a {
margin-top: 3px;
}
ul#navmenu li:hover > a {
background-color: white;
color: #c50a13;
}
ul#navmenu ul.submenu {
display: none;
position: absolute;
top: 26px;
left: 0px;
}
ul#navmenu li:hover .submenu {
display: block;
}
.darrow {
font-size: 14pts;
position: absolute;
top: 10px;
right: 1px;
color: dodgerblue;
}
Update:
You forgot something in your CSS clearfix.
#clearfix:after {
display: block;
clear: both;
content: ''; /* add me */
}
In addition, you have some errors in your HTML which can affect rendering in different ways in different browsers.
[1] Invalid close tag for an <li>
[2] Extra </div> before the close of your </nav>.
[3] Duplicate IDs: id="clearfix"
First, fix the duplicate IDs. In your CSS, change this:
#clearfix:after {
display: block;
clear: both;
}
To this:
.clearfix:after {
display: block;
clear: both;
}
Here is your HTML without errors.
<div id="wrapper">
<header id="header" role="banner">
<div id="logo">
<img src="Images/title.png" alt="logo" width="1018" height="140">
</div>
<div id="social">
<ul>
<li>
<img src="images/twitter.png" alt="Twitter" width="32" height="32">
</li>
<li>
<img src="images/facebook.png" alt="Facebook" width="32" height="32">
</li>
<li>
<img src="images/youtube.png" alt="Youtube" width="32" height="32">
</li>
</ul>
</div>
<div class="clearfix">
</div>
<nav id="page_nav">
<div class="menu">
<ul id="navmenu">
<li class="active">Home</li>
<li>About Us</li>
<li>
Get Involved<span class="darrow">▼</span>
<ul class="submenu">
<li>Social Media</li>
<li>Union Meetings</li>
<li>Rally</li>
</ul>
</li>
<li>
News<span class="darrow">▼</span>
<ul class="submenu">
<li>Shrew's News</li>
<li>Update</li>
</ul>
</li>
<li>Gallery</li>
<li>Contact Us</li>
</ul>
</div>
<div class="clearfix">
</div>
</nav>
</header>
</div>

How to align specific item into a <li>

I need to align specific items into a <li>. That <li> is the first child of a <ul> menu. I have some ideas like do many <span> and align them together or I can divide my <li> area in 3 sections and align my items the one under the others but I do not know which way is the most practical and the most semantically correct.
Here is my code:
<ul id="menuWorkshops">
<li>
<span>Easy</span>
<span>Middle</span>
<span>Difficult</span>
<span class="circle green"></span>
<span class="circle orange"></span>
<span class="circle red"></span>
</li>
<li>
<span>Hardware</span>
<ul>
<li>
<img alt="" src="img/hardware_web.png" /> Montage PC
<span class="circleMenu orange"></span>
</li>
</ul>
</li>
<li>
<span>Système</span>
<ul>
<li>
<img alt="" src="img/os_web.png" /> Installation OS
<span class="circleMenu green"></span>
</li>
</ul>
</li>
<li>
<span>Programmation</span>
<ul>
<li>
<img alt="" src="img/html_web.png" /> Développement Web
<span class="circleMenu orange"></span>
</li>
<li>
<img alt="" src="img/lego_web.png" /> Lego Mindstorm
<span class="circleMenu green"></span>
</li>
<li>
<img alt="" src="img/catch_me_web.png" /> Jeu Attrape-moi (Processing)
<span class="circleMenu red"></span>
</li>
<li>
<img alt="" src="img/tetris_web.png" /> Jeu Tetris (Small Basic)
<span class="circleMenu red"></span>
</li>
<li>
<img alt="" src="img/breakout_web.png" /> Jeu Casse-Brique (Small Basic)
<span class="circleMenu orange"></span>
</li>
<li>
<img alt="" src="img/scratch_web.png" /> Kinect to Scratch
<span class="circleMenu green"></span>
</li>
<li>
<img alt="" src="img/bird_web.png" /> Jeu Flappy Bird (Scratch)
<span class="circleMenu green"></span>
</li>
</ul>
</li>
</ul>
ul#menuWorkshops {
display: inline-block;
width: 285px;
padding-left: 0;
border: 1px solid #000;
border-bottom: 0;
list-style-type: none;
}
ul#menuWorkshops ul {
padding-left: 0;
}
ul#menuWorkshops > li > span {
display: block;
height: 35px;
border-bottom: 1px solid #000;
background-color: #4D4D4D;
color: #FAFAFA;
font-size: 18px;
text-align: center;
line-height: 35px;
}
ul#menuWorkshops > li:first-child {
height: 50px;
background-color: #E0E0E0;
color: #050505;
}
ul#menuWorkshops ul li {
height: 35px;
line-height: 35px;
padding: 5px 10px;
background-color: #007CB7;
color: #FAFAFA;
font-size: 14px;
border-bottom: 1px solid #000;
}
ul#menuWorkshops img {
vertical-align: middle;
}
ul#menuWorkshops ul li:hover {
background-color: #8BBDD9;
color: #050505;
font-weight: bold;
list-style-type: none;
}
span.circleMenu {
float: right;
width: 10px;
height: 10px;
border: 1px solid #FFF;
border-radius: 5px;
}
.green {
background-color: #008000;
}
.orange {
background-color: #FFA500;
}
.red {
background-color: #F00;
}
For you to understand my question I will join a screenshot of the result I want to reach.
my screenshot
I would treat that top section as separate from the navigation that follows, as it's not a sibling list item in any true sense. Here, I've created a nav for the entire menu with a header and a series of dl within for the ease-medium-difficult legend, followed by the ul with .submenu uls for the actual nav items. Certainly not the only way to go about this, but definitely a more semantic solution than what you started with. Obviously, if you prefer everything wrapped in a ul, you can also repurpose this CSS to that end.
body {
box-sizing: border-box;
font-family: sans-serif;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
#menuWorkshops {
border: 1px solid #000;
display: inline-block;
width: 325px;
}
#menuWorkshops dl,
#menuWorkshops dt,
#menuWorkshops dd,
#menuWorkshops ul,
#menuWorkshops li {
margin: 0;
padding: 0;
}
#menuWorkshops header {
background-color: #E0E0E0;
color: #050505;
padding: 12px 10px;
}
#menuWorkshops header dl {
display: inline-block;
font-size: 14px;
width: 32%;
}
#menuWorkshops header dl,
#menuWorkshops header dt,
#menuWorkshops header dd {
margin: 0;
text-align: center;
}
#menuWorkshops header dt,
#menuWorkshops header dd {
display: block;
}
#menuWorkshops header .circle {
margin: 4px auto 0;
}
.circle {
border: 1px solid #FFF;
border-radius: 50%;
display: inline-block;
height: 20px;
width: 20px;
}
.green {
background-color: #008000;
}
.orange {
background-color: #FFA500;
}
.red {
background-color: #F00;
}
#menuWorkshops ul,
#menuWorkshops li {
display: block;
padding-left: 0;
}
#menuWorkshops li {
color: #FAFAFA;
line-height: 50px;
}
#menuWorkshops > ul > li {
background-color: #4D4D4D;
border-top: 1px solid #000;
font-size: 18px;
text-align: center;
}
#menuWorkshops .submenu li {
border-top: 1px solid #000;
}
#menuWorkshops .submenu a {
background-color: #007CB7;
color: #FAFAFA;
display: block;
font-size: 14px;
padding: 0 10px;
text-align: left;
text-decoration: none;
}
#menuWorkshops .submenu a:hover {
background-color: #8BBDD9;
color: #050505;
font-weight: bold;
list-style-type: none;
}
#menuWorkshops .submenu img {
display: inline-block;
height: 40px;
padding: 0 10px;
vertical-align: middle;
width: 40px;
}
#menuWorkshops .submenu .circle {
float: right;
margin-top: 12px;
}
<nav id="menuWorkshops">
<header>
<dl>
<dt>Facile</dt>
<dd class="circle green"></dd>
</dl>
<dl>
<dt>Moyen</dt>
<dd class="circle orange"></dd>
</dl>
<dl>
<dt>Difficile</dt>
<dd class="circle red"></dd>
</dl>
</header>
<ul>
<li>Hardware
<ul class="submenu">
<li>
<a href="#">
<img alt="" src="img/hardware_web.png" />Montage PC
<span class="circle orange"></span>
</a>
</li>
</ul>
</li>
<li>Système
<ul class="submenu">
<li>
<a href="#">
<img alt="" src="img/os_web.png" />Installation OS
<span class="circle green"></span>
</a>
</li>
</ul>
</li>
<li>Programmation
<ul class="submenu">
<li>
<a href="#">
<img alt="" src="img/html_web.png" />Développement Web
<span class="circle orange"></span>
</a>
</li>
<li>
<a href="#">
<img alt="" src="img/lego_web.png" />Lego Mindstorm
<span class="circle green"></span>
</a>
</li>
<li>
<a href="#">
<img alt="" src="img/catch_me_web.png" />Jeu Attrape-moi (Processing)
<span class="circle red"></span>
</a>
</li>
<li>
<a href="#">
<img alt="" src="img/tetris_web.png" />Jeu Tetris (Small Basic)
<span class="circle red"></span>
</a>
</li>
<li>
<a href="#">
<img alt="" src="img/breakout_web.png" />Jeu Casse-Brique (Small Basic)
<span class="circle orange"></span>
</a>
</li>
<li>
<a href="#">
<img alt="" src="img/scratch_web.png" />Kinect to Scratch
<span class="circle green"></span>
</a>
</li>
<li>
<a href="#">
<img alt="" src="img/bird_web.png" />Jeu Flappy Bird (Scratch)
<span class="circle green"></span>
</a>
</li>
</ul>
</li>
</ul>
</nav>

How to center list image in bootstrap

I am trying to center the contact icons but its not working. I tried to set the margin to auto and used text-align:center but it doesnt work either. Please help
#contact {
text-align: center;
margin-right: auto;
margin-left: auto;
}
.footer .row li {
float: left;
list-style-type: none;
text-align:center;
}
.footer .row img{
display: inline-block;
height: auto;
vertical-align: middle;
}
<div class="container">
<div class="footer">
<div class="row">
<div id="contact" class="col-xs-12 center">
<ul>
<li><img src="./images/logos/fb.png" class="img-responsive inline-block" alt="Responsive image" width="90px" height="90px" /></li>
<li><img src="./images/logos/twitter.png" class="img-responsive inline-block" alt="Responsive image" width="90px" height="90px" /></li>
<li><img src="./images/logos/insta.png" class="img-responsive inline-block" alt="Responsive image" width="90px" height="90px" /></li>
</ul>
</div>
</div>
</div>
</div>
g
Don't use bootstrap for now, i suggest to learn the basics first.
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
ul{
display: table;
width: 100%;
padding: 10px
}
ul li{
list-style: none;
float: left;
background: #ddd;
margin-right: 10px;
padding: 10px
}
ul li img {
width: 25px;
height: 25px;
background: red;
}
ul li span, ul li p{
line-height: 25px;
height: 25px;
background: blue;
color: #fff
}
/* here the style */
.vertical-align li {
text-align: center;
}
.horizontal-align li img,
.horizontal-align li span {
float: left;
}
<h1>Vertical</h1>
<ul class='vertical-align'>
<li><img src='url.png' /><p>VALUE</p></li>
<li><img src='url.png' /><p>VALUE</p></li>
<li><img src='url.png' /><p>VALUE</p></li>
<li><img src='url.png' /><p>VALUE</p></li>
</ul>
<h1>Horizontal</h1>
<ul class='horizontal-align'>
<li><img src='url.png' /><span>VALUE</span></li>
<li><img src='url.png' /><span>VALUE</span></li>
<li><img src='url.png' /><span>VALUE</span></li>
<li><img src='url.png' /><span>VALUE</span></li>
</ul>

Safari vs Firefox: Strange UL "padding"

I have this HTML:
<article class="images">
<ul class="cf">
<li>
<a href="#">
<img src="http://www.placehold.it/800x600" alt="" />
</a>
</li>
</ul>
</article>
And this CSS:
* {
margin: 0;
padding: 0;
}
.images ul {
margin-left: -3%;
width: 100%;
background: red;
}
.images li {
list-style-type: none;
}
.images li img {
width: 17%;
margin-left: 3%;
margin-bottom: 3%;
float: left;
}
Still, in Safari the ul seems to have some kind of padding on the right.
In Firefox the ul is displayed correctly.
See it for yourself: http://jsfiddle.net/EdCXx/
Is there any way to fix that?
Edit: With Safari 6.0.2 on OS X 10.8.2 it looks like this:
I'm assuming the issue is that you're using negative margin and this is causing a problem (I don't have access to a Mac at the moment, so I can't verify).
Try changing your CSS to what's below. I also changed your clearfix to one I picked up a while ago that has had excellent cross-browser results.
http://jsfiddle.net/EdCXx/4/
CSS:
/* Reset */
* {
margin: 0;
padding: 0;
}
/* Clearfix */
.clear:after {
clear: both;
content: ".";
display: block;
height: 0;
line-height: 0;
visibility: hidden;
}
/* Images */
.images ul {
width: 100%;
background: red;
}
.images li {
list-style: none;
overflow: hidden;
margin-right: 3%;
margin-bottom: 3%;
float: left;
width: 17%;
height: 17%;
}
.images li img {
float: left;
max-width: 100%;
max-height: 100%;
}
And tighten up your HTML (not necessary, but it's prettier):
<article class="images">
<ul class="clear">
<li> <img src="http://www.placehold.it/800x600" alt="" /></li>
<li><img src="http://www.placehold.it/800x600" alt="" /></li>
<li> <img src="http://www.placehold.it/800x600" alt="" /></li>
<li> <img src="http://www.placehold.it/800x600" alt="" /></li>
<li> <img src="http://www.placehold.it/800x600" alt="" /></li>
<li> <img src="http://www.placehold.it/800x600" alt="" /></li>
<li> <img src="http://www.placehold.it/800x600" alt="" /></li>
<li> <img src="http://www.placehold.it/800x600" alt="" /></li>
</ul>
</article>