【发布时间】:2019-02-17 16:36:06
【问题描述】:
我是一名用户体验专家。我让东西看起来漂亮而实用。今晚我的人生短板似乎是在编码,如果我发错了,我深表歉意。
我的问题是,当用户将鼠标悬停在图片(background-image)#sthero-client-image 上时,它应该隐藏#sthero-whitebar-copy 并显示#sthero-whitebar-heros-copy。我正在尝试通过 JavaScript 来做这件事,因为我有其中三个要做,而且进展不顺利。
这里是代码:我又一直在玩它,所以它有点时髦..
$(document).ready(function() {
$("#sthero-client-image").hover(function() {
$("#sthero-whitebar-copy").css("display": "none");
$("#sthero-whitebar-client-copy").css("display": "block");
}, function() {
// on mouseout, reset the background colour
$("#sthero-whitebar-copy").css("display": "block");
$("#sthero-whitebar-client-copy").css("display": "none");
});
});
.sthero-wrapper{
height:420px;
width:1220px;
}
.sthero-whitebar-hide{
display: block;
}
.sthero-whitebar{
width:1220px;
height:100px;
text-align:center;
background:rgba(255,255,255,.7);
position: absolute;
top: 30%;
left:1.5%;
transform: translate(-.75%, -30%);
}
.sthero-whitebar-text-contianer{
position: absolute;
top: 50%;
left:50%;
transform: translate(-50%, -50%);
}
#sthero-whitebar-copy{
font-family:'exo 2';
font-size:42px;
color:#000;
display:block;
}
#sthero-whitebar-client-copy{
font-family:'exo 2';
font-size:42px;
color:#000;
display:none;
}
#sthero-whitebar-heros-copy{
font-family:'exo 2';
font-size:42px;
color:#000;
display:none;
}
#sthero-whitebar-family-copy{
font-family:'exo 2';
font-size:42px;
color:#000;
display:none;
}
#sthero-client-image{
background-image: url(clients- 100.jpg);
background-repeat: no- repeat;
height:420px;
width:362px;
float:left;
}
#sthero-client-image:hover{
background-image: url(50client-1 00.jpg);
background-repeat: no- repeat;
height:420px;
width:362px;
float:left;
}
.sthero-heros-image{
background-image: url(heros- 100.jpg);
background-repeat: no- repeat;
height:420px;
width:450px;
float:left;
}
.sthero-heros-image:hover{
background-image: url(50hero- 100.jpg);
background-repeat: no- repeat;
height:420px;
width:450px;
float:left;
}
.sthero-family-image{
background-image: url(family- 100.jpg);
background-repeat: no- repeat;
height:420px;
width:408px;
float:left;
}
.sthero-family-image:hover{
background-image: url(50family- 100.jpg);
background-repeat: no- repeat;
height:420px;
width:408px;
float:left;
}
.sthero-clear{
clear:both;
}
<div class="sthero-wrapper">
<div class ="sthero-whitebar"><div class ="sthero-whitebar-text-contianer">
<div id="sthero-whitebar-copy">
Who do you want to ship to ?
</div>
<div id="sthero-whitebar-client-copy"> CLIENT'S</div>
<div id="sthero-whitebar-heros-copy">HERO'S</div>
<div id="sthero-whitebar-family-copy">FAMILY</div>
</div></div>
<div id="sthero-client-image"></div>
<div class="sthero-heros-image"></div>
<div class="sthero-family-image"></div>
<div class ="sthero-clear"></div>
</div>
【问题讨论】:
-
能否请您提供您正在使用的 HTML?
标签: javascript html css hover user-experience