【发布时间】:2015-10-03 22:53:13
【问题描述】:
有很多这样的词: test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 ...
每个单词都与多个例句相关联。我希望它们在光标悬停在单词上之前被隐藏。这是我的代码。
演示:https://jsfiddle.net/kyubyong/umxf19vo/
HTML:
<a><b>test1</b></a>
<div class="divs">
<li>This is the first example</li>
<li>This is the second example</li>
<li>This is the third example</li>
</div>
<a><b>test2</b></a>
<div class="divs">
<li>This is the first example</li>
<li>This is the second example</li>
<li>This is the third example</li>
</div>
CSS
a:hover
{
background-color: lightgray;
}
.divs
{
display: none;
}
a:hover + .divs
{
display: block;
position: absolute;
background-color: lightgray;
width: 100%;
padding: 5px;
}
问题是当原行不止一个时,例句块覆盖了底行的单词。我希望他们下去,这样例句就不会涵盖他们。
【问题讨论】:
-
你能解决这个问题吗?(当它不工作时)
-
@RinoRaj 已经有小提琴不工作了。
-
您是否意识到,您想要实现的目标实际上是要创建一个非常糟糕的跳跃式 UI。将鼠标悬停在一个项目上,手风琴打开(显示)向下推同级项目......现在如果你想用鼠标到达较低项目 BAM!一团糟。
-
您的意思是如果 test9 和 test10 换行到下一行,您不希望它们被覆盖?我相信这需要一些 JS。
-
这可以使用 jQuery 来完成。查看更新的演示:Demo
标签: javascript html css