根据内容动态更改Div宽度。 [英] Changing Div width dynamically according to the contents.

查看:59
本文介绍了根据内容动态更改Div宽度。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一种情况需要根据内容自动更改div的宽度。


所以说如果div内容的宽度是400 px,那么div的宽度应该是400px,如果超过600px,宽度不应该超过600,但是应该有一个水平滚动条。


在此先感谢,

Nitin

Hi all,

I have a situation where i need to change the width of a div automatically according to the contents in it.

So say if width of the contents inside the div is 400 px then the width of div should be 400px, and also if it exceeds 600px the width should not increase beyond 600, but a horizontal scrollbar should come.

Thanks in advance,
Nitin

推荐答案

你能展示到目前为止你做了什么吗? ...


亲切的问候
could you show what you have done so far? ...

kind regards





这是javascript代码:

Hi,

This is the javascript code:

展开 | 选择 | Wrap | 行号


1。在第2行什么是宽度?另一个div或应该是widthDiv?


2.长度会给你一个字符的数量......所以你要检查一下吗?但800个字符很多......我想你想设置px的宽度?


亲切的问候
1. in line 2 what is width? another div or should it be widthDiv?

2. length would give you the no of characters ... so you want to check that? but 800 chars are a lot ... i guess you want to set a width in px?

kind regards


这篇关于根据内容动态更改Div宽度。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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