更改位置为“绝对”悬停时(显示完整措辞)
有一组按行排列的链接。
CSS:
.table div {
float:left;
margin-right:5px;
width:150px; /*width needs to be fixed, since we're limited in space*/
white-space:nowrap;
overflow:hidden
}
a.trick,a.trick:link,a.trick:active,a.trick:visited {position:static}
a.trick:hover{position:absolute}
HTML:
<div class=table>
<div>Text here</div>
<div><a class=trick href="#">Text here may be too long to fit</a></div>
<div>Next column</div>
<div>of my table made of divs</div>
</div>
在 Opera 和 Firefox 中运行良好(悬停时重叠下一个“列”,显示完整内容)。
在 Chrome 中(Safari 也可能)根本不会对 :hover 做出反应。
任何人都知道绕过的方法,最好没有 JS/jQ (纯 CSS)? 提前致谢!
Have a set of links in rows.
CSS:
.table div {
float:left;
margin-right:5px;
width:150px; /*width needs to be fixed, since we're limited in space*/
white-space:nowrap;
overflow:hidden
}
a.trick,a.trick:link,a.trick:active,a.trick:visited {position:static}
a.trick:hover{position:absolute}
HTML:
<div class=table>
<div>Text here</div>
<div><a class=trick href="#">Text here may be too long to fit</a></div>
<div>Next column</div>
<div>of my table made of divs</div>
</div>
Works great in Opera and Firefox (on hover overlaps the next "column", displaying full content).
In Chrome (Safari too, likely) does not react to :hover at all.
Anyone knows a way to bypass, preferably without JS/jQ (pure CSS)?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您能够在服务器上确定链接上允许的最大字符数,您可以使用以下策略:
CSS:
HTML:
If you are able to determine on the server the maximum number of characters to allow on the link you could use the following strategy:
CSS:
HTML:
我不明白为什么你希望它接收绝对位置,这与单词的大小有什么关系,等等。
好吧,我看到你的例子在这里工作 http://jsfiddle.net/R6dkJ/ 在 Firefox 上。
要“正确”地执行此操作,您可以这样做:
这可以达到相同的效果。
absolute
属性用于定位元素本身。当然,您可以将它用于像这样的黑客以获得一些想要的效果 - 但当您这样做时,您肯定会遇到浏览器之间的不兼容问题。I don't understand why you want it to receive position absolute, what that has got to do with the size of the words, etc..
Ok, I saw your example working here http://jsfiddle.net/R6dkJ/ on firefox.
To do this exact thing "correctly", you would for an example do this:
This achieves the same effect.
The
absolute
property is used for positioning the element itself. Of course you can use it for hacks like this to get some desired effect - but you will most definitely run into incompatibilities between browsers when you do so.使用一些 jQuery 解决了这个问题,即:
出于某种原因,Chrome/Safari 想要额外确认该位置实际上应该成为绝对:)。
现在可以在任何地方使用(包括 IE)。
感谢您的参与,并享受这个美好的“黑客”:)。
Solved with a bit of jQuery, which is:
For some reason Chrome/Safari want additional affirmation that position actually should become absolute :).
Now works everywhere (including IEs).
Thanks for participation, and enjoy this nice "hack" :).