我试图复制Codrops have here的动画。 (例11,在蓝色背景上)。CSS链接悬停动画
我跟着他们的CSS,但我得到一个奇怪的结果,文本堆栈,并且不能正确显示悬停。你可以看到它发生在this JSFiddle。
仅供参考这里是HTML:
<div id="content" class="small-12 columns the-posts">
<article id="post-162" class="post-162 post type-post status-publish format-standard hentry category-uncategorized row">
<a href="http://localhost/pondera_v3/uncategorized/test-post-6/" rel="bookmark" title="Test Post 6" class="post-title" data-hover="Test Post 6">Test Post 6</a>
</article>
</div>
这里是CSS:
.the-posts article a.post-title {
position: relative;
display: inline-block;
font-weight: bold;
font-family: arial, helvetica;
text-decoration: none;
font-size: 29px;
}
.the-posts article a.post-title::before {
display: inline-block;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
padding: 0;
max-width: 0;
color: #86a63e;
content: attr(data-hover);
-webkit-transition: max-width 0.5s;
-moz-transition: max-width 0.5s;
transition: max-width 0.5s;
}
.the-posts article a.post-title:hover::before, .the-posts article a.post-title:focus::before {
max-width: 100%;
}
我与overflow
播放,但该解决方案是暗指我!有人能指出我要去哪里吗?
您的文本不适合到具有0宽度太行包装的区域。它继续包裹,直到该区域足够宽以便它不包裹。这就是为什么你看到它这样做。 –