473,770 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Images with captions centered?

Hello,
I've been struggling with this problem for a while now, so I though I'd
get some input from anyone more skilled with CSS than I am.

I'm actually trying to accomplish two things with this:

1. Create a floated image with text around, with a caption centered
underneath. Image size can be varied but the caption needs to have a
fixed size to make it break correctly I think. I also need the image to
resize automatically when the browsers width gets very small, using the
'max-width' attribute, and this is where the problem lies, since Firefox
does not seem to accept the max-width attribute and handles it like the
image is non-existent or very small. It works like expected in MSIE 6 and
Opera 8.

2. Inspired by a 'A List Apart' article (see [1] below), I'm trying to
create a fluid way to display images with captions, but with the image-
display *centered* and with the possibility of different image sizes (ALA
had fixed image sizes). I've tried many different solutions but recently
tried using 'display: image-block' which judging from the CSS 2.1
standard should be the way to go, and it works perfectly in Opera but
fails totally in FF and MSIE, who just displays the images one below the
other.

I know the first problem can be fixed by not using max-width but I'd
really like to have it work with it. I guess Opera is the only browser
supporting on-the-fly resizing of images this way, is this correct?

As to the second problem, my guess is that using another solution than
inline-block would solve it but I've tried display:block and different
wrapper classes. Floating to the left would do it but I really want the
images centered, not to the left.

Is there a standards-compliant way to make this work in both Opera, FF
and MSIE?

I have created a test case for both problems here:
http://stian.freeshell.org/test/float/float.html

Could someone please have a look at this and give me some hints to what I
can do to fix the problems or improve the methods I'm using?

reagards,
Stian

links:
[1] http://www.alistapart.com/articles/practicalcss/
Sep 15 '05
17 2272
In news:MP******** *************** *@news.individu al.net,
Lauri Raittila <la***@raittila .cjb.net> typed:
| in comp.infosystem s.www.authoring.stylesheets, Stian Lund wrote:
|
|| With display: inline-block Opera needs to have width of the image set
|| explicitly while FF and MSIE apparently don't need to.
|
| I thought it was Gecko that don't get inline-block without width...
|
|| Working on it... thanks for all help!
|
| Here is example:
| http://www.student.oulu.fi/~laurirai/www/css/gallery/
|
| No widths or heights needed, works in big 3 (versions 6, 8, 1 tested)
|
| I would be interested to know support in other browsers, especially
KHTML
| based, and new Geckos
At the example page (link above) in the code to start listing the
thumb images -
what does the div class='thumbS' refer to?
<div class='thumbs'> <div class='thumb'>

RoseW
Sep 17 '05 #11
in comp.infosystem s.www.authoring.stylesheets, RoseW wrote:
In news:MP******** *************** *@news.individu al.net,
Lauri Raittila <la***@raittila .cjb.net> typed: | Here is example:
| http://www.student.oulu.fi/~laurirai/www/css/gallery/ At the example page (link above) in the code to start listing the
thumb images - what does the div class='thumbS' refer to?
<div class='thumbs'> <div class='thumb'>


Nothing. It was left there from earlier version, which was not working on
Gecko. It is not needed, IIANM (you never know what IE does...)

This version uses bug in gecko that makes tables with display:inline
inline-table.

It is strange that gecko has not enabled display:inline-table, as it
works to set element to table using css (with display:table-row or table-
cell) and then setting display:inline.
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Sep 17 '05 #12
On Fri, 16 Sep 2005 14:36:49 +0200, in
comp.infosystem s.www.authoring.stylesheets , Lauri Raittila
<la***@raittila .cjb.net> in
<MP************ ************@ne ws.individual.n et> wrote:
in comp.infosystem s.www.authoring.stylesheets, Stian Lund wrote:
With display: inline-block Opera needs to have width of the image set
explicitly while FF and MSIE apparently don't need to.


I thought it was Gecko that don't get inline-block without width...
Working on it... thanks for all help!


Here is example:
http://www.student.oulu.fi/~laurirai/www/css/gallery/

No widths or heights needed, works in big 3 (versions 6, 8, 1 tested)

I would be interested to know support in other browsers, especially KHTML
based, and new Geckos


Could you explain a bit of the code to me? Here is the excerpt:

..thumb {display:inline ;}
..thumb {padding:5px;ve rtical-align:middle;}
..thumb {display:inline-block;}
..thumb {display:inline-table;}
..thumb > a, .thumb > div {display:table-row;}

Doesn't that end up with display having the value inline-table? And
what does the '>' do in the last line?

--
Matt Silberstein

Do something today about the Darfur Genocide

Genocide is news | Be A Witness
http://www.beawitness.org

