473,396 Members | 1,989 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,396 software developers and data experts.

div shrink to fit its content

hi,
i have the following html. i don't want to set size for div and i want
to have it get the size (especially shrink) of its content but it
resizes to the width of the page. i tried the span instead of div
element but it leaves some horizontal space after it. so i'd like to
know what's the best way compatible with common browsers(if possible
with styles) to get the element shrink to its content while the next
element coming after it positioned and displayed expectedly.
thanks

<div style="background-color:#E0053A;">
<span>A title</span>
<select>
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select>
</div>

Aug 17 '06 #1
1 19624
spolsky wrote:
hi,
i have the following html. i don't want to set size for div and i want
to have it get the size (especially shrink) of its content but it
resizes to the width of the page.
div is a block element, which means, it always uses the whole line, or the
whole available horizontal space.
i tried the span instead of div
element but it leaves some horizontal space after it.
span is an inline element, which means, it only uses the space of its
content.
http://www.w3.org/TR/html401/struct/....html#edef-DIV

so i'd like to
know what's the best way compatible with common browsers(if possible
with styles) to get the element shrink to its content while the next
element coming after it positioned and displayed expectedly.
This depends on the kind of content you are talking about: text, images,
applets, objects.
Maybe you could post an URL to your page, so we can see, as a whole, what
you're trying to achieve.
BTW:
Your missing a form element here. If you expect your stylesheet definitions
to work as expected, you have to write correct markup.
<div style="background-color:#E0053A;">
<span>A title</span>
<select>
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select>
</div>
Maybe this works for you:
<h1>A title</h1>
<form style="background-color:#e0053a;" action="somewhere">
<label for="choice">Choose your poison</label>
<select id="choice">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</form>
Sven
Aug 17 '06 #2

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

Similar topics

1
by: R Camarda | last post by:
Help, I have a database that has a data file of 2GB and a log file of 31GB. In enterprise manager, when I choose shrink it says there is 30GB of unused space. When I shrink the database, it does...
5
by: BashiraInTrouble | last post by:
Hi Friends, I have tried almost everything but I cant seem to shrink the transaction log. Executing DBCC SQLPERF(LOGSPACE) gives me this info: Database Log Size (MB) Log Space Used (%) ...
4
by: Tommy.Vincent | last post by:
hi all, This will be a easy question for all out here. I have a database of 28GB. having 3 Data Files 22 GB, 3.58 Gb and 2.70 GB respectively. and a Transaction Log file of 156 mb. When i...
4
by: Bob Richardson | last post by:
Is it possible for an image to SHRINK (both height and width, keeping same h/w ratio) when the browser's width is reduced? It's easy to have both h & w increase, as needed, to fill up 100% of the...
4
by: Gary Bond | last post by:
Hi All, Can anybody point me to some 'how-to' documentation, tutorials, etc as to how to write a shrink/protect wrapper for .Net exes/dlls, (like the Shrinkwrap product for instance). I have...
12
by: hallpa1 | last post by:
Hi all, I posted messages before about trying to purge many records (about 35%) of a 200Gig database. The responses gave me a lot to think about, especially regarding the indexes. But due to the...
4
by: ge5talt | last post by:
Longtime reader, 1st time poster :) I am in the process of overhauling a website and replacing an old table-based quirksmode layout with a standards-mode tableless one. I am currently working on...
3
by: Galka | last post by:
Hello Environment: Windows XP, MS Access 2003. I'd like - in a report - to save space , when there is no company data. When there is, I print out company name, address, telephone number and...
6
by: Major Drake | last post by:
Windows 2003 64 bit sp2 + SQL Server std 32 bit sp2 compability mode 90, recovery model simple. I have about 40 Gb database where is about 98% free space (I deleted data from tables). dbcc...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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...
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.