순수 js+css 모 바 일 타 오 바 오 사이트 팝 업 상세 상자 기능 구현
3921 단어 js타 오 바 오자세 한 내용 상자
클릭 하여 그림 보기
코드
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no, viewport-fit=cover">
<style>
body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#content{
width: 100%;
height: 10rem;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
background: skyblue;
position: fixed;
left: 0;
right: 0;
bottom: -10rem;
margin: 0 auto;
text-align: center;
line-height: 10rem;
}
@keyframes slideUp {
from{
bottom: -10rem;
}
to{
bottom: 0;
}
}
@keyframes slideDown {
from{
bottom: 0;
}
to{
bottom: -10rem;
}
}
#content img{
width: 1.2rem;
height: 1.2rem;
position: absolute;
right: 10px;
top: 10px;
}
</style>
</head>
<body>
<div id="main">
<a href="#" rel="external nofollow" id="a"> </a>
</div>
<div id="content">
<img src="images/close.png" alt="" id="close">
</div>
</body>
<script>
var show = document.getElementById("a");
var close = document.getElementById("close");
var content = document.getElementById("content");
var main = document.getElementById("main");
document.onclick = function () {
content.style.animation = "slideDown 0.5s 1 normal forwards";
main.style.opacity = "1";
};
close.addEventListener("click",function () {
content.style.animation = "slideDown 0.5s 1 normal forwards";
main.style.opacity = "1";
});
show.addEventListener("click",function (e) {
stopFunc(e);
content.style.animation = "slideUp 0.5s 1 normal forwards";
main.style.opacity = "0.5";
},false);
content.addEventListener("click",function (e) {
stopFunc(e);
},false);
//
function stopFunc(e) {
e.stopPropagation() ? e.stopPropagation() : e.cancelBubble = true;
}
</script>
</html>
총결산위 에서 말 한 것 은 소 편 이 소개 한 순수 js+css 로 모 바 일 타 오 바 오 사이트 의 팝 업 상세 상자 기능 을 실현 합 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 저 에 게 메 시 지 를 남 겨 주세요.소 편 은 신속하게 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
만약 당신 이 본문 이 당신 에 게 도움 이 된다 고 생각한다 면,전 재 를 환영 합 니 다.번 거 로 우 시 겠 지만 출처 를 밝 혀 주 십시오.감사합니다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[2022.04.19] 자바스크립트 this - 생성자 함수와 이벤트리스너에서의 this18일에 this에 대해 공부하면서 적었던 일반적인 함수나 객체에서의 this가 아닌 오늘은 이벤트리스너와 생성자 함수 안에서의 this를 살펴보기로 했다. new 키워드를 붙여 함수를 생성자로 사용할 때 this는...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.