I am trying to create a rather complex grid of images and information (almost like Pinterest). In particular, I am trying to insert a position into one set of <ul>s directly after another. I have a job, but one aspect is causing problems, so I'm trying to ask about this little piece to avoid complicating the whole problem.
To horizontally align the images and their information, we use inline <li>s with other elements of the level of the built-in block inside them. Everything works correctly for the most part, except that <li>s has almost no height.
The HTML and CSS in JSFiddle is here if you want to link to it in addition to below:
HTML:
<div> <ul class="Container"> <li> <span class="Item"> <a href="#"><img src="http://jsfiddle.net/img/logo.png"/></a> <span class="Info"> <a href="#">Title One</a> <span class="Details">One Point One</span> </span> </span> </li> <li> <span class="Item"> <a href="#"><img src="http://jsfiddle.net/img/logo.png"/></a> <span class="Info"> <a href="#">Title Two</a> <span class="Details">Two Point One</span> </span> </span> </li> </ul>
CSS
.Container { list-style-type:none; } .Container li { background-color:grey; display:inline; text-align:center; } .Container li .Item { border:solid 2px #ccc; display:inline-block; min-height:50px; vertical-align:top; width:170px; } .Container li .Item .Info { display:inline-block; } .Container li .Item .Info a { display:inline-block; width:160px; }
If you look at the result in the jsfiddle link, you will see that the gray background includes only a small strip of just <li> . I know that changing the <li> to display:inline-block solves this problem, but this is not possible for other reasons.
So, first of all, I'm just looking to see if anyone understands why the inline <li> element has no height. I can not find anything in the specification that explains this. I know that I cannot add height to the inline element, but any explanation of why this is happening that might allow me to fix would be great.
Secondly, if you test the elements using IE Developer Mode, you will see that although the background color is in the right place, the actual location of the <li>'s bounding box is at the bottom of the container in accordance with the hover over the element. I could solve this problem if it were at the top in every browser, but it seems to be changing.
NOTE. In this case, I donโt care about old browsers, but I do not use HTML5 or JavaScript positioning.
Thanks.