"Darfur: A Genocide We can Stop"
www.darfurgenocide.org

Save Darfur.org :: Violence and Suffering in Sudan's Darfur Region
http://www.savedarfur.org/
Sep 24 '05 #13
Matt Silberstein wrote in message news:sr******** *************** *********@4ax.c om...
Lauri Raittila wrote:
Stian Lund wrote:
With display: inline-block Opera needs to have width of the image set
explicitly while FF and MSIE apparently don't need to.
I thought it was Gecko that don't get inline-block without width...
Working on it... thanks for all help!


Here is example:
http://www.student.oulu.fi/~laurirai/www/css/gallery/

No widths or heights needed, works in big 3 (versions 6, 8, 1 tested)

I would be interested to know support in other browsers, especially KHTML
based, and new Geckos


Could you explain a bit of the code to me? Here is the excerpt:

.thumb {display:inline ;}
.thumb {padding:5px;ve rtical-align:middle;}
.thumb {display:inline-block;}
.thumb {display:inline-table;}
.thumb > a, .thumb > div {display:table-row;}

Doesn't that end up with display having the value inline-table?


http://www.w3.org/TR/REC-CSS1#display
in css1 'display' has only values of: block | inline | list-item | none
so the last two would be invalid anyway

http://www.w3.org/TR/REC-CSS2/visure...ropdef-display
in css2 there is no inline-block value for the display anyway
'display'
Value: inline | block | list-item | run-in | compact | marker |
table | inline-table | table-row-group | table-header-group |
table-footer-group | table-row | table-column-group |
table-column | table-cell | table-caption | none | inherit
and since all values are "or" |, you are correct that the last one will decide.

http://www.w3.org/TR/2003/WD-css3-co...30514/#display
CSS3 will be somehow different ;-)
And what does the '>' do in the last line?


http://www.w3.org/TR/CSS2/selector.html#q1
should explain everything
Sep 24 '05 #14
in comp.infosystem s.www.authoring.stylesheets, Matt Silberstein wrote:
On Fri, 16 Sep 2005 14:36:49 +0200, in
comp.infosystem s.www.authoring.stylesheets , Lauri Raittila:
Here is example:
http://www.student.oulu.fi/~laurirai/www/css/gallery/

No widths or heights needed, works in big 3 (versions 6, 8, 1 tested)

I would be interested to know support in other browsers, especially KHTML
based, and new Geckos


Could you explain a bit of the code to me? Here is the excerpt:

.thumb {display:inline ;}


This is for IE to support inline-block and Gecko (see later)
.thumb {padding:5px;ve rtical-align:middle;}
.thumb {display:inline-block;}
This is for IE and other browsers not implementing inline-table
.thumb {display:inline-table;}
For Opera 4+
.thumb > a, .thumb > div {display:table-row;}
For Gecko, makes outer element table with display:inline
Doesn't that end up with display having the value inline-table?
Yes. So any ideal browser gets this right.
And what does the '>' do in the last line?


Just a selector, as this line is not needed for IE, it doesn't matter if
it doesn't get > selector.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Sep 24 '05 #15
in comp.infosystem s.www.authoring.stylesheets, Robi wrote:
Matt Silberstein wrote in message news:sr******** *************** *********@4ax.c om...
Lauri Raittila wrote:
Stian Lund wrote:

http://www.student.oulu.fi/~laurirai/www/css/gallery/
.thumb {display:inline ;}
.thumb {padding:5px;ve rtical-align:middle;}
.thumb {display:inline-block;}
.thumb {display:inline-table;}
.thumb > a, .thumb > div {display:table-row;}

Doesn't that end up with display having the value inline-table?

Only if browser regognizes it.
http://www.w3.org/TR/REC-CSS1#display
in css1 'display' has only values of: block | inline | list-item | none
so the last two would be invalid anyway http://www.w3.org/TR/REC-CSS2/visure...ropdef-display
in css2 there is no inline-block value for the display anyway
'display'
But it works in IE5+ (with display:inline in IE6 standards). Correct
behaviour by CSS2 is to ignore it, and that is just fine.
http://www.w3.org/TR/2003/WD-css3-co...30514/#display
CSS3 will be somehow different ;-)


See CSS21. I know it is not REC, but there is nothing better, exept CSS1.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Sep 24 '05 #16
On Sat, 24 Sep 2005 08:09:20 +0200, in
comp.infosystem s.www.authoring.stylesheets , Lauri Raittila
<la***@raittila .cjb.net> in
<MP************ ************@ne ws.individual.n et> wrote:
in comp.infosystem s.www.authoring.stylesheets, Matt Silberstein wrote:
On Fri, 16 Sep 2005 14:36:49 +0200, in
comp.infosystem s.www.authoring.stylesheets , Lauri Raittila:

