DIV自动调整大小? [英] DIV that auto-sizes?

查看:140
本文介绍了DIV自动调整大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

有没有办法让div尺寸本身达到其内容的宽度?

" width:auto"不工作。

div包含一个UL,我希望div符合

列表中最长的一行。 div居中。


-

jmm dash list(at)sohnen-moe(dot)com

(删除.AXSPAMGN电子邮件)

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)

推荐答案

Jim Moe< jm *************** @ sohnen-moe .COM>写道:
Jim Moe <jm***************@sohnen-moe.com> wrote:
有没有办法让div大小本身的宽度?


显示

属性的table-cell,inline-block或inline-table值将实现这一点,浏览器支持各不相同。

" width:auto"不行。
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.




这不应该。


-

Spartanicus



It''s not supposed to.

--
Spartanicus


Jim Moe写道:
Jim Moe wrote:
你好,
有没有办法让div大小本身达到其内容的宽度?
" width:auto"不起作用。
div包含一个UL,我希望div符合列表中最长的一行。 div居中。
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.



阅读几篇帖子,26 jan
http://groups-beta.google.com/group/...ab59977f6cd143


可以帮到你


read a few postings back, 26 jan
http://groups-beta.google.com/group/...ab59977f6cd143

could help you


On Sat,2005年1月29日08:19:27 -0700 Jim Moe写道:
On Sat, 29 Jan 2005 08:19:27 -0700 Jim Moe wrote:
你好,
有没有办法让div大小本身的宽度为
内容?
" width:auto"不起作用。
div包含一个UL,我希望div符合
列表中最长的一行。 div居中。
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;}

第一部分是UL的容器。

第二部分设置为100%所以它也是800px宽。

缩进一点:div#two {margin-left:5%;宽度:95%;}

居中它div#two {margin-left:5%; margin-right:5%width:90%;}

当然,div#two {margin:5%;宽度:90%}


<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%}


这篇关于DIV自动调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