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>
Related
Trying to reproduce the following in HTML & CSS:
Here's how I tried to structire it:
.layout ul > li {
list-style: none;
}
.layout ul > li:nth-child(1n) > img {
float: left;
}
.layout ul > li:nth-child(2n) > img {
float: right;
z-index: 9999;
}
<div class="layout">
<ul>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
</ul>
</div>
The problem is that when applying clearfix it doesn't help at all. The images seem to come on one row. Maybe is there something specific when it comes to li elements and clearfix? How this can be solved?
You can simply consider text-align property and some negative margin for the overlap (this will avoid you all the float issues)
.layout {
width: 200px;
}
.layout ul {
margin: 0;
padding: 0;
}
.layout ul>li {
list-style: none;
margin-bottom: -20px;
position: relative; /* don't forget this to be able to use z-index */
}
.layout ul>li {
text-align: left;
}
.layout ul>li:nth-child(2n) {
text-align: right;
z-index: 999;
}
<div class="layout">
<ul>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
</ul>
</div>
Try to make use of transform css property
.layout ul {
display: flex;
flex-wrap: wrap;
padding: 0;
list-style: none;
background: #ccc;
padding: 20px;
padding-left: 40px;
}
.layout ul>li {
width: 50%;
box-sizing: border-box;
border: 5px solid #fff;
margin-bottom: 10px;
}
.layout ul>li>img {
width: 100%;
max-width: 100%;
display: block;
}
.layout ul>li:nth-child(even) {
transform: translateY(50%) translateX(-20px);
}
<div class="layout">
<ul>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
<li><img src="http://placeimg.com/120/80/grayscale" /></li>
</ul>
</div>
When trying to put an image and a title in a list tag, the title drops to the second line. Is there a way to work around this?
ul {
padding: 0;
list-style-type: none;
}
#searchImg {
width: 50px;
height: 72px;
white-space: nowrap;
padding: 0;
margin: 0;
}
#searchTitle {
margin-left: 60px;
}
<ul id="myUL">
<li><img src="https://myanimelist.cdn-dena.com/images/anime/2/75533.jpg" id="searchImg"><p id="searchTitle">A Certain Magical Index</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/13/77968.jpg" id="searchImg"><p id="searchTitle">Ajin</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/22061.jpg" id="searchImg"><p id="searchTitle">Angel Beats!</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/47347.jpg" id="searchImg"><p id="searchTitle">Attack on Titan</p></li>
</ul>
Demo
You have to make it inline using the following.
ul p {
display:inline;
}
Gives you this:
You are using block element(p) which spans full width,so use display:inline property on block element or simply use Inline elements
ul {
padding: 0;
list-style-type: none;
}
#searchImg {
width: 50px;
height: 72px;
white-space: nowrap;
padding: 0;
margin: 0;
}
#searchTitle {
margin-left: 60px;
}
p {
display: inline;
}
<ul id="myUL">
<li>
<a href="#"><img src="https://myanimelist.cdn-dena.com/images/anime/2/75533.jpg" id="searchImg">
<p id="searchTitle">A Certain Magical Index</p>
</a>
</li>
<li>
<a href="#"><img src="https://myanimelist.cdn-dena.com/images/anime/13/77968.jpg" id="searchImg">
<p id="searchTitle">Ajin</p>
</a>
</li>
<li>
<a href="#"><img src="https://myanimelist.cdn-dena.com/images/anime/10/22061.jpg" id="searchImg">
<p id="searchTitle">Angel Beats!</p>
</a>
</li>
<li>
<a href="#"><img src="https://myanimelist.cdn-dena.com/images/anime/10/47347.jpg" id="searchImg">
<p id="searchTitle">Attack on Titan</p>
</a>
</li>
</ul>
Follow the following code and you will have the desired result.
ul {
padding: 0;
list-style-type: none;
}
ul li{
width: 100%;
float: left;
margin-top: 5px;
}
#searchImg {
width: 50px;
height: 72px;
white-space: nowrap;
padding: 0;
margin: 0;
float: left;
}
#searchTitle {
margin-left: 60px;
float: left;
}
<ul id="myUL">
<li><img src="https://myanimelist.cdn-dena.com/images/anime/2/75533.jpg" id="searchImg"><p id="searchTitle">A Certain Magical Index</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/13/77968.jpg" id="searchImg"><p id="searchTitle">Ajin</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/22061.jpg" id="searchImg"><p id="searchTitle">Angel Beats!</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/47347.jpg" id="searchImg"><p id="searchTitle">Attack on Titan</p></li>
</ul>
To align title with the image use display:inline-block property.
#searchImg {
width: 50px;
height: 72px;
white-space: nowrap;
padding: 0;
margin: 0;
vertical-align: middle; // align text to middle of image for better view
}
#searchTitle {
margin-left: 60px;
display:inline-block;
}
Try this one
ul {
padding: 0;
list-style-type: none;
}
ul li
{
}
#searchImg {
width: 50px;
height: 72px;
white-space: nowrap;
padding: 0;
margin: 0;
}
#searchTitle {
display: inline-block;
margin-left: 60px;
}
<ul id="myUL">
<li><img src="https://myanimelist.cdn-dena.com/images/anime/2/75533.jpg" id="searchImg"><p id="searchTitle">A Certain Magical Index</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/13/77968.jpg" id="searchImg"><p id="searchTitle">Ajin</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/22061.jpg" id="searchImg"><p id="searchTitle">Angel Beats!</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/47347.jpg" id="searchImg"><p id="searchTitle">Attack on Titan</p></li>
</ul>
Try this one using display table to parent and table-cell to child elements
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
ul {
padding: 0;
list-style-type: none;
}
ul li a {
display: table;
margin-top: 10px;
}
ul li a img, ul li a p {
display: table-cell;
vertical-align: middle;
}
#searchImg {
width: 50px;
height: 72px;
white-space: nowrap;
padding: 0;
margin: 0;
}
#searchTitle {
margin-left: 60px;
}
</style>
</head>
<body>
<ul id="myUL">
<li>
<a href="#"><img src="https://myanimelist.cdn-dena.com/images/anime/2/75533.jpg" id="searchImg">
<p id="searchTitle">A Certain Magical Index</p>
</a>
</li>
<li>
<a href="#"><img src="https://myanimelist.cdn-dena.com/images/anime/13/77968.jpg" id="searchImg">
<p id="searchTitle">Ajin</p>
</a>
</li>
<li>
<a href="#"><img src="https://myanimelist.cdn-dena.com/images/anime/10/22061.jpg" id="searchImg">
<p id="searchTitle">Angel Beats!</p>
</a>
</li>
<li>
<a href="#"><img src="https://myanimelist.cdn-dena.com/images/anime/10/47347.jpg" id="searchImg">
<p id="searchTitle">Attack on Titan</p>
</a>
</li>
</ul>
</body>
</html>
ul {
padding: 0;
list-style-type: none;
}
#searchImg {
padding: 0;
display:inline-block;
vertical-align:middle;
margin-right:10px;
}
#searchTitle {
padding:0;
margin:0;
display:inline-block;
font-size:16px;
font-weight:bold
}
<ul id="myUL">
<li><img src="https://myanimelist.cdn-dena.com/images/anime/2/75533.jpg" id="searchImg"><p id="searchTitle">A Certain Magical Index</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/13/77968.jpg" id="searchImg"><p id="searchTitle">Ajin</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/22061.jpg" id="searchImg"><p id="searchTitle">Angel Beats!</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/47347.jpg" id="searchImg"><p id="searchTitle">Attack on Titan</p></li>
</ul>
Your code is missing float: left; property of the img and p tag. Use the following given CSS for the desired output:
ul{
padding: 0;
list-style-type: none;
}
ul li{
float: left;
width: 100%;
}
#searchImg{
width: 50px;
height: 72px;
white-space: nowrap;
padding: 0;
margin: 0;
float: left;
}
#searchTitle{
margin-left: 60px;
float: left;
}
display: inline-block
can help you
ul {
padding: 0;
list-style-type: none;
}
#searchImg {
width: 50px;
height: 72px;
white-space: nowrap;
padding: 0;
margin: 0;
}
#searchTitle {
margin-left: 10px;
display: inline-block;
}
<ul id="myUL">
<li><img src="https://myanimelist.cdn-dena.com/images/anime/2/75533.jpg" id="searchImg"><p id="searchTitle">A Certain Magical Index</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/13/77968.jpg" id="searchImg"><p id="searchTitle">Ajin</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/22061.jpg" id="searchImg"><p id="searchTitle">Angel Beats!</p></li>
<li><img src="https://myanimelist.cdn-dena.com/images/anime/10/47347.jpg" id="searchImg"><p id="searchTitle">Attack on Titan</p></li>
</ul>
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;
I want to make a block filled with a large number of photos in row. Width of web page is always too small, so I want to add a horizontal scrolling.
I made it here: http://jsfiddle.net/49REZ/
HTML
<div class="wrapper">
<div class="photos">
<ul>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg"/></li>
</ul>
</div>
</div>
CSS
.wrapper {
width: 80%;
margin: 10px auto;
}
.wrapper {
overflow-x: scroll;
overflow-y: hidden;
}
ul, li {
margin: 0;
padding: 0;
}
.wrapper ul {
width: 10000px;
}
ul li {
list-style: none;
float: left;
}
It works fine in Chrome.
But it does not work well in Firefox, because it fairy displays 10000px block with a lot of free space after photos.
Try to replace the css with the following:
.wrapper ul {
white-space: nowrap;
}
ul li {
list-style: none;
display: inline-block;
}
http://jsfiddle.net/49REZ/4/
you can try this:
HTML:
<ul class="images">
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg" width="150" height="150"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg" width="150" height="150"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg" width="150" height="150"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg" width="150" height="150"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg" width="150" height="150"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg" width="150" height="150"/></li>
<li><img src="http://photos-ak.sparkpeople.com/nw/4/4/l446472527.jpg" width="150" height="150"/></li>
</ul>
CSS:
ul.images {
margin: 0;
padding: 0;
white-space: nowrap;
width: 500px;
overflow-x: auto;
background-color: #ddd;
}
ul.images li {
display: inline;
width: 150px;
height: 150px;
}
jsfiddle
try to put your 10 000px on another mother component,such as the div, or directly the body
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>