>Here is example:
>http://www.student.oulu.fi/~laurirai/www/css/gallery/
>
>No widths or heights needed, works in big 3 (versions 6, 8, 1 tested)
>
>I would be interested to know support in other browsers, especially KHTML
>based, and new Geckos


Could you explain a bit of the code to me? Here is the excerpt:

.thumb {display:inline ;}


This is for IE to support inline-block and Gecko (see later)
.thumb {padding:5px;ve rtical-align:middle;}
.thumb {display:inline-block;}


This is for IE and other browsers not implementing inline-table
.thumb {display:inline-table;}


For Opera 4+
.thumb > a, .thumb > div {display:table-row;}


For Gecko, makes outer element table with display:inline
Doesn't that end up with display having the value inline-table?


Yes. So any ideal browser gets this right.
And what does the '>' do in the last line?


Just a selector, as this line is not needed for IE, it doesn't matter if
it doesn't get > selector.


Thanks for this help and thanks to Robi for the links.
--
Matt Silberstein

Do something today about the Darfur Genocide

Genocide is news | Be A Witness
http://www.beawitness.org

"Darfur: A Genocide We can Stop"
www.darfurgenocide.org

Save Darfur.org :: Violence and Suffering in Sudan's Darfur Region
http://www.savedarfur.org/
Sep 26 '05 #17
Lauri Raittila wrote in message news:MP******** *************** *@news.individu al.net...
in comp.infosystem s.www.authoring.stylesheets, Matt Silberstein wrote:
On Fri, 16 Sep 2005 14:36:49 +0200, Lauri Raittila:
Here is example:
http://www.student.oulu.fi/~laurirai/www/css/gallery/

No widths or heights needed, works in big 3 (versions 6, 8, 1 tested)

I would be interested to know support in other browsers, especially KHTML
based, and new Geckos
Could you explain a bit of the code to me? Here is the excerpt:

.thumb {display:inline ;} //[1]
.thumb {padding:5px;ve rtical-align:middle;}
.thumb {display:inline-block;} //[2]
.thumb {display:inline-table;} //[3]
.thumb > a, .thumb > div {display:table-row;} //[4]

Doesn't that end up with display having the value inline-table?


Yes. So any ideal browser gets this right.

[1] This is for IE to support inline-block and Gecko (see later)
[2] This is for IE and other browsers not implementing inline-table
[3] For Opera 4+
[4] For Gecko, makes outer element table with display:inline

And what does the '>' do in the last line?


Just a selector, as this line is not needed for IE, it doesn't matter if
it doesn't get > selector.


It is simply amazing, the concoctions you need to do to support certain
browsers while it's also amazing what browsers don't support.

Honestly, sometimes I wonder how authors keep on developing websites
while bending backwards to allow just about any browser to access their
website.
Sep 26 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1809
by: Jeff Thies | last post by:
I'd like to place a "caption" under an image and insert both into the flow of text. I'm thinking of something like this: (Styles shown inline for readability, they would be defined as classes) <div style="float: left; padding: 10px"><img src="some_image.jpg"><div>my caption/credit</div></div> <p> enough content to flow around the image....</p>
5
12350
by: Applebrown | last post by:
Hello, basically, I'm just learning intermediate CSS and trying to convert my old table webpage completely to CSS. Hoorah, right? Well, it's not quite going as planned. It's an extremely simple layout, and I'm finding myself stuck with small white space in between my images where I planned for the graphics to be stacked up right on top of one another. Here's the simple vertical layout: width is 640px, centered with a CSS border. I'd...
11
4215
by: mercurius_1 | last post by:
I need some help with this page: http://www.sarahpollock.com/new/x.php I stole much of this layout from "A List Apart," but I'm no CSS guru and I desperately need some help with the finishing details because everything I've tried so far has flopped. I would really appreciate your insight on the following items: 1 - I would like to get the four images across the top to be in the overall center of the page (Like most everything else on...
61
4755
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the important part ... also work with backgrounds in other tags. I fail to see any wisdom in making SVG different than say PNG (of course the implementation of the rendering code would obvious be different). --
9
2521
by: Troy Piggins | last post by:
If I use the code: ----- <div style="text-align: center;"> <a href="photos.php?img=xx1.jpg"> <img src="xx1.jpg" style="padding: 10px;" /> </a> <a href="photos.php?img=xx2.jpg">
14
1971
by: windandwaves | last post by:
Hi Folk and Gurus This may help some of you (though probably not the gurus), in changing images: http://www.sunnysideup.co.nz/j/imageChange/ Any feedback appreciated. Cheers
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.