简体   繁体   中英

How to align an image to the center with css?

I have three images. The need to be aligned so they fit on the same line and are centered. I have managed to align the 1st and 3rd image using float: left; and float: right; but I'm struggling to align the center image.

https://dl.dropbox.com/u/94786808/example.png

Here's the involved code:

.postprojects {
     margin-top: 60px;
     padding-left: 35px;
     padding-right: 35px;
     padding-top: 35px;
     background-image:url('image/bgprojects.png');
     width: 889px;
     height: 300px;
     }

.postproject1 {
     float: left;
     overflow: hidden;
}

.postproject2 {
     float: left;
     overflow: hidden;
}

.postproject3 {
    float: right;
    overflow: hidden;
}

Any suggestions?

(PS Disregard the weird clipping on the bottom of the site. It's a padding error)

Try this code, may be:

.postproject2 {
    float: left;
    overflow: hidden;
    margin: 73px 10px 0;
}

Fiddle: http://jsfiddle.net/praveenscience/eFK7F/2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM