1
画像の上を浮遊するときに画像上で見えるようになるテキストの変化は、画像とテキストを1つのdivに入れる前に滑らかでした。私は画像の上にテキストを配置できるように、画像とテキストを1つのdivに入れました。移行は今や不安定です - これをどのように修正できるかご存知ですか?ありがとうございました。画像を置き換えるときにテキストがちらつく
$(document).ready(function() {
$("img").hover(function() {
$("img").stop().animate({
"opacity": "0"
}, "slow");
$(".text").css("visibility", "visible");
},
function() {
$("img").stop().animate({
"opacity": "1"
}, "slow");
$(".text").css("visibility", "hidden");
});
});
#image {
display: block;
margin: 0 auto;
height: 35%;
width: 35%;
padding-left: 5%;
overflow: hidden;
}
#imageblock {
position: relative;
overflow: hidden;
}
.text {
color: #000000;
text-align: center;
font-family: "Raleway";
font-size: 90%;
visibility: hidden;
position: absolute;
padding: 3%;
width: 100%;
bottom: 30px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="imageblock">
<img id="image" src="http://2016.igem.org/wiki/images/8/81/T--Sydney_Australia--Peek_Banner.png">
<div class="text">
<h5>NBB4 ethylene</h5>
</div>
</div>
コードのスクリーンショットではなく、スニペットまたはJSFiddleを作成できますか? – Lucian
少なくともHTMLを質問に貼り付けてコピーすることができます。 – Arg0n
CSSトランジションの使用を開始します。 –