How to make my div align in CSS?


Tags: html,css

Problem :

This is my actual div: Pic1

This is the Pic1 HTML code, it will loop based on the database:

<ul class="productUl">
    <li class="productLi">
        <div class="productItem">
                   <!--my div content-->
        </div>
    </li>
</ul>

This is my CSS code:

.productItem{
    width: 15em;
    height: 13.8em;
    text-align:center;
    background-color: red;

}
.productUl{
    width: 750px;
    text-align:center;
    list-style-type:none;
    padding:5px;
    margin: 0;
} 

.productLi{
    width: 15em;
    float: left; 
    padding:0px 5px; 
}

But I found that my productItem is up and down, can not in same position Y, I know that I can set the position Y manually, but apart from setting position Y, can I do still keep them in position Y? any ideas on that?

This is what I want: Pic2



Solution :

It works for me.

Your problem is apparently elsewhere.

Can you show us a complete page?


    CSS Howto..

    How to make text in transparent div opaque? [duplicate]

    How to fix roll link in IE11

    How do I obtain a floating element's left offset while it is outside the viewport?

    How to make a background text appear under youtube video?

    how to add more specificity to css class .background-color-blue so it overrides default div's background color

    Chrome inspector not showing body outline correctly

    How to make html elements move up/ down as image height resizes using only css and html

    How to add text to a CSS Sprite

    How do I place an image after a link?

    How can I apply css to elements created with append()

    ASP.NET MVC: How do other people apply conditional CSS classes?

    How do I centralize an ordered list?

    CSS How to change background color of text?

    problem with internet explorer showing html input button which is hidden

    How Would I Center Text In This DIV?

    How do I add a “popup” shadow to an HTML element

    How to align logo and text in bootstrap on small screens?

    How can I make a photo which fit the div shape using css

    How to move all content (relative,absolute,…) down?

    How to apply custom CSS and Javascript specific CMS page Magento

    How to denote common class names with slight numeral changes into one - CSS shorthand?

    how to setup capybara-webkit to test ajax calls and get screenshots(html with css and javascript loaded)

    How to implement this button in HTML / CSS?

    CSS: How do I make text indent for a label with long text?

    How to display a centered background of fixed width

    How can I make LIs push their siblings to the same height?

    how to change height of div to covered the text area (CSS)

    How do I repeat select elements in HTML

    How to set size of a checkbox in table vaadin

    How do I make an inline-block stretch?