Click here to get back home

Center-Aligning elements

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Center-Aligning elements gaijinco 05-12-2008
Posted by Jukka K. Korpela on May 19, 2008, 11:54 am
Please log in for more thread options
Scripsit Ben C:

>> Scripsit Ben C:
>>
>>>> My problem with display: inline-block is that when it does not
>>>> work, the effects can be devastating.
>> [...]
>>> You'd have similar problems if you were using float and CSS was
>>> turned off.

Having studied this a bit more, I think there's also the problem that
when you use <div> for the image/caption combinations that you then turn
to inline blocks in CSS, IE incorrectly defaults the width to 100% of
the available width. We can fix this by explicitly setting the width to
the image width, or that width plus some padding etc., but it's somewhat
less flexible then.

And when I use <span>, the non-CSS rendering is just awful, unless I use
<br>, doing something like
<span class="pic"><img ...><br>
<span class="caption">caption text<br></span></span>
which is possible but a little clumsy.

>> Regarding inline-block vs. float, what's the point? Support to
>> inline-block is increasing but still more limited than support to
>> float.
>
> With inline block the images in an image gallery can be different
> sizes without them "snagging" on each other as they try to float to
> the left.

I guess you're right, and we could use vertical-align to tune the
presentation in such cases.

> You can also put text-align: center on the container so they break up
> into centered rows, which is an effect I'm sure some people have asked
> for in these NGs in the past.

Point taken.

> The other nice thing about it is that the behaviour of replaced inline
> is very similar to that of inline-block so that the
> images-with-captions flow just like inline images do without
> captions. This makes it a good way to retro-fit captions.

Well, I don't think inline images are that common.

But the main problem is that browser support is poor. IE supports
display: inline-block since IE 5.5 but with flaws, such the one I
mentioned. Firefox 2 does not seem to support it all, and I think this
is strong enough reason to refrain from using it on www pages. Using
<br> a tolerable (?) fallback is possible, but the other methods work
fine - though with some of the nice features of inline blocks - on
practically all graphic browsers.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Posted by Ben C on May 19, 2008, 12:10 pm
Please log in for more thread options
[...]
> But the main problem is that browser support is poor. IE supports
> display: inline-block since IE 5.5 but with flaws, such the one I
> mentioned. Firefox 2 does not seem to support it all, and I think this
> is strong enough reason to refrain from using it on www pages. Using
><br> a tolerable (?) fallback is possible, but the other methods work
> fine - though with some of the nice features of inline blocks - on
> practically all graphic browsers.

I agree it's not practical to use it on the www yet. But it may be soon:
Firefox 3 I think supports it properly and I have heard rumours that
generally IE8 is a big step forwards from IE7 (let's hope they are
true).

I usually tell people how to do things with inline-block first and then
break the news to them that it isn't practical and they have to use
floats instead. The idea is to get them to aspire to a better world.

--
As for the future, your task is not to foresee it, but to enable it --
Antoine de Saint-Exupéry

Similar ThreadsPosted
CSS for All Elements (Bullets February 22, 2005, 12:17 pm
CSS gap between inline elements February 7, 2008, 3:03 am
Form and nested elements November 10, 2004, 11:57 am
Visibility of form elements December 3, 2004, 8:01 pm
Presentational and Structural Elements September 22, 2005, 10:56 am
form elements which should not be submitted March 9, 2006, 3:17 pm
custom tags and elements December 5, 2006, 4:57 am
Don't print certain elements from a page February 17, 2007, 3:38 pm
Extending HTML Elements April 19, 2007, 8:46 am
How to push elements to the bottom August 21, 2007, 6:07 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap