通过css设置标签的大小属性? [英] Set tag's size attribute through css?

查看:173
本文介绍了通过css设置标签的大小属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,您可以这样做:

<select size="3">
    <option>blah</option>
    <option>blah</option>
    <option>blah</option>
</select>

它会呈现为一个选择框,其中所有三个选项都是可见的
我正在寻找一种方法来从css设置此大小属性。

And it would render as a selectionbox where all three options are visible (without dropping down)
I'm looking for a way to set this size attribute from css.

推荐答案

没有选项设置大小,但如果你设置的大小一些浏览器将允许你通过CSS设置宽度/高度属性任何你想要的。

There ins't an option for setting the size, but if you do set the size some browsers will let you set the width/height properties to whatever you want via CSS.

Some = Firefox,Chrome ,Safari,Opera。

Some = Firefox, Chrome, Safari, Opera.

在IE中没有太多的工作,但是(没有意外)

Not much works in IE though (no surprise)

你想要的,在IE中使用CSS表达式,检查是否设置了size属性,如果是,运行JS到(重新)设置为你想要的大小...例如

You could though, if you wanted, use CSS expressions in IE, to check if the size attribute is set, and if so, run JS to (re)set it to the size you want... e.g.

size = options.length;

这篇关于通过css设置标签的大小属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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