Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css inline-block does not works on the same level

I met some trouble with the property inline-block

It works fine, but When I fill one of my <li> it does not put them all at the same level.

I wanted all to have the same size (width and height)= and the same vertical position

Below is my css

ul#display-inline-block-example,
    ul#display-inline-block-example li {
        /* Setting a common base */
        margin-right: 10;
        margin-top: 10;
        padding: 0;
    }

    ul#display-inline-block-example li {
        display: inline-block;
        min-width: 121px;
        min-height: 95px;
        max-width: 121px;
        max-height: 95px;
        background: rgb(255,255,255); /* Old browsers */
        background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%); /* FF3.6+ */
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(47%,rgba(246,246,246,1)), color-stop(100%,rgba(237,237,237,1))); /* Chrome,Safari4+ */
        background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%); /* Chrome10+,Safari5.1+ */
        background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%); /* Opera 11.10+ */
        background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%); /* IE10+ */
        background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%); /* W3C */
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        box-shadow: 0 0 0 1px #fafafa inset, 0 1px 1px 0px #dddddd;
        border: 1px solid #d5d5d5;
        -webkit-box-shadow: 0 0 0 1px #fafafa inset, 0 1px 1px 0px #dddddd;
        -moz-box-shadow: 0 0 0 1px #fafafa inset, 0 1px 1px 0px #dddddd;
        text-align:center
    }

and then the html

<div class="main">
        <ul id="display-inline-block-example">
    <li><img src="images/history.png"></li>
    <li>Item two</li>
    <li>Item three</li>
    <li>Item one</li>
    <li>Item two</li>
    <li>Item three</li>
</ul>
        </div>

Anykind of help will be much appreciated

enter image description here

like image 909
Stanislas Piotrowski Avatar asked Dec 05 '22 07:12

Stanislas Piotrowski


2 Answers

try

vertical-align: top on your inline-block li elements

also see this link :

http://www.impressivewebs.com/inline-block/

like image 170
gaurav5430 Avatar answered Dec 28 '22 09:12

gaurav5430


vertical-align: top is the one your searching for . and it should be used on the elements that need vertical alignment . not on parent

and if u want to go further and have same margin between elements . independent of the number of elements . then have a look at this http://jsfiddle.net/JrZ3Z/1/

like image 40
Mihnea Belcin Avatar answered Dec 28 '22 09:12

Mihnea Belcin