To start off here is an image to illustrate what I'm dealing with:
I have seen a few other instances of people dealing with this where a border of sorts is applied to the bottom of an image. A solution was to set the images to display: block, but there was no explanation as to why this fixes it. I'm trying to understand why an image must have a display value of block when applying a box shadow property.
HTML
<div id="showcase">
<section>
<ul id="gallery">
<li><img src="img/img1.png" alt="One"></li>
<li><img src="img/img2.png" alt="Two"></li>
<li><img src="img/img3.png" alt="Three"></li>
<li><img src="img/img4.png" alt="Four"></li>
<li><img src="img/img5.png" alt="Five"></li>
<li><img src="img/img6.png" alt="Six"></li>
<li><img src="img/img7.png" alt="Seven"></li>
</ul>
</section>
<footer>
</footer>
</div>
CSS
#showcase {
max-width: 850px;
border: 2px dotted;
margin: 0 auto;
background: silver;
}
#gallery {
list-style: none;
padding: 0;
margin: 0;
}
#gallery li {
width: 45%;
float: left;
margin: 2.5%;
box-shadow: 0 8px 10px -5px;
}
Actually you're just missing to properly position your inline-block images using
#gallery img{
vertical-align: top; /* or any other value from */
}
https://developer.mozilla.org/en/docs/Web/CSS/vertical-align
Example with issue:
#gallery li{
display:inline-block;
box-shadow: 0 8px 10px -5px;
}
<ul id="gallery">
<li>
<img src="//placehold.it/60x60">
</li>
</ul>
Example with vertical-align on images
#gallery li{
display:inline-block;
box-shadow: 0 8px 10px -5px;
}
#gallery li img{
vertical-align: top;
}
<ul id="gallery">
<li>
<img src="//placehold.it/60x60">
</li>
</ul>
https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align
Phrasing HTML elements like img are subject to typographical line-boxes unless set (overridden) to a block-level display state.
Related
I have a list with images in. The list is a centered column in foundation.
Fiddle
I need it so that the list elements images are all aligned in the same 'row' rather than going down the page.
How can I do this? I've tried:
li{
display: inline;
}
But no luck.
Add display: inline-flex to your ul
ul {
list-style: none;
display: inline-flex;
}
img {
border: 1px solid black;
}
<div class="row">
<ul class="small-4 medium-6 small-centered columns">
<li>
<img src="http://api.ning.com/files/yallYWJbJ*ZVuc1yUMGYuXL4artVmJUl*Uuzcv2prT67gOy0nNVLPjrRE1GYTasJCNYmjgeSTgORbhuGbyRpcsaQbL1nvAPk/GreenSquare" />
</li>
<li>
<img src="http://api.ning.com/files/yallYWJbJ*ZVuc1yUMGYuXL4artVmJUl*Uuzcv2prT67gOy0nNVLPjrRE1GYTasJCNYmjgeSTgORbhuGbyRpcsaQbL1nvAPk/GreenSquare" />
</li>
<li>
<img src="http://api.ning.com/files/yallYWJbJ*ZVuc1yUMGYuXL4artVmJUl*Uuzcv2prT67gOy0nNVLPjrRE1GYTasJCNYmjgeSTgORbhuGbyRpcsaQbL1nvAPk/GreenSquare" />
</li>
</ul>
</div>
You can give the ul and li a fixed size or % based width and use for lists a display:inline-block
#myUL{
list-style: none;
width: 100%;
position: relative;
display:block;
float:none;
padding: 0;
margin: 0;
}
li{
width: 32.5%;
position: relative;
margin: 0px;
line-height: 14px;
display: inline-block;
}
}
img{
border: 1px solid black;
position:relative;
width:100%;
}
Jsfiddle
Firstly - you need to remove "li" css being nested inside ul.
Then, having li width set to some certain size, and adding display: inline-block; to li's css should do the job.
It has greater universal browser support in opposition to inline-flex (if you're about to have a support for IE9 and below):
HTML:
<div class="row">
<ul class="small-4 medium-6 small-centered columns">
<li><img src="http://api.ning.com/files/yallYWJbJ*ZVuc1yUMGYuXL4artVmJUl*Uuzcv2prT67gOy0nNVLPjrRE1GYTasJCNYmjgeSTgORbhuGbyRpcsaQbL1nvAPk/GreenSquare"/></li>
<li><img src="http://api.ning.com/files/yallYWJbJ*ZVuc1yUMGYuXL4artVmJUl*Uuzcv2prT67gOy0nNVLPjrRE1GYTasJCNYmjgeSTgORbhuGbyRpcsaQbL1nvAPk/GreenSquare"/></li>
<li><img src="http://api.ning.com/files/yallYWJbJ*ZVuc1yUMGYuXL4artVmJUl*Uuzcv2prT67gOy0nNVLPjrRE1GYTasJCNYmjgeSTgORbhuGbyRpcsaQbL1nvAPk/GreenSquare"/></li>
</ul>
</div>
CSS:
ul {
list-style: none;
}
li {
display: inline-block;
width:30%;
margin-right: -4px;
}
img {
border: 1px solid black;
}
JSFiddle
I have a Wordpress menu that I've made the tabs background images. I am trying to get the images to scale down when the .wrapper scales down and keep them in a horizontal row and avoid javascript and/or media queries or navwalker class as I'm using bootstrap.
This is what the menu looks like full scale:
Here is my code for my .wrapper and for a one out of the 9 menu-items and the nav class and logo structure. Please note I'm trying to apply the same concept to the logo.
I am using html5blank and Wordpress menu.
<div class="nav" role="navigation">
<?php html5blank_nav(); ?>
</div>
here is the html it renders of one of the 9 <li>'s ( that I'm styling in the css )
<li id="menu-item-1688" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1688">Blog</li>
.wrapper {
max-width:1280px;
width:95%;
margin:0 auto;
position:relative;
}
.logo {
float:left;
width:145px;
height:157px;
}
.nav {
float:left;
padding-top:11px;
}
.nav ul {
padding:0;
margin:0;
}
.nav ul li {
float:left;
list-style-type:none;
padding:0;
margin:0;
}
li#menu-item-1688 a {
display:block;
background:url('img/ksl_news.png');
background-repeat:no-repeat;
width:110px;
height:119px;
color:transparent;
margin-top:27px;
}
You can use a quirk of the padding property to do this: the values for padding-top/padding-bottom when specified as percentages are calculated based on the width of the element (this also applies for margins).
Minimal example:
a {
background: url('http://i.stack.imgur.com/4kaLj.png');
background-size: contain;
display: block;
padding-top: 12.6324%;
}
The 12.6324% comes from the aspect ratio of your image: height/width*100 = 310/2454*100 = 12.6324%.
display: block; causes the element to take 100% width of it's container. Together, this solves your problem, as long as you know the aspect ratio of your images so you can calculate these percentages, this will work.
Jsfiddle example.
So here's an odd approach to this - using display: table in order to avoid needing to know the number of menu items you'll have. It's not quite perfect - as the images can sometimes be a pixel off in size, but if this works for you then great :)
HTML:
<div class="container">
<nav class="nav">
<ul>
<li class="logo"><img src="//placehold.it/145x157" /></li>
<li><img src="//placehold.it/110x119" /></li>
<li><img src="//placehold.it/110x119" /></li>
<li><img src="//placehold.it/110x119" /></li>
<li><img src="//placehold.it/110x119" /></li>
<li><img src="//placehold.it/110x119" /></li>
<li><img src="//placehold.it/110x119" /></li>
<li><img src="//placehold.it/110x119" /></li>
<li><img src="//placehold.it/110x119" /></li>
<li><img src="//placehold.it/110x119" /></li>
</ul>
</nav>
</div>
CSS:
.nav {
display: table;
width: 100%;
}
.nav ul {
display: table-row;
}
.nav li {
list-style: none;
padding: 0px;
margin: 0px;
display: table-cell;
vertical-align: bottom;
}
.nav img {
max-width: 100%;
border: solid 1px #000;
}
JSFiddle Example.
However if the slight difference in cell size is a problem for you (it is quite noticable), but you are happy to have a hard-coded requirement in css of the number of items in your menu, try using the same markup with the followng CSS instead:
.nav ul {
margin: 0px;
padding: 0px;
font-size: 0px;
}
.nav li {
list-style: none;
padding: 0px;
margin: 0px;
display: inline-block;
vertical-align: bottom;
max-width: 9%;
}
.nav li.logo {
max-width: 11%;
}
.nav img {
max-width: 100%;
border: solid 1px #000;
}
Jsfiddle example.
Can't seem to get this working - i have a group of images with text under them set to :block , when i try to get the ul or li class containing the images and the a class , i'm unable to get anything i've tried to work. I want to keep images and text under the image centered regardless of page width.
Set up jsfiddle here http://jsfiddle.net/89bnF/488/
HTML
<li class="single">
<ul>
<li><img src=""><a>Top Dawg</a></li>
<li><img src=""><a>THEEOhiostate</a></li>
<li><img src=""><a>slambodians</a></li>
<li><img src=""><a>Hollywood Shuffler</a></li>
<li><img src=""><a>Thunderbolts</a></li>
<li><img src=""><a>MeWantee</a></li>
<li><img src=""><a>Cincy Slammers</a></li>
<li><img src=""><a>Mahafaha</a></li>
<li><img src=""><a>SF Drug Lords</a></li>
<li><img src=""><a>Hudy Delight</a></li>
<li><img src=""><a>long shot</a></li>
<li><img src=""><a>Green Guy</a></li>
</ul>
</li>
CSS
.single ul {
text-align: justify;
border: 1px solid red;
}
.single li {
display: inline-block;
position: relative;
top: 1.2em;
}
.single ul:before{
content: '';
display: block;
width: 100%;
margin-bottom: -1.2em;
}
.single ul:after {
content: '';
display: inline-block;
width: 100%;
}
img {
width:100px;
height:30px;
background:black;
}
If you remove the position:relative and introduce the margin: 0 auto; it should centre the <li>
.single li {
display: inline-block;
top: 1.2em;
margin: 0 auto;
}
This question already has answers here:
How to remove indentation from an unordered list item?
(10 answers)
Closed 7 years ago.
For some reason in my footer there's a space to the left of my ul so it isn't lined up with the content above it (membership text etc) If I were to put text outside this ul (but still within the footer wrapper) there is no such space.
Here's what it looks like:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Ozanam Club </title>
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="css/normalize.css"/>
<link rel="stylesheet" href="css/flexslider.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/fonts/enigma.css" />
</head>
<body>
<div id="wrap">
<header>
<div id="logo"><img src="images/logo.png" height="157px" width="237px"></div>
<!--
<div class="social">
<ul>
<li><img src="images/icons/facebook.gif"/></li>
<li><img src="images/icons/twitter.gif"/></li>
<li><img src="images/icons/youtube.gif"/></li>
</ul>
</div>
-->
<div id="navigation">
<ul>
<li>Home</li>
<li>Events</li>
<li>Clubs</li>
<li>Photos</li>
<li>F.A.Q</li>
<li>Contact</li>
</ul>
</div>
</header>
<section class="slider">
<div class="flexslider">
<ul class="slides">
<li>
<img src="images/slider/image1.gif" />
</li>
<li>
<img src="images/slider/image2.gif" />
</li>
<li>
<img src="images/slider/image3.gif" />
</li>
</ul>
</div>
</section>
<div class="main">
<h1>Ozanam Club</h1>
<p>The first Ozanam Club was started in May 1989 by James Lynch, a member of the
St. Vincent De Paul society who himself had two children with learning difficulties
and who was concerned at the general lack of leisure provision for them.</p>
<p>The Ozanam Club is a Special Works Conference of the St. vincent De Paul Society.
The name of the clubs are called after Blessed Frederick Ozanam who is the founder
of the S.S.V.P. At this present time we have two clubs in Viewpark, an adults club
and a seperate club for younger members. We have an adults club in Hamilton and
Paisley and also a club in Carfin for younger members. </p>
<h1>Membership</h1>
<p>Membership is open to anyone who has disablities, regardless of their race or religious belief.</p>
<p>The aim of the clubs are a fun night out for our members and some temporary respite for parents. All of the clubs are run solely by volunteers who are disclosure checked prior to working with
vulnerable adults/children.</p><p> They are also made aware of the Adults/Children Protection Procedures and encouraged to attend an information session.</p>
<p>You can find more information on our a F.A.Q page.</p>
</div>
<div class="side">
<img src="images/events.gif" alt="Events" />
View
</div>
<div class="side">
<img src="images/photos.gif" alt="Events" />
View
</div>
</div>
<footer>
<div id="footer-wrap">
<ul>
<li>Home</li>
<li>Events</li>
<li>Clubs</li>
<li>Photos</li>
<li>F.A.Q</li>
<li>Contact</li>
</ul>
</div>
</footer>
</div>
</div>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script defer src="js/jquery.flexslider-min.js"></script>
<script>
$(window).load(function() {
$('.flexslider').flexslider({
animation: "slide"
});
});
</script>
</body>
</html>
CSS:
body {background: white; background: url('../images/grunge.png'); font-family: 'EnigmaticRegular';}
#wrap {margin: 0 auto; width: 100%; max-width: 1000px;}
header {position: relative;}
#logo {margin: 20px 0 0 0; display: block; float: left;}
.social ul { z-index: 1; list-style: none; position: absolute; top: 0; right: 0;}
.social li { float: left;}
.social img { height: 35px; width: 35px;}
#navigation { width: 100%; max-width: 1000px; height: 200px; position: relative; }
#navigation ul { padding: 0.5em; background: white; border-radius: 5px; border-bottom: solid 3px #3c88bc; display: inline-block; position: absolute; bottom: 0; right: 0;}
#navigation li { padding-left: 0.5em; padding-right: 0.5em; list-style: none; font-style: none; font-family: 'EnigmaticBold'; border-right: solid 1px black;}
#navigation li:last-child { border: 0;}
#navigation ul,
#navigation li {float: left;}
#navigation a { color: #195c8a; text-decoration: none; font-weight: bold;}
#navigation a:hover { color: #13405f;}
.main { float: left; margin-top: 20px; width: 625px;}
.main h1 {font-family: 'EnigmaticBold'; color: #13405f; }
.main p {color: #13405f;}
.main a {color: inherit; }
.side {float: right; margin-top: 20px; border-radius: 10px; margin-bottom: 10%; }
.side a { text-decoration: none; color: #3c88bc;}
.button { font-size: 14px;font-family: 'EnigmaticBold'; display: block; width: 100px; margin: 0 auto; text-align: center; background: #fff; padding: 5px; border-radius: 10px; border-bottom: solid 3px #3c88bc;}
footer { height: 100px; background: #195c8a; clear: both; }
#footer-wrap {margin: 0 auto; padding: 0; width: 100%; max-width: 1000px; }
#footer-wrap li { float: left; list-style: none; padding-right: 3em;}
#footer-wrap a {color: white ;text-decoration: none;}
The <ul> element has browser inherent padding & margin by default. In your case, Use
#footer ul {
margin: 0; /* To remove default bottom margin */
padding: 0; /* To remove default left padding */
}
or a CSS browser reset ( https://cssreset.com/ ) to deal with this.
I don't see any margin or margin-left declarations for #footer-wrap li.
This ought to do the trick:
#footer-wrap ul,
#footer-wrap li {
margin-left: 0;
list-style-type: none;
}
by default <UL/> contains default padding
therefore try adding style to padding:0px in css class or inline css
I'm having lots of problem aligning an image on CSS.
Here is the thing, I have a div called "toggle" inside this div I have a list ul - li on each li I have text and then 3 images, but I want to have the Images aligned some how the alignment of the images are relative to the text not to the left padding.
http://aluna.webdcg.com/visistat/
Maybe this is what you need. See code in action at: http://jsfiddle.net/67VWe/
CSS:
* { font-family: Tahoma; }
ul { width: 200px; margin: 20px; border: 1px solid #777; }
li { padding: 2px; border-bottom: 1px dotted #777; }
li label { width: 120px; float: left; }
HTML:
<div id="toggle">
<ul>
<li><label>Text 1</label> <img src="http://admin.visistat.com/sales/img/icon-pulse-dot-red.png" width="22" height="22" /></li>
<li><label>Text 1234</label> <img src="http://admin.visistat.com/sales/img/icon-pulse-dot-red.png" width="22" height="22" /></li>
<li><label>Text 1234567</label> <img src="http://admin.visistat.com/sales/img/icon-pulse-dot-red.png" width="22" height="22" /></li>
</ul>
</div>
--
The label tag, width, and float values did the trick.