순수 js+css 모 바 일 타 오 바 오 사이트 팝 업 상세 상자 기능 구현


클릭 하여 그림 보기
코드

<!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 로 모 바 일 타 오 바 오 사이트 의 팝 업 상세 상자 기능 을 실현 합 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 저 에 게 메 시 지 를 남 겨 주세요.소 편 은 신속하게 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
만약 당신 이 본문 이 당신 에 게 도움 이 된다 고 생각한다 면,전 재 를 환영 합 니 다.번 거 로 우 시 겠 지만 출처 를 밝 혀 주 십시오.감사합니다!

좋은 웹페이지 즐겨찾기