"2019-09-21_簡易圖片HOVER動態效果"
Bootstrap 4.1.1 Snippet by john8895

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="pic" data-description="圖片說明文字"> <img src="https://picsum.photos/600/400/?random=1"> </div>
.pic { position: relative; overflow: hidden; width: 600px; height: 400px; } .pic::after { content: attr(data-description); position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); /* background: linear-gradient(90deg,rgba(255, 255, 255, 0.5),rgba(255, 255, 255, 1) 75%); */ transform: translateY(100%); transition: all 1s ease; color: #fff; font-size: 30px; text-align: center; } .pic:hover::after { transform: translateY(80%); }

Related: See More


Questions / Comments: