【发布时间】:2015-04-05 23:29:13
【问题描述】:
我目前正在尝试这样做,当您将鼠标悬停在一个元素上时,三个 div 将覆盖该元素这是我想要它做的一个示例。
左侧不悬停,右侧悬停。
我意识到这在 css 中是不可能的,但我相信这可以在 jQuery 中完成,首先我尝试添加类,但这不会按照我想要的方式工作,我完全迷失了它涉及到 jQuery。
$(function() {
$( document ).ready(function() {
$('.ikon').hover(function() {
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
目前css谁处理图片:
/**PORTFOLIO-ALBUM***/
/*==================*/
#portfolio #album {
width: 955px;
min-width: 360p;
height: 780px;
overflow: auto;
position: absolute;
top: 100px;
left: 250px;
}
#portfolio .ikon {
width: 280px;
height: 175px;
overflow: hidden;
float: left;
margin-left: 20px;
margin-bottom: 20px;
position: relative;
}
#portfolio .ikon img {
max-width: 350px;
min-height: 100%;
position: absolute;
left: -35px;
top: -10px;
}
图片是如何输出的:
$query = "SELECT photo_id, photo_filename FROM photos WHERE fk_photo_category_id = '$album_category' ";
$result = $mysqli->query($query);
if ($result->num_rows > 0) {
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
$photo_name = $row['photo_filename'];
$photo_id = $row['photo_id'];
echo "<div class='ikon'><a href='index.php?page=portfolio.php&album=$album_id&photo=$photo_id'><img src='img/photos/$photo_name' alt='' /></a></div>";
}
【问题讨论】:
-
你希望它的工作方式是什么?
-
@erkaner 我一悬停,第二张图片顶部的效果就会出现。我还更新了图片,以减少混乱。
-
就我个人而言,我会使用 jQuery,但也可以只使用 HTML/CSS。
:hover伪类用途广泛。
标签: jquery hover jquery-hover