【发布时间】:2016-10-23 23:08:51
【问题描述】:
我有一个简单的表格,其中有 1 个标题和下一列中的下拉箭头图像。我希望始终隐藏该图像,并且仅在鼠标悬停在其上时才显示该图像。我尝试使用 :hover 属性,但它不显示结果 我的代码是这样的。
编辑:
我在 opacity 属性的帮助下实现了上述目标。现在我需要做的是在单击图像时显示一个带有指向页面链接的下拉列表。我是 jquery 的新手,我已经写了大纲函数,但不知道要写什么来显示带有链接的下拉列表。
函数如下:
<script>
$(document).ready(function(){
$("#ddImg").click(function(){
///
});
});
</script>
HTML
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<div class="Table">
<div class="Row" >
<div class="Cell">
<p>Dummy Title</p>
</div>
<div id="divImg" class="Cell" >
<img class="image" id= "ddImg" src="images/MENUDARK.gif" />
</div>
</div>
</div>
CSS
<style type="text/css">
.Table
{
display: table;
}
.Row
{
display: table-row;
}
.Cell
{
display: table-cell;
border-width: thin;
padding-left: 5px;
padding-right: 5px;
}
.image
{
opacity: 0;
}
.cell:hover .image
{
opacity: 1;
}
</style>
【问题讨论】:
-
你不想使用 jQuery 吗?
-
有一个错字。使用
.Cell:hover而不是.cel:hover -
这不能用 css 实现吗?实际上,完整的功能将是当移动悬停时,箭头应该出现,点击箭头时,应该出现一个下拉菜单。我正在考虑为后面的部分添加 jquery