
使用CSS创建响应式图库,您可以尝试运行以下代码
<!DOCTYPE html>
<html>
<head>
<style>
div.myGallery {
border: 2px solid orange;
}
div.myGallery:hover {
border: 1px solid blue;
}
div.myGallery img {
width: 100%;
height: auto;
}
div.desc {
padding: 20px;
text-align: center;
}
.responsive {
padding: 0 5px;
float: left;
width: 24.99999%;
}
@media only screen and (max-width: 700px) {
.responsive {
width: 49.99999%;
margin: 5px 0;
}
}
@media only screen and (max-width: 500px) {
.responsive {
width: 100%;
}
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
</style>
</head>
<body>
<div class = "responsive">
<div class = "myGallery">
<a target = "_blank" href="https://www.tutorialspoint.com/assets/videotutorials/courses/3d_animation_online_training/380_course_211_image.jpg">
<img src = "https://www.tutorialspoint.com/assets/videotutorials/courses/3d_animation_online_training/380_course_211_image.jpg" alt="3D Animation Tutorial" width="600" height="500">
</a>
<div class = "mydiv">3D Animation Tutorial></div>
</div>
</div>
<div class = "responsive">
<div class = "myGallery">
<a target = "_blank" href = "https://www.tutorialspoint.com/assets/videotutorials/courses/swift_4_online_training/380_course_210_image.jpg">
<img src = "https://www.tutorialspoint.com/assets/videotutorials/courses/swift_4_online_training/380_course_210_image.jpg" alt="Swift Video Tutorial" width="600" height="500">
</a>
<div class = "mydiv">Swift Video Tutorial</div>
</div>
</div>
<div class = "responsive">
<div class = "myGallery">
<a target = "_blank" href = "https://www.tutorialspoint.com/assets/videotutorials/courses/css_online_training/380_course_215_image.jpg">
<img src = "https://www.tutorialspoint.com/assets/videotutorials/courses/css_online_training/380_course_215_image.jpg" alt="CSS Video Tutorial" width="600" height="500">
</a>
<div class="mydiv">CSS Tutorial</div>
</div>
</div>
<div class = "clearfix"></div>
</body>
</html>以上就是如何使用CSS创建一个响应式图片库的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号