gpt4 book ai didi

asp.net - HTML 输入类型提交 : problem with width on IE

转载 作者:技术小花猫 更新时间:2023-10-29 12:04:28 25 4
gpt4 key购买 nike

这很难解释。我希望我能做到。

我最近创建了一个自定义 ASP.net 服务器控件,代表一个工具栏。工具栏包含按钮,因此是 HTML 元素。为了允许我添加图像,我使用 CSS 将其添加到背景中。我在输入元素上应用的 CSS 如下所示:

.button{
padding: 2px 2px 2px 2px;
margin-right: 2px;
border: 1px solid #999;
cursor: pointer;
text-decoration: none;
color: #606060;
}

此外在按钮本身(通过样式标签;这是因为这些类型的按钮是自动呈现的,最终程序员不应更改)我有定义背景图像和一些附加设置的样式

background-attachment:scroll;
background-image:url(images/select.png);
background-position:left center;
background-repeat:no-repeat;
padding-left:15px;

需要 padding-left s.t.文本不会落后于背景图像。所以最后你会得到类似的东西

<input type="submit" style="background-image: url(images/select.png); background-attachment: scroll; background-repeat: no-repeat; background-position: left center; padding-left: 15px;" class="button" id="someId" value="Save" name="someName"/>

在 Firefox 上(像往常一样)一切正常。我的问题是在 IE 上(在 IE 7 上测试过,但我需要与 IE 6+ 兼容)如果你输入一个很长的文本作为按钮文本,按钮会放大,基本上是按钮前后的空间文本随着文本的大小而增加。为了让按钮紧跟在图像之后,我将 text-align:right 行添加到 button 类。

为了更好地说明它...
在 Firefox 上:
alt text http://img268.imageshack.us/img268/311/buttonfirefox.jpg

在 IE 上:
alt text http://img23.imageshack.us/img23/2373/buttonie.jpg

有没有人对我如何解决这个问题有任何建议?

//编辑:
我当然可以做的是在按钮上指定一个固定的宽度,直到它看起来不错。但是,如果可能的话,我想避免这种情况。

最佳答案

这是一个老错误。您需要将 overflow:visible 添加到按钮。这里还有更多:

http://jehiah.cz/archive/button-width-in-ie

这里:

http://www.brandnewbox.co.uk/articles/details/removing_padding_from_ie_buttons/

关于asp.net - HTML 输入类型提交 : problem with width on IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1304889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com