0
キャプションを写真に追加しようとしています。キャプションが表示され、クリックされると(そして別のクリックまで表示されたままにしておきたい)、キャプションが写真の下に常に表示されるようにします。これは可能ですか?私は2つのアクションを別々に行うことができますが、一緒にはできません。ホバー上の写真にキャプションオーバーレイを追加してクリックするにはどうすればよいですか?
私の他の選択肢は、通常の画面でホバーを使用し、モバイルでクリックオプションを使用することです。ここで
は、私が働いているものです:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("img").click(function(){
$("p").toggle();
});
});
</script>
<style>
.container {
position: relative;
width: 400px;
}
.image {
opacity: 1;
display: block;
width: 100%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}
.middle {
transition: 0.5s ease;
opacity: 0;
width:100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%)
}
p {
background-color: none;
font-family:sans-serif;
font-style:italic;
color: black;
font-size: 14px;
line-height:24px;
padding: 12px 12px;
}
.container:hover .image {
opacity: 0.2;
}
.container:hover .middle {
opacity: 1;
}
.text p{
background-color: none;
font-family:sans-serif;
font-style:italic;
color: black;
font-size: 14px;
line-height:24px;
text-align: center;
padding: 12px 12px;
}
</style>
</head>
<body>
<div class="container">
<img src="https://static1.squarespace.com/static/511526cde4b067782b69109c/517aa359e4b0ab81ac8d931c/517aa396e4b041a7f26623d5/1366991956677/05-corporate-headshot-photo-WBEZ+-+Chicago+Public+Media_Edwards_Steve_Programming_120328_1210.psd.JPG-1500px.JPG" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<p class="text">Rodney Erickson is a content marketing professional at HubSpot, an inbound marketing and sales platform that helps companies attract visitors, convert leads, and close customers. Previously, Rodney worked as a marketing manager for a tech software startup. He graduated with honors from Columbia University with a dual degree in Business Administration and Creative Writing."</p>
</div>
<p>RODNEY ERICKSON, M.B.A.<br>Content Marketing</p>
</div>
</body>
</html>
感謝:)