0

出于某种原因,IE7 中的 asp:button 在按钮的左侧添加了一个额外的 100px(或大约......)。这给我的 CSS 样式带来了问题。当然,我可以通过给它精确的像素尺寸来覆盖每个单独的按钮..,但这会很痛苦,因为我的公司构建的应用程序有近 50 个页面,每页大约有 10 个按钮(你可以这样做数学!)。我宁愿让 asp:button 根据文本的大小/宽度按需增长。

任何帮助将非常感激。

ASPX (html)

<div class="sales-order-buttons">
   <asp:Button ID="btnSearchSalesOrders" runat="server" Text="Search Sales Orders" />
   <asp:Button ID="btnViewAssociatedOrders" runat="server" Text="View Associated Orders" />
</div>

CSS

input[type="submit"] {
   background: url("../images/arrow.png") no-repeat left red;
   color: #006aae;
   float: left;
   text-align: left;
   display: block;
   width: auto;
   margin-left: 10px;
   text-indent: 40px; 
}

input[type="submit"]:hover { 
   color: #009CFF; 
   cursor: pointer;
}
4

1 回答 1

0

这是一个已知问题,例如,请参阅删除 IE 按钮中的额外填充,正如您在评论中提到的,解决方案如下所示:

/* this is to fix IE 6 and 7 which create extra right/left padding on buttons
 * IMPORTANT: because IE 6 does not understand the first selector below, you need to apply the class "inputButton" to all input of type="button" in your documents
 * the first declaration is for IE 6 and 7, the second one for IE 6 only, the third one is for all browsers.
 */
button,
input[type="submit"],
input[type="reset"],
input[type="button"],
.inputButton {
  *overflow: visible;
  _width: 0;
  padding: .2em .4em;
}

对于跨浏览器的任何其他有趣的更强大的解决方案是使用 CSS reset/base

试试这个(我能找到的唯一一个直接解决这个特定的 IE 错误):http ://blog.teamtreehouse.com/setting-rather-than-resetting-default-styling,CSS基础:http://tjkdesign .com/ez-css/css/base.css

于 2013-11-06T01:35:42.403 回答