Hello,
Is there a way to have a div size itself to the width of its contents?
"width:auto " does not work.
The div contains a UL and I want the div to fit the longest line in the
list. The div is centered.
--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email) 22 39605
Jim Moe <jm************ ***@sohnen-moe.com> wrote: Is there a way to have a div size itself to the width of its contents?
The table-cell, inline-block or inline-table values for the display
property would achieve that, browser support varies.
"width:auto " does not work.
It's not supposed to.
--
Spartanicus
Jim Moe wrote: Hello, Is there a way to have a div size itself to the width of its contents? "width:auto " does not work. The div contains a UL and I want the div to fit the longest line in the list. The div is centered.
read a few postings back, 26 jan http://groups-beta.google.com/group/...ab59977f6cd143
could help you
On Sat, 29 Jan 2005 08:19:27 -0700 Jim Moe wrote: Hello, Is there a way to have a div size itself to the width of its contents? "width:auto " does not work. The div contains a UL and I want the div to fit the longest line in the list. The div is centered.
<div id="one">
<ul>
<li><div id="two"><text> </div></li>
</ul>
</div>
div#one {width:800px;}
div#two {width:100%; text-align:center;}
Division one is the container for your UL.
Division two is set at 100% so it will also be 800px wide.
To indent a little: div#two { margin-left:5%; width:95%;}
To center it div#two {margin-left:5%; margin-right:5% width:90%;}
And of course, div#two {margin:5%; width:90%}
"Richard" <An*******@127. 001> wrote: On Sat, 29 Jan 2005 08:19:27 -0700 Jim Moe wrote:
Is there a way to have a div size itself to the width of its contents?
div#one {width:800px;}
So width: 800px means size itself to the width of the contents? Try to
at least read the question before posting your drivel.
Steve
--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor
Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Steve Pugh <st***@pugh.net > writes: "Richard" <An*******@127. 001> wrote:On Sat, 29 Jan 2005 08:19:27 -0700 Jim Moe wrote:
Is there a way to have a div size itself to the width of its contents?
So width: 800px means size itself to the width of the contents? Try to at least read the question before posting your drivel.
But the question remains, and for me is an interesting one, although
in my case, I'd like the div vertical size to adjust itself to the
amount of a fixed-width text, so that if more text is entered, the
vertical size of the div will increase.
--
Haines Brown
Haines Brown <br****@teufel. hartford-hwp.com> wrote: Steve Pugh <st***@pugh.net > writes:
"Richard" <An*******@127. 001> wrote: >On Sat, 29 Jan 2005 08:19:27 -0700 Jim Moe wrote: > >> Is there a way to have a div size itself to the width of its >> contents? So width: 800px means size itself to the width of the contents? Try to at least read the question before posting your drivel.
But the question remains,
As other people have said there are several ways to create 'shrink to
fit' blocks in CSS. CSS tables are the best way but IE doesn't support
them. Under CSS 2.1 floats also behave like this but not under CSS 2
(and Mac IE follows the CSS 2 rules).
and for me is an interesting one, although in my case, I'd like the div vertical size to adjust itself to the amount of a fixed-width text, so that if more text is entered, the vertical size of the div will increase.
Um, that's the default.
Steve
--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor
Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Haines Brown wrote: Steve Pugh <st***@pugh.net > writes:
"Richard" <An*******@127. 001> wrote:
On Sat, 29 Jan 2005 08:19:27 -0700 Jim Moe wrote:
Is there a way to have a div size itself to the width of its contents?
So width: 800px means size itself to the width of the contents? Try to at least read the question before posting your drivel.
But the question remains, and for me is an interesting one, although in my case, I'd like the div vertical size to adjust itself to the amount of a fixed-width text, so that if more text is entered, the vertical size of the div will increase.
is this a jukebox or what ?! apparently it is. as i just said, the
solution was given just 3 days ago. so for the very hesitating or simply
mentally poor, follow the link, and check post #26 (in google numbering)
Spartanicus wrote: Is there a way to have a div size itself to the width of its contents?
The table-cell, inline-block or inline-table values for the display property would achieve that, browser support varies.
Only by setting both the div and ul to display:table-cell did the
shrink to fit work. Only now the div completely ignores the margin:auto.
:-( And, of course, it looks differently in IE and Mozilla.
Demo URL: <http://www.sohnen-moe.com/test/test.html>
--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Ali Babba wrote: Is there a way to have a div size itself to the width of its contents? "width:auto " does not work. The div contains a UL and I want the div to fit the longest line in the list. The div is centered.
read a few postings back, 26 jan http://groups-beta.google.com/group/...ab59977f6cd143
Yes, I saw that. It does not work for a contained UL.
--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Manlio Perillo |
last post by:
Hi.
This post follows "does python have useless destructors".
I'm not an expert, so I hope what I will write is meaningfull and
clear.
Actually in Python there is no possibility to write code that follows
C++ RAII pattern.
Of course Python objects are not statics like in C++, but in C++ the
auto_ptr class is used for enforcing this pattern for dynamical
|
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 page the way I
want. Does anybody know a solution for this?
First of all, the code I am using:
CSS
-------
body {
|
by: Robert Downes |
last post by:
I'm using the following in a page that I'm testing in Mozilla:
p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto}
But the dashed border is extending to the right-edge of the screen. I
want it to only extend as far as it needs to to nicely contain the
content within (a couple of links).
Is width: auto the wrong property to do this? Is Mozilla rendering the
style wrong?
|
by: Vijay Kumar R. Zanvar |
last post by:
Hello,
Unlike register, auto keyword can not be used to
declare formal parameter(s). Is there any specific
reason for this?
Kind regards,
Vijay Kumar R. Zanvar
|
by: Alpha |
last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key
column and the 2nd is a string. When I add a new row to the dataset to be
updated back to the database. What should I do with the 1st column ? (Below
I have a "1" in place for now). Also, Does the datase.AcceptChanges();
updates the changes to the database? Which command do I use to update the
changes in dataset back to the Access database table? Thanks, Alpha...
| |
by: Samuel |
last post by:
Hi,
I am running into a problem of mixing UICulture = auto and allowing users to
select culture using a dropdown list.
I am detecting a querystring, "setlang", and when found, setting the
CurrentUICulture to what's specified in the querystring. Since I want to
allow UICulture auto detecting, I add UICulture = "auto" to page directive on
each page.
|
by: maya |
last post by:
at work they decided to center divs thus:
body {text-align:center}
#content {width: 612px; text-align:left; margin: 0 auto 0 auto; }
this works fine in IE & FF, EXCEPT in FF it doesn't work if I change
'auto' to 0 for left and right margin values; I have to leave those at
'auto'.. so I would like to know what exactly means 'auto' -- what
value it represents exactly (and does it apply for all elements/values
you might apply 'auto' to?)
|
by: nospam_news |
last post by:
I currently get asked about my usage of "auto". What is it for?
The keyword is clearly superflous here.
In contrast to the huge majority of C/C++ developers I write
definitions very explicitly like that:
int main(char argc, char *argv, char *env) {
try {
auto Exception mainException(1);
mainException.setErrNo(42);
|
by: Piotr K |
last post by:
Hi,
I've encountered a strange problem with Firefox which I don't have any
idea how to resolve. To the point: I've <divelement with a style
"height: auto" and I want to retrieve this value ("auto") in
JavaScript - however instead of getting "auto" value, I get calculated
height. In IE and Opera it simply returns "auto".
Any ideas how to check in Firefox if element height was set to
"auto" ? I'll be grateful for any help.
|
by: JOYCE |
last post by:
Look the subject,that's my problem!
I hope someone can help me, thanks
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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 we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |