DIV对象的问题,如何保持宽度不变

ops2000 2003-11-06 09:54:50
我的Div中,顺序包含几个Span,现在我想不让Span的宽度增加时Div的宽度一起增加。也就是想让Div的宽度固定?高手赐教,谢谢。急用。。。。
...全文
131 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhfkiller 2003-11-07
  • 打赏
  • 举报
回复
overflow Attribute | overflow Property

--------------------------------------------------------------------------------

Sets or retrieves how to manage the content of the object when the content exceeds the height and/or width of the object.

Syntax

HTML { overflow : sOverflow }
Scripting object.style.overflow [ = sOverflow ]

Possible Values

sOverflow String that specifies or receives one of the following values:visible Default. Content is not clipped, and scroll bars are not added.
scroll Content is clipped, and scroll bars are added even if the content does not exceed the dimensions of the object.
hidden Content that exceeds the dimensions of the object is not shown.
auto Content is clipped, and scrolling is added only when necessary.


The property is read/write. The property has a default value of visible. The cascading style sheets (CSS) attribute is not inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft?Internet Explorer 5. For more information, see Dynamic Properties.

Remarks

The default value for the body element is auto.

Setting the overflow property to hidden on a TEXTAREA object hides its scroll bars.

The default value for the TABLE element is hidden.

As of Microsoft?Internet Explorer 5, the TD element supports the overflow property, with a default value of hidden, if the tableLayout property for the parent TABLE is set to fixed. In a fixed table layout, content that exceeds the dimensions of the cell is clipped if the overflow property is set to either hidden, scroll, or auto. Otherwise, setting the value of the overflow property to visible causes the extra text to overflow into the right neighboring cell (or left if the direction property is set to rtl), continuing until the end of the row.

Setting the overflow property to visible causes the content to clip to the size of the window or frame that contains the object.

This property is available on the Macintosh?platform as of Internet Explorer 5.

Example

The following examples use the overflow attribute and the overflow property to manage content of the object.
This example uses an inline style to automatically adjust itself to overflowing content when the page is loaded.

<DIV ID=oDiv STYLE="width: 200px; height: 200px; overflow: auto;">
:
</DIV>
This example allows the user to dynamically change the overflow property of a DIV object by choosing one of the possible overflow values from a SELECT object.

<SCRIPT>
function SetOverflow(o, sValue)
{
o.style.overflow = sValue;
}
</SCRIPT>

<DIV ID="div1"
STYLE="font-size:18pt;background-color:yellow;height:50px;width:75px">
The quick brown fox jumped over the lazy dog.
</DIV>

<SELECT onchange="SetOverflow(div1,
this.options[this.selectedIndex].text)">
<OPTION SELECTED>visible
<OPTION>scroll
<OPTION>hidden
<OPTION>auto
</SELECT>
007james 2003-11-07
  • 打赏
  • 举报
回复
style="width:200px;overflow:auto"
这样就有滚动条,可以上下拉动
kingdomzhf 2003-11-07
  • 打赏
  • 举报
回复
style="width:200px;overflow:auto"
fason 2003-11-06
  • 打赏
  • 举报
回复
style="width:200px;overflow:auto"
jiuzhangcs21dn 2003-11-06
  • 打赏
  • 举报
回复
width属性用绝对值比如200px
ygghost 2003-11-06
  • 打赏
  • 举报
回复
width 用数值, span 用百分比就可以。

61,128

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