Internet Explorer 生成额外的 br
我遇到一个问题,Internet Explorer 正在生成一个不在我的源代码中的附加 br
元素。附加的 br
会影响页面的布局,并且在使用开发人员工具时可见。我尝试删除周围元素之间的所有硬回车,但附加的 br
仍然存在。 Firefox 和 Chrome 没有这个问题。我能做些什么来解决这个问题?
而不是
First line. Second line.
我得到
First line Second line.
代码示例
<asp:ImageButton ID="RemoveItem" AlternateText="Remove Item"
ImageUrl="~/img/buttons/remove.png" runat="server" CssClass="remove"
CommandName="Remove" OnCommand="RemoveCartItem_Command" />
<br runat="server" id="TotalBreak" />
<span class="fieldlabel">Total</span>
以及我最终得到的结果(...用于显示我已经缩短了渲染的 id)
<input id="...RemoveItem" class="remove" alt="Remove Item"
src="img/buttons/remove.png" type=image name="...RemoveItem" />
<br id="...TotalBreak"/>
<br/>
<span class="fieldlabel">Total</span>
I have an issue where Internet Explorer is generating an additional br
element that is not in my source. The additional br
effects the page's layout and is visible when using the developer tool. I've tried removing all hard returns between the surrounding elements but the additional br
persists. Firefox and Chrome do not have this issue. Ideas on what I can do to fix the issue?
Instead of
First line. Second line.
I get
First line Second line.
Code Example
<asp:ImageButton ID="RemoveItem" AlternateText="Remove Item"
ImageUrl="~/img/buttons/remove.png" runat="server" CssClass="remove"
CommandName="Remove" OnCommand="RemoveCartItem_Command" />
<br runat="server" id="TotalBreak" />
<span class="fieldlabel">Total</span>
And what I end up with (... used to show I've shortened rendered ids)
<input id="...RemoveItem" class="remove" alt="Remove Item"
src="img/buttons/remove.png" type=image name="...RemoveItem" />
<br id="...TotalBreak"/>
<br/>
<span class="fieldlabel">Total</span>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是由于
line-height
或浏览器默认样式表中的其他默认值造成的。就像buyckbova所说,你应该使用CSS重置。试试 Eric Meyer 的,它很彻底: http://meyerweb.com/eric/tools/css/重置/It's probably due to
line-height
or another default in the browser's default style sheet. Like buyckbova said, you should use a CSS reset. Try Eric Meyer's, it's thorough: http://meyerweb.com/eric/tools/css/reset/尝试重置 CSS 以删除浏览器默认设置。
Try a CSS reset to remove browser defaults.