且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在邮箱上固定具有较长数据的texbox的宽度?

更新时间:2023-02-02 15:42:54

由于控件的宽度为%,因此会增加宽度.您需要使用条件表达式来设置宽度.在直到一定长度(例如300px)使用%的位置之后,始终使用300px的固定宽度.

更新:
在这里! [
Since the control width is in %, it increases the width. You need to use conditional expression to set the width. Where till a certain length like 300px use % and after that always a fixed width of 300px.

UPDATE:
Here is it![^]


在标签内使用带有width属性的style参数.这是此页面中的一个示例;

<textarea class="RateComment" rows="5" cols="60" style="width:285px;float:right">

更新:他正在使用文本框(而不是文本区域),宽度为%.将其固定为285将始终具有此宽度.看起来他需要避免基于输入到文本框中的长文本(其宽度以%设置)的方式来扩展页面,以使其在加载时占据所有可用空间. (当texbox中的文本长度驱动宽度而不是页面可用空间时,问题就会出现)
[Update2:我知道,其目的是展示样式元素的可用性,仅此而已.干杯,戴维.]
Use the style parameter with a width property within the tag. Here is an example of one from within this very page;

<textarea class="RateComment" rows="5" cols="60" style="width:285px;float:right">

UPDATE: He is using a textbox(not a textarea) and has % as width. Fixing it to 285 would always have this width. It looks like he needs to avoid widening of the page based on long text entered into the textbox whose width is set in % such that it occupies all the available space while loading. (Issue crops up when length of text inside the texbox drives the width and not the page avaialble space)
[Update2: I know, the intent was to show the availability of the style element, nothing else. Cheers, Davie.]


您可以使用max-width属性
在CSS文件中编写如下内容:
You may use max-width property
Write something like this in your CSS file:
.textbox1
{
  max-width: 300px;
  width: 100% !important
}



其中,textbox1是文本框的ID.
您可以用代码中指定的内容替换100%.

它适用于IE6 +和Mozilla 3.5+浏览器.尚未检查以前的版本.
检查一下,让我知道这是否是您想要的. :thumbsup:

干杯!
安库尔



where, textbox1 is the id of the textbox.
you can replace 100% with whatever you have specified in your code.

It works on IE6+ and Mozilla 3.5+ browsers. Have not checked for previous versions.
Check it out and let me know if this it what you wanted. :thumbsup:

Cheers!
Ankur