锚标签 - 等高,仍然可以通过 CSS 点击?
我在 jsfiddle 上有一些代码: http://jsfiddle.net/tYrCe/1/ 如果您愿意,请编辑它!
我有 3 个带有锚标签的按钮。我希望它们的高度相等。
要求
- 高度相等
- 独立于内容(最小高度,不行)
- 整个链接应该仍然可点击(javascript onclick,不行)
I have a little code on jsfiddle:
http://jsfiddle.net/tYrCe/1/
Edit it if you like!
I have 3 buttons with anchor tags. I would like them to be equal in height.
Requirements
- Equal in height
- Independent of content (min-height, not ok)
- The whole link should still be clickable (javascript onclick, not ok)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
display: table-cell
。table-layout:fixed
在单元格之间均匀分配可用宽度。确保您可以接受浏览器支持:http://caniuse.com/css-table
(我认为不支持 IE6/7 就可以了,因为您使用的是
outline
)参见: http://jsfiddle.net/thirtydot/Ab6bg/
You can use
display: table-cell
.table-layout: fixed
evenly distributes the available width between the cells.Make sure the browser support is acceptable to you: http://caniuse.com/css-table
(I assume no IE6/7 support is fine because you're using
outline
)See: http://jsfiddle.net/thirtydot/Ab6bg/
经典的纯 CSS 方法是使用较大的底部填充,然后反转边距,如 中所述这篇“位置就是一切”文章。
这是您相应修改的小提琴。
HTML:
CSS:
The classic, pure CSS, way is to use a large bottom padding and then reverse margin as discussed in this "Position is Everything" article.
Here is your fiddle modified accordingly.
HTML:
CSS: