473,416 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

put a block element into a line, makes it behave like <img>?

Hello. This is problem puzzled me a long time. I wish to organize some
block elements and let them flow one after each other like text.

Think about a album, I wish the album have 12 thumbnails, each one has a
comment line under the picture. And I wish when the screen size is big,
this thumbnails arrange 3 rows, 4 columns; if the browser window is
smaller, arranges 4 rows, 3 columns; if it's even smaller, 6 rows with 2
columns. If there are only thumbnails, it's very simple, just flow each
thumbnail down with proper margin and padding:
<div> <img ... /> <img ... /> .... </div>

But now each image has a line of comment, so it is like this:
<div>
<div class="thumbnail"><img ... /><br/><p> Comments here ... </p> </div>
<div class="thumbnail"><img ... /><br/><p> Comments here ... </p> </div>
......
</div>

I wonder how to make div.thumbnail look like a single <img/>.

This is very simple in IE (although I am not sure if it is standard
way), just let div.thumbnail {display: inline;} and the effect is what I
wanted. This is the screen shot on IE:
http://218.85.101.134/ie6.png (file stays a week)

But for mozilla, this would cause very strange arrangement:
http://218.85.101.134/mozilla.png (file stays a week)

This buggy webpage can be visited at:
http://www.zhangweiwu.com/album_group.html
Jul 21 '05 #1
7 2605
Hi Weiwu.

Zhang Weiwu wrote:
Think about a album, I wish the album have 12 thumbnails, each one has a
comment line under the picture. And I wish when the screen size is big,
this thumbnails arrange 3 rows, 4 columns; if the browser window is
smaller, arranges 4 rows, 3 columns; if it's even smaller, 6 rows with 2
columns. If there are only thumbnails, it's very simple, just flow each
thumbnail down with proper margin and padding:
<div> <img ... /> <img ... /> .... </div>

But now each image has a line of comment, so it is like this:
<div>
<div class="thumbnail"><img ... /><br/><p> Comments here ... </p> </div>
<div class="thumbnail"><img ... /><br/><p> Comments here ... </p> </div>
.....
</div>


I do this by setting each div containing a thumbnail to be the same
width and then floating them all. For example, see:

http://mcc.id.au/photos/svgopen2004/day2/

Each thumbnail is in a div, like:

<div class="photo">
<div>
<a href="1">
<img
src="http://www.bur.st/~clm/photos/svgopen2004/day2/1.thumb.jpg"
alt="Conference registration" width="150" height="112"/>
</a>
</div>
<div class="caption">Conference registration</div>
<div class="date">September 7 2004, 4:55pm</div>
</div>

Each div.photo is styled with:

.photo {
float: left;
margin-top: 0.75em;
margin-right: 1.5em;
text-align: center;
width: 150px;
height: 20em;
}

Hope this helps,

Cameron

--
Cameron McCormack
| Web: http://mcc.id.au/
| ICQ: 26955922

Replies by e-mail must include the current month name in subject line to
bypass spam filter.
Jul 21 '05 #2
Zhang Weiwu wrote;
Hello. This is problem puzzled me a long time. I wish to organize some
block elements and let them flow one after each other like text.
display:inline-block

CSS2.1, partially works in Opera 7. Work in IE.

display:inline-table

CSS2, works on Opera 5+

thing {display:inline-block}
thing {display:inline-table}

Gets best results. If doesn't, add display:inline thing before inline-
block.
But now each image has a line of comment, so it is like this:
<div>
<div class="thumbnail"><img ... /><br/><p> Comments here ... </p> </div>
<div class="thumbnail"><img ... /><br/><p> Comments here ... </p> </div>
.....
</div>
Why <br/>? It seems to unnecessary, and has no semantical value.
I wonder how to make div.thumbnail look like a single <img/>.

This is very simple in IE (although I am not sure if it is standard
way), just let div.thumbnail {display: inline;} and the effect is what I
wanted. This is the screen shot on IE:
http://218.85.101.134/ie6.png (file stays a week)
Use correct CSS I showed earlier, and then it is not bug, but correct
behaviour.
But for mozilla, this would cause very strange arrangement:
http://218.85.101.134/mozilla.png (file stays a week)


Mozilla is bad at CSS. You need to use float for it. Makes it harder to
align differently sized boxes vertically, and you can't center the
content.
Centered gallery with captions example:
http://www.student.oulu.fi/~laurirai...allery/cc.html
I would love to hear how it works on other browsers:
Opera 7, IE6 - show like intended
Firefox, Firebird - show boxes left aligned
Others?
Does
http://www.student.oulu.fi/~laurirai/www/css/gallery/
Work better?

