HighDots Forums  

centering question

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss centering question in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alex K
 
Posts: n/a

Default centering question - 02-07-2008 , 12:41 PM






Does anyone know how to make a div take the width of what it contains?
NOT the width of what contains it. This is usefull when we don't know
the size of the content in advance. Thank you so much.

Alex

Reply With Quote
  #2  
Old   
Ben C
 
Posts: n/a

Default Re: centering question - 02-07-2008 , 01:32 PM






On 2008-02-07, Alex K <alex.ksikes (AT) gmail (DOT) com> wrote:
Quote:
Does anyone know how to make a div take the width of what it contains?
NOT the width of what contains it. This is usefull when we don't know
the size of the content in advance. Thank you so much.
Make it float: left (or right), display: table-cell, display: table, or
display: inline-block.

Of those only the first is reliable cross-browser.

Judging by the Subject line your next question is going to be how do I
centre this shrink-to-fit container. Unfortunately if you chose float
you can't.

If you need a centered shrink-to-fit block that also works in IE, the
only option is HTML tables.


Reply With Quote
  #3  
Old   
dorayme
 
Posts: n/a

Default Re: centering question - 02-07-2008 , 03:24 PM



In article <slrnfqmn82.kg8.spamspam (AT) bowser (DOT) marioworld>,
Ben C <spamspam (AT) spam (DOT) eggs> wrote:

Quote:
On 2008-02-07, Alex K <alex.ksikes (AT) gmail (DOT) com> wrote:
Does anyone know how to make a div take the width of what it contains?
NOT the width of what contains it. This is usefull when we don't know
the size of the content in advance. Thank you so much.

Make it float: left (or right), display: table-cell, display: table, or
display: inline-block.

Of those only the first is reliable cross-browser.

Judging by the Subject line your next question is going to be how do I
centre this shrink-to-fit container. Unfortunately if you chose float
you can't.

If you need a centered shrink-to-fit block that also works in IE, the
only option is HTML tables.
Perhaps OP will benefit from:

<http://netweaver.com.au/alt/shrinkTo...teringShrinkTo
Fit.html>

--
dorayme


Reply With Quote
  #4  
Old   
BootNic
 
Posts: n/a

Default Re: centering question - 02-08-2008 , 10:40 AM



dorayme <doraymeRidThis (AT) optusnet (DOT) com.au> wrote in news:doraymeRidThis-
978BE2.08240508022008 (AT) news-vip ...ptusnet.com.au:

[snip]
Quote:
Perhaps OP will benefit from:

http://netweaver.com.au/alt/shrinkTo...teringShrinkTo
Fit.html
Oh is see a mistake. Silly me, what was I thinking when I used inline-box
for IE. It should be inline-block, but I suppose that is the reason I added
zoom:1; to the rule all in an effort to trigger hasLayout.

Now that is done display:inline-box; should be display:inline-block; and
since I don't recall if IE less then 6 needs zoom:1; or not I would leave
that is as well since it's in a conditional comment.

--
BootNic Friday February 8, 2008 11:40 AM
Behind every successful woman...is a basket of dirty laundry.
*Sally Poe*


Reply With Quote
  #5  
Old   
dorayme
 
Posts: n/a

Default Re: centering question - 02-08-2008 , 02:45 PM



In article <Xns9A3E76D7596E2BootNic (AT) bootnic (DOT) motzarella.org>,
BootNic <bootnic.bounce (AT) gmail (DOT) com> wrote:

Quote:
dorayme <doraymeRidThis (AT) optusnet (DOT) com.au> wrote in news:doraymeRidThis-
978BE2.08240508022008 (AT) news-vip ...ptusnet.com.au:

[snip]

Perhaps OP will benefit from:

http://netweaver.com.au/alt/shrinkTo...teringShrinkTo
Fit.html

Oh is see a mistake. Silly me, what was I thinking when I used inline-box
for IE. It should be inline-block, but I suppose that is the reason I added
zoom:1; to the rule all in an effort to trigger hasLayout.

Now that is done display:inline-box; should be display:inline-block; and
since I don't recall if IE less then 6 needs zoom:1; or not I would leave
that is as well since it's in a conditional comment.
I should have picked this one up myself. Perhaps at the time I
regarded anything for IE as like a smelly rat, best left to
professional pest inspectors. That's you, Bootnic!

I have taken the opportunity to add a comment in the source for
the page you refer to. It elevates you in a style that reminds me
of the way Virgil used to describe his characters, especially
heroes. See the Aeneid. You are now "the keen-eyed Bootnic".

<g>

--
dorayme


Reply With Quote
  #6  
Old   
BootNic
 
Posts: n/a

Default Re: centering question - 02-08-2008 , 04:46 PM



dorayme <doraymeRidThis (AT) optusnet (DOT) com.au> wrote in
news:doraymeRidThis-9B7AEC.07451509022008 (AT) news-vip (DOT) optusnet.com.au:

Quote:
In article <Xns9A3E76D7596E2BootNic (AT) bootnic (DOT) motzarella.org>,
BootNic <bootnic.bounce (AT) gmail (DOT) com> wrote:

dorayme <doraymeRidThis (AT) optusnet (DOT) com.au> wrote in
news:doraymeRidThis- 978BE2.08240508022008 (AT) news-vip ...ptusnet.com.au:

[snip]

Perhaps OP will benefit from:

http://netweaver.com.au/alt/shrinkTo...teringShrinkTo
Fit.html

Oh is see a mistake. Silly me, what was I thinking when I used
inline-box for IE. It should be inline-block, but I suppose that is
the reason I added zoom:1; to the rule all in an effort to trigger
hasLayout.

Now that is done display:inline-box; should be display:inline-block;
and since I don't recall if IE less then 6 needs zoom:1; or not I
would leave that is as well since it's in a conditional comment.

I should have picked this one up myself. Perhaps at the time I
regarded anything for IE as like a smelly rat, best left to
professional pest inspectors. That's you, Bootnic!

I have taken the opportunity to add a comment in the source for
the page you refer to. It elevates you in a style that reminds me
of the way Virgil used to describe his characters, especially
heroes. See the Aeneid. You are now "the keen-eyed Bootnic".
LOL ... Not sure keen-eyed fits, after all it only took 3 months for me
to spot me own mistake.

Now me pants are back up tis time to tuck in me shirt. Tis one more
inline-box that needs to be changed to inline-block. On the URL you
provided that describes my indiscretion.

--
BootNic Friday February 8, 2008 5:46 PM
The only thing wrong with immortality is that it tends to go on
forever.
*Herb Caen*


Reply With Quote
  #7  
Old   
dorayme
 
Posts: n/a

Default Re: centering question - 02-08-2008 , 07:20 PM



In article <Xns9A3EB4DD3F9CEBootNic (AT) bootnic (DOT) motzarella.org>,
BootNic <bootnic.bounce (AT) gmail (DOT) com> wrote:

Quote:
Tis one more
inline-box that needs to be changed to inline-block. On the URL you
provided that describes my indiscretion.
Right, fixed now... was only looking at the demo mark up
before... <g>

--
dorayme


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.