Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering floated elements in full-width div

Tags:

css

css-float

I'm working on a product catalog page, and the group of images needs to be centered but I have yet to find a way to do so, since they're all floated in a div that's a 100% in width.

I'm looking for a way to center those images horizontally without losing the flexibility of their floating properties.

Here's a link to the catalog on the website: http://internetvolk.de/katalog/

like image 650
Tobias Timpe Avatar asked Jun 21 '26 03:06

Tobias Timpe


2 Answers

try using display: inline-block; istead of floating and add text-align: center to their parent container)

like image 188
skip405 Avatar answered Jun 27 '26 03:06

skip405


Augment with the following rules:

#katalog {
    text-align: center;
}

and

.imageLink {
    /** float: left; <-- REMOVE! */
    display: inline-block;
}
like image 31
calebds Avatar answered Jun 27 '26 04:06

calebds



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!