473,480 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

div as small as possible

usually i don't care... but if I use script.aculo.us, there is a
Draggable class to use so that I can drag the div around...

so the div turns out to enclose the max width across the screen. it
can make the Draggable a bit weird if I just want a small area to be
included -- one small element can overlap the other ones easily as the
div is "max width"

so I wonder, can I set the div to be "as small as possible", just to
contain the elements inside but not more.

I tried using width: auto and it wouldn't work. setting width to a
small number like 30px seems to work alright, except it maybe better
to let it just enclosed the elements inside but not more.

Oct 29 '07 #1
3 8861
On 2007-10-29, Summercool <Su************@gmail.comwrote:
usually i don't care... but if I use script.aculo.us, there is a
Draggable class to use so that I can drag the div around...

so the div turns out to enclose the max width across the screen. it
can make the Draggable a bit weird if I just want a small area to be
included -- one small element can overlap the other ones easily as the
div is "max width"

so I wonder, can I set the div to be "as small as possible", just to
contain the elements inside but not more.

I tried using width: auto and it wouldn't work. setting width to a
small number like 30px seems to work alright, except it maybe better
to let it just enclosed the elements inside but not more.
You need an element whose auto width is shrink-to-fit. That's anything
with position: absolute or fixed, or that's floated, or display:
table-cell or table.

Not completely sure exactly what you're doing, but position: absolute
with width: auto (the default) sounds like the most appropriate.
Oct 29 '07 #2
On Oct 29, 3:47 am, Ben C <spams...@spam.eggswrote:
You need an element whose auto width is shrink-to-fit. That's anything
with position: absolute or fixed, or that's floated, or display:
table-cell or table.

Not completely sure exactly what you're doing, but position: absolute
with width: auto (the default) sounds like the most appropriate.
i tried both display: table and float: left and they both worked!
is there a rule? that when is it "max width" and when is it "just
shrink to fit"?

the display: table feels a bit weird as it is not really a table.

besides, the height seems just a little bit taller than it is...

http://www.0011.com/test_drag/index3.php

on IE 7.0, it is exactly the right size... but on Firefox 2.0.0.8 and
Safari 3 Win Beta, it is shown as a bit taller than it has to be. (as
you see the background color coming out at the bottom).


Oct 29 '07 #3
On 2007-10-29, Summercool <Su************@gmail.comwrote:
On Oct 29, 3:47 am, Ben C <spams...@spam.eggswrote:
>You need an element whose auto width is shrink-to-fit. That's anything
with position: absolute or fixed, or that's floated, or display:
table-cell or table.

Not completely sure exactly what you're doing, but position: absolute
with width: auto (the default) sounds like the most appropriate.

i tried both display: table and float: left and they both worked!
is there a rule?
There is no shortage of rules. Search the CSS 2.1 specification for the
string "shrink-to-fit".
that when is it "max width" and when is it "just
shrink to fit"?
In the cases I gave (I think I got them all). I prefer to call them
"greedy auto width" and "shrink-to-fit auto width".
the display: table feels a bit weird as it is not really a table.

besides, the height seems just a little bit taller than it is...
I'm sure the height is always exactly as tall as it is [1].
http://www.0011.com/test_drag/index3.php
on IE 7.0, it is exactly the right size...
Odd, I'm sure I heard display: table doesn't work in IE. Perhaps it does
in IE7.
but on Firefox 2.0.0.8 and Safari 3 Win Beta, it is shown as a bit
taller than it has to be. (as you see the background color coming out
at the bottom).
That's descender space below the inline img. It should be there. Use
strict mode:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">

and set those imgs to display: block.

[1] There is a story about Bertrand Russell and his friend on a boat.
Friend says, "I thought your boat was bigger than it is.". Russell
replies testily, "No, my boat is not bigger than it is".
Oct 29 '07 #4

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

Similar topics

10
1748
by: AlexS | last post by:
Hi, I wonder if anybody can comment if what I see is normal in FW 1.1 and how to avoid this. I have .Net assembly, which creates literally thousands of temporary strings and other objects...
4
2555
by: Manny | last post by:
Hi, I would like to display a small html file in a layer (div) when the mouse goes over a link (<a href="small.html" onMouseOver="showPop(small.html)"). Which tag should I use in the layer :...
24
1933
by: Arne Demmers | last post by:
Hi, As a project of mine I have to do some C programming, which in fact isn't the real problem. The problem it self is that I will have to write some code that is as minimal as possible, and as...
13
3080
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
4
2034
by: =?Utf-8?B?VzFsZDBuZTc0?= | last post by:
When one architects a new project one of the first steps in the decision is to decide on the layers. (In my opinion anyway) One architecture that I have used before is to go solid OO and create...
169
8943
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
4
3646
by: ATS16805 | last post by:
Hi. I wonder if it's possible to "force" a browser to "switch to SSR mode" for any given document. Specifically, I'm looking for a solution, not to a User Agent issue (i think), but a coding idea;...
0
1644
by: mrchatgroup | last post by:
news from http://www.mrchat.net/myblog/myblog/small-accidents-mean-big-trouble-for-supercollider.html Small Accidents Mean Big Trouble for Supercollider Image Scientists expect startup...
0
7048
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
7091
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...
1
6743
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
6966
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
5344
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,...
1
4787
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
2999
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...
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
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.