图片的放大模态框
来源:互联网 发布:小米网络放大器怎么用 编辑:程序博客网 时间:2024/05/21 23:37
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style>
#myImg {
margin:30px 30%;
border-radius: 10px;
cursor: pointer;
transition: 0.3s;
}
#myImg:hover{opacity:0.7;}
.modal {
display: none;
width: 100%;
height: 100%;
padding-top: 100px;
left: 0;
top: 0;
position:fixed;
overflow: auto;
z-index: 1;
background-color: rgba(0,0,0,0.8);
}
.modal-content {
max-width: 700px;
width: 80%;
margin: auto;
display: block;
}
#caption {
max-width: 700px;
width: 80%;
margin: auto;
height: 150px;
padding-top: 20px;
text-align: center;
display: block;
color: #ff0000;
}
@keyframes ni{
0%{transform:scale(0.1)}
100%{transform:scale(1)}
}
.modal-content, #caption {
-webkit-animation-name: zoom;
-webkit-animation-duration: 2s;
animation-name: ni;
animation-duration: 2s;
}
.close {
position: absolute;
top: 20px;
right: 20px;
font-size: 40px;
color: #ff0000;
cursor: pointer;
}
</style>
<meta charset="utf-8" />
</head>
<body>
<img src="tu1.jpg" width="400" height="400" alt="人生的意义不在于我不说" id="myImg" />
<div id="myModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="img01">
<div id="caption"></div>
</div>
<script>
var modal = document.getElementById('myModal');
// 获取图片模态框,alt 属性作为图片弹出中文本描述
var img = document.getElementById('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function () {
modal.style.display = "block";
modalImg.src = this.src;
modalImg.alt = this.alt;
captionText.innerHTML = this.alt;
}
var span = document.getElementsByClassName("close")[0];
// 点击 <span> 元素上的 (x), 关闭模态框
span.onclick = function () {
modal.style.display = "none";
}
</script>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style>
#myImg {
margin:30px 30%;
border-radius: 10px;
cursor: pointer;
transition: 0.3s;
}
#myImg:hover{opacity:0.7;}
.modal {
display: none;
width: 100%;
height: 100%;
padding-top: 100px;
left: 0;
top: 0;
position:fixed;
overflow: auto;
z-index: 1;
background-color: rgba(0,0,0,0.8);
}
.modal-content {
max-width: 700px;
width: 80%;
margin: auto;
display: block;
}
#caption {
max-width: 700px;
width: 80%;
margin: auto;
height: 150px;
padding-top: 20px;
text-align: center;
display: block;
color: #ff0000;
}
@keyframes ni{
0%{transform:scale(0.1)}
100%{transform:scale(1)}
}
.modal-content, #caption {
-webkit-animation-name: zoom;
-webkit-animation-duration: 2s;
animation-name: ni;
animation-duration: 2s;
}
.close {
position: absolute;
top: 20px;
right: 20px;
font-size: 40px;
color: #ff0000;
cursor: pointer;
}
</style>
<meta charset="utf-8" />
</head>
<body>
<img src="tu1.jpg" width="400" height="400" alt="人生的意义不在于我不说" id="myImg" />
<div id="myModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="img01">
<div id="caption"></div>
</div>
<script>
var modal = document.getElementById('myModal');
// 获取图片模态框,alt 属性作为图片弹出中文本描述
var img = document.getElementById('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function () {
modal.style.display = "block";
modalImg.src = this.src;
modalImg.alt = this.alt;
captionText.innerHTML = this.alt;
}
var span = document.getElementsByClassName("close")[0];
// 点击 <span> 元素上的 (x), 关闭模态框
span.onclick = function () {
modal.style.display = "none";
}
</script>
</body>
</html>
阅读全文
0 0
- 图片的放大模态框
- 图片的放大ZommJS
- 图片的放大缩小
- 图片的放大缩小
- 图片的自动放大
- 图片的放大缩小
- layer图片的放大
- js放大图片的特效
- 仿淘宝的放大图片
- 图片的放大与缩小
- Android中图片的放大。
- 图片的放大和缩小
- 下拉放大图片的效果
- 图片的放大和缩小
- 图片的放大与缩小
- 图片的放大或缩小
- SVG格式图片的放大
- AndroidStudio中图片的放大
- Android三方分享总结
- codeforces 455E Function && 51nod 1488 帕斯卡小三角
- 深入分析Spring 与 Spring MVC容器
- 机器学习算法线上部署方法
- 求链表的倒数第m个元素
- 图片的放大模态框
- 数组、List和ArrayList的区别
- IOS和android手机测试注意点
- Android常用开源项目(二十七)
- C#多线程
- Thinkphp内置的一个中英文字符串截取函数,显示省略号
- 什么时候使用CountDownLatch
- Node.js加载第三方SDK作为node_modules模块
- HashMap和Hashtable的区别