Someone already told you how to make floated boxes, I recommend that if
you can live with restrictions.
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 21 '05 #3
Lauri Raittila <la***@raittila.cjb.net> wrote:
Hello. This is problem puzzled me a long time. I wish to organize some
block elements and let them flow one after each other like text.
display:inline-block

CSS2.1, partially works in Opera 7. Work in IE.


Inline-block does nothing on a block level element in IE.
Centered gallery with captions example:
http://www.student.oulu.fi/~laurirai...allery/cc.html


Seems a bit to complex, simpler imo:
http://www.spartanicus.utvinternet.i...h_captions.htm
I didn't bother much with how Gecko renders it.

--
Spartanicus
Jul 21 '05 #4
Spartanicus wrote;
Lauri Raittila <la***@raittila.cjb.net> wrote:
Hello. This is problem puzzled me a long time. I wish to organize some
block elements and let them flow one after each other like text.
display:inline-block

CSS2.1, partially works in Opera 7. Work in IE.


Inline-block does nothing on a block level element in IE.


Gee, I was lied earlier, apparently. It seems that IE don't regognize
inline-block at all. (makes no difference weather it is there or not. I
thought I had tested it, but apparently didn't)

Or maybe the someone talking me said it was MacIE...
Centered gallery with captions example:
http://www.student.oulu.fi/~laurirai...allery/cc.html

Seems a bit to complex, simpler imo:
http://www.spartanicus.utvinternet.i...h_captions.htm
That is because there is extra stuff in mine that is not really
necessary. And of course, yours will look ugly when there is differently
sized thumpsnails.
(I cut and pasted the HTML, not bothered to clean it. It is needed for
styling on other page, and inline styles are there as I had forgotten
them...).

I don't like you markup using p element for image and caption. It don't
fit definition of paragraph. Why not use table, it would suit much better
than p. In fact, it would propably degrade better.

<table>
<tr><td><img><th>caption
</table>
I didn't bother much with how Gecko renders it.


That was done one line in my example.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 21 '05 #5
Lauri Raittila <la***@raittila.cjb.net> wrote:
>> Hello. This is problem puzzled me a long time. I wish to organize some
>> block elements and let them flow one after each other like text.
>
>display:inline-block
>
>CSS2.1, partially works in Opera 7. Work in IE.
Inline-block does nothing on a block level element in IE.


Gee, I was lied earlier, apparently.


I recently pointed out to you that IE supports inline-block to some
extent (note the "to some extent"). But it doesn't do anything on an
elements that default to block, it only works on elements that default
to inline.
It seems that IE don't regognize inline-block at all.
It works fine on elements that default to inline, see the url I posted.
Or maybe the someone talking me said it was MacIE...
Nope, IE win.
>Centered gallery with captions example:
>http://www.student.oulu.fi/~laurirai...allery/cc.html

Seems a bit to complex, simpler imo:
http://www.spartanicus.utvinternet.i...h_captions.htm


That is because there is extra stuff in mine that is not really
necessary. And of course, yours will look ugly when there is differently
sized thumpsnails.


Why?:
http://www.spartanicus.utvinternet.i..._captions2.htm
I don't like you markup using p element for image and caption. It don't
fit definition of paragraph.
The image and the caption need to be grouped together and separated from
other image/caption combo's in the same gallery. Paragraph markup is the
correct way to achieve that. In one form an image/caption combo is
strictly text, some may feel that a paragraph should consist of multiple
sentences, this is nonsense. Paragraph markup is appropriate regardless
of how much text it encompasses, as long as the text it contains belongs
together and needs to be separated from other content then paragraph
markup is correct.
Why not use table, it would suit much better
than p. In fact, it would propably degrade better.

<table>
<tr><td><img><th>caption
</table>


1 row 2 cell table markup arguably would not be unsuitable, but IIRC UA
support for positioning the caption beneath the image is poor (only
works in O7 IIRC).

--
Spartanicus
Jul 21 '05 #6
Spartanicus wrote;
Lauri Raittila <la***@raittila.cjb.net> wrote:
>display:inline-block
>
>CSS2.1, partially works in Opera 7. Work in IE.

Inline-block does nothing on a block level element in IE.
Gee, I was lied earlier, apparently.


I recently pointed out to you that IE supports inline-block to some
extent (note the "to some extent"). But it doesn't do anything on an
elements that default to block, it only works on elements that default
to inline.


Hm, I tested on quirks mode, which explains things.
http://www.spartanicus.utvinternet.i...h_captions.htm


will look ugly when there is differently
sized thumpsnails.


Why?:
http://www.spartanicus.utvinternet.i..._captions2.htm


[ try use shorter urls, so that I can quote them under 80.]

Now, make them random order, and not growing linearly in both all
directions. Sure you can live with it, but imho if captions would be on
same line it would look better. (you still have one option though - but
with bit more markup, there would be many options - and markup would be
better)

My example doesn't look that good either at the moment, I know. But as I
don't use br, and have box in img, I can do lots.
I don't like you markup using p element for image and caption. It don't
fit definition of paragraph.


The image and the caption need to be grouped together and separated from
other image/caption combo's in the same gallery.


Correct. Use grouping element, called div. If you need to group
something, that is not text, do not use P.
Paragraph markup is the correct way to achieve that.
It surely is not. Paragraph markup is for paragraphs. Are you too
boneheaded to know what know paragraph? There is div for use in cases
there is no other suitable elemenet.

You markup also causes problems, when user agent assumes that paragraph
is paragraph, and shows it somehow different that div, to take advantage
of the fact that it is paragraph, not some random content. Like max-width
for better readability.

I find it wrong to have image inside P, but I know there is different
opinions on this, and I can understand them. But I can't understand you
when you are not having any paragraph in its normal meaning. Show your
frien a mail order catalog, draw border around an image and caption, as
what he thinks it is. I bet he don't say it is paragraph, even if he
doesn't know better name for it.
In one form an image/caption combo is
strictly text,
I find it rather amazing that you say that image is text. Of course, it
does not say in dictionary that image is not text, but that is pretty
irrelevant. Why don't you make survey: show your image of butterfly with
caption to 100 people, ask them what they think it is

a) text
b) image
c) photo
d) paragraph

I would be very surprised, if you come with result that has one answer a.
C is there so that people don't think that you are fooling with them and
answer wrongly on purpose. You may use d) instead/with a)...
some may feel that a paragraph should consist of multiple
sentences, this is nonsense.


The paragraph is there for text. It has no use semantically if it is used
as general element to hold just about anything. A paragraph can be just
one sentence, and a word can be a sentence. But an image and a caption is
not paragraph, especially it is not paragraph, when you have list of
images with captions.

What you don't seem to get is that if you use some element to something,
that it is not very far fetched from it's orginal purpose, you make the
element unusable. There is no sence in semantics, if they are so vague
that one can't assume anything of them. In html, all elements are
traditionally used incorrectly, and most are defined stupid way - but
that doesn't mean you are allowed to strech definitions even farther, if
it suits you.
Why not use table, it would suit much better
than p. In fact, it would propably degrade better.

<table>
<tr><td><img><th>caption <tr>td><img><th>caption2</table>

Sorry, should have added more rows show what I meaned. If I am not
mistaken, it should be just as easy to get work as with current markup.
Caption alignment is irrelevant with this kind of table.

Of course, there is many ways to use table to combine image and caption
that are more logical that paragraph, but IMO it is not good use of
table.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 21 '05 #7
Lauri Raittila <la***@raittila.cjb.net> wrote:
Are you too boneheaded to know what know paragraph?


You're behaviour of late has fallen substantially below what I consider
the minimum requirement to engage with. Good luck with that attitude.

Bye.

--
Spartanicus
Jul 21 '05 #8

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

Similar topics

5
by: MyndPhlyp | last post by:
I've been busting my head trying to figure this out for quite some time. With IE6 and NS7, no problems. I can simply code the HTML <img height="100%"> and be done with it. But NS4 and NS6 (and...
9
by: Wladimir Borsov | last post by:
As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel...
8
by: KS | last post by:
Just to show some code to show the consept. <img id="date" onclick="javascript:show_calendar();" src="/PlexSysWeb/images/show-calendar.gif" width=20 height=18 border=0> What i want the...
15
by: Gérard Talbot | last post by:
Hello all, I'd like to know and understand the difference between, say, <img src="/ImageFilename.png" width="123" height="456" alt=""> and <img src="/ImageFilename.png" style="width:...
3
by: Henry Johnson | last post by:
Okay - I'm spinning my wheels on this one... can someone help me figure out how to programmatically populate a table cell as follows (from C# code-behind)? I've tried using a Literal control in the...
10
by: News | last post by:
I am trying to be able to manipulate the width and height of an <img> but do not seem to be able. "Yes", I know the JavaScript will "not" manip anything, which is ok. I simply do not know how to...
4
by: SammyBar | last post by:
Hi all, I wonder is it possible to upload the content of an <imgfield to a server. The content of the <imgwas downloaded from a web site different from the one it should be uploaded. The image...
4
by: Jon Slaughter | last post by:
I have a captcha system going and for some reason when I use <?php $s = ""; for($i = 0; $i < 10; $i++) { $s = $s.rand(0,9); } $_SESSION = $s; $fn = '/Login/Register/Captcha.php'; echo '<img...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...

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.