473,406 Members | 2,387 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,406 software developers and data experts.

Can a div's width expand to fit content's width?

Hi

I've created a banner with a drop-shadow using a div - there's a mock-
up at http://tinyurl.com/6n7czu . The only problem is that the way
I've done it, I have to specify the width of the div - if I don't, it
renders with a width of 100%. Is there any way of making the width fit
the text it encloses (plus padding), and so that it expand
automatically if you add more text?

Dave
Apr 8 '08
50 7159
VK
On Apr 10, 8:35 pm, Dave Rado <dave.r...@dsl.pipex.comwrote:
Floats don't meet my requirement for reasons discussed earlier in the
thread (the boxes have to be shrink-to-fit *and* centred). I've got it
working using tables though.
AFIAK you cannot reliably do it by CSS alone because of different
quirks on different browsers. It also very difficult to do because of
official by very silly treatment of overflow:auto. It is being taken
as kind of overflow:remainder, so "take all space what rest" while it
should be, as the name implies, "take exactly how much space you need
to accommodate the current content but not a pixel more".

I would stay with one cell table to keep things cross-browser
compatible and reliable.
Jun 27 '08 #51

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

Similar topics

1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
3
by: tungchau81 | last post by:
Hi, A Modal Dialog does not allow us to highlight the text content inside <DIV> tag unless I use a <textarea> tag to display that text content. However, the situation of my software makes it...
5
by: Bob Imperial | last post by:
Hi folks! In need of some enlightenment here, I'm trying to get my wrapper div to expand to accommodate height-wise, to whatever content is placed in it, no luck yet and I realize it's probably...
5
by: Agix | last post by:
Hi there, Please check out : http://clarifysolutions.co.uk/certenroll/ The source is included below. This page is a test, so I can play about with paddings, margins and layouts using divs as...
3
by: Kai Rosenthal | last post by:
Hello, I have two or more div elements which have the same min-width. <div class="wrapper"> <div class="element01">text01</div> <div class="element02">text02</div> ... </div> In a browser...
3
by: Max58kl | last post by:
Hi I am currently trying to create a FAQ webpage. At the moment the code I have lets me click on the Questions which successfully shows and hides the <DIV> tags containing the Answers. But...
6
by: AJM Project | last post by:
Hello, I see this is a well known thing and have seen many answers but none have worked for me. It's just a test page I'm making and I've ran into this so I thought I'd ask how to fix it - inline...
1
by: Chris Rock | last post by:
I have a "Looped Slider" that displays a series of images, but I've had to manually resize the images (using height/width tags), but I'm looking for some code that will take the width of the DIV, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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
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...
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,...

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.