CSS:如何解决超链接对齐问题?
我有两个链接:购物者和商店。这两个链接都有自己独立的左浮动和右浮动。 Store 链接应该位于右浮动中,但当向左浮动添加边框样式时,它会从其 div 中弹出。我怎样才能把它放回原位?请查看 http://jsfiddle.net/JuCKU/ 示例。
我完全忘记用新代码更新 jfiddle 。 http://jsfiddle.net/JuCKU/3/
firefox 存在对齐问题,而 google chrome 似乎存在对齐问题正确渲染布局。
I have two links: shopper and store. Both of these links are in there own separate left and right floats. The Store link is supposed to be in a right float, but it snaps out of its div when adding a border style to the left float. How do I get it back into place? Please have a look at http://jsfiddle.net/JuCKU/ for an example.
I completely forgot to update jfiddle with the new code. http://jsfiddle.net/JuCKU/3/
firefox is having the alignment issue while google chrome seems to render the layout correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
将宽度从 50% 降低到 49%。由于有边框,它会占用空间,并且通过为每个 div 指定 50% 的宽度,总数有点太宽,并且第二个 div 会向下弹出一点。或者摆脱边界。
jsFiddle 示例
更改
为:
Drop the width from 50% to 49%. Since you have a border, it takes up space and by giving each div a width of 50%, the total is a bit too wide and the second div pop down a bit. Or get rid of the border.
jsFiddle Example
Change
To:
这是一个舍入问题。这不是四舍五入的问题,50%+50%+1px边框已经超过100%了。使宽度略小于 50% 是一个快速解决方案。更改此:
为此:
http://jsfiddle.net/JuCKU/4/
It's a rounding issue. It's not a rounding issue, 50% + 50% + 1px border is more than 100%. Making the width slightly less than 50% is a quick fix.Change this:
for this:
http://jsfiddle.net/JuCKU/4/
简单地在您的
shopper div
中给出margin-right:-1px
检查这个 http://jsfiddle.net/JuCKU/6/
OR
您可以使用 css3
box-sizing
属性来实现此目的,但它直到为止都有效IE8
&多于。检查这个http://jsfiddle.net/JuCKU/7/
simple give
margin-right:-1px
in yourshopper div
Check this http://jsfiddle.net/JuCKU/6/
OR
you can use css3
box-sizing
property for this but it's work tillIE8
& above.Check this http://jsfiddle.net/JuCKU/7/
添加边框会将框的整体大小增加到 50%+1px,因此它们的总宽度大于 100%,并且必须给予一些东西。
您可以使用 CSS3 属性
box-sizing:border-box
将边框合并到总宽度的 50% 中,或者更具体地说,在 Firefox 中为 -moz-box-sizing,在 Firefox 中为 -webkit-box-sizing Chrome/Safari 以及 Opera 中简单的框大小调整。不幸的是 IE 还不支持这一点。因此,将其添加到您的代码中。
更多信息 - http://www.css3.info/preview/box-sizing/
正如其他人所提到的,跨所有浏览器的防弹解决方案是将框的宽度减少到略小于 50%。
Adding the border increases the overall size of the boxes to 50%+1px, so together their combined width is greater than 100% and something's gotta give.
You can use the CSS3 property
box-sizing:border-box
to incorporate the border into the total 50% width, or more specifically -moz-box-sizing in Firefox, -webkit-box-sizing in Chrome/Safari and simply box-sizing in Opera. Unfortunately IE doesn't yet support this.So add this to your code.
More info - http://www.css3.info/preview/box-sizing/
As mentioned by others the bulletproof solution across all browsers is to reduce the width of your boxes to fractionally less than 50%.
给 div 一些宽度,
请参阅 http://jsfiddle.net/JuCKU/1/
Give the divs some widths
see http://jsfiddle.net/JuCKU/1/