分享个网站首页弹窗代码

效果图:

带透明半遮罩效果,有关闭按钮,很不错,能自定义自己的广告标题和内容。

代码如下:

<html>
<head>
<style>
/* defaults */
/* =============================================== */
 
 
 
html {
  font-size: 62.5%;
}
 
body {
  --light: hsl(0, 0%, 100%);
  --background: linear-gradient(to right bottom, hsl(236, 50%, 50%), hsl(195, 50%, 50%));
 
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
 
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Open Sans', sans-serif;
 
  min-height: 100vh;
  background: linear-gradient(to bottom, hsl(236, 50%, 98%), hsl(236, 50%, 94%));
}
 
a,
a:link {
  font-family: inherit;
  text-decoration: none;
}
 
/* modal */
/* =============================================== */
.modal-container {
 
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
 
  display: flex;
  justify-content: center;
  align-items: center;
 
  width: 100%;
  height: 100%;
 
  background: hsla(0, 0%, 40%, .6);
}
 
/* using :target */
.modal-container:target {
  display: flex;
}
 
.modal {
width: 60rem;
  padding: 4rem 2rem;
  border-radius: .8rem;
 
  color: var(--light);
  background: var(--background);
  box-shadow: .4rem .4rem 2.4rem .2rem hsla(236, 50%, 50%, 0.3);
  position: relative;
 
  overflow: hidden;
}
 
.modal__details {
  text-align: center;
 
  margin-bottom: 4rem;
  padding-bottom: 4rem;
  border-bottom: 1px solid hsla(0, 0%, 100%, .4);
}
 
.modal__title {
  font-size: 3.2rem;
}
 
.modal__description {
  margin-top: 2rem;
 
  font-size: 1.6rem;
  font-style: italic;
}
 
.modal__text {
  padding: 0 4rem;
  margin-bottom: 4rem;
 
  font-size: 1.6rem;
  line-height: 2;
}
 
.modal__text::before {
  content: '';
 
  position: absolute;
  top: 0%;
  left: 100%;
  transform: translate(-50%, -50%);
 
  width: 18rem;
  height: 18rem;
  border: 1px solid hsla(0, 0%, 100%, .2);
  border-radius: 100rem;
 
  pointer-events: none;
}
 
.modal__btn {
  padding: 1rem 1.6rem;
  border: 1px solid hsla(0, 0%, 100%, .4);
  border-radius: 100rem;
 
  color: inherit;
  background: transparent;
  font-size: 1.4rem;
  font-family: inherit;
  letter-spacing: .2rem;
 
  transition: .2s;
  cursor: pointer;
}
 
.modal__btn:hover,
.modal__btn:focus {
  border-color: hsla(0, 0%, 100%, .6);
  transform: translateY(-.2rem);
}
 
/* links */
/* =============================================== */
.link-1 {
  font-size: 1.8rem;
 
  color: var(--light);
  background: var(--background);
  box-shadow: .4rem .4rem 2.4rem .2rem hsla(236, 50%, 50%, 0.3);
  border-radius: 100rem;
  padding: 1.4rem 3.2rem;
 
  transition: .2s;
}
 
.link-1:hover,
.link-1:focus {
  transform: translateY(-.2rem);
  box-shadow: 0 0 4.4rem .2rem hsla(236, 50%, 50%, 0.4);
}
 
.link-2 {
  width: 4rem;
  height: 4rem;
  border: 1px solid hsla(0, 0%, 100%, .4);
  border-radius: 100rem;
 
  color: inherit;
  font-size: 2.2rem;
 
  position: absolute;
  top: 2rem;
  right: 2rem;
 
  display: flex;
  justify-content: center;
  align-items: center;
 
  transition: .2s;
}
 
.link-2::before {
  content: '×';
 
  transform: translateY(-.1rem);
}
 
.link-2:hover,
.link-2:focus {
  border-color: hsla(0, 0%, 100%, .6);
  transform: translateY(-.2rem);
}
 
/* Second Version Link */
/* =============================================== */
.second-version-link,
.second-version-link:link {
  color: hsl(236, 50%, 50%);
  padding: .8rem 1.6rem .8rem .2rem;
  border-bottom: 2px solid hsl(236, 50%, 50%);
 
  font-size: 1.4rem;
  font-weight: bold;
 
  position: absolute;
  top: 4rem;
  right: 4rem;
}
 
.second-version-link::after {
  content: '\2197';
 
  position: absolute;
  top: 0;
  right: 0;
 
  font-size: .9em;
}
 
.abs-site-link {
  position: fixed;
  bottom: 20px;
  left: 20px;
  color: hsla(0, 0%, 0%, .6);
  font-size: 1.6rem;
}
</style>
</head>
<body>
<div class="modal-container" id="modal-opened" style="display: none" >
  <div class="modal">
 
    <div class="modal__details">
      <h1 class="modal__title">Modal Title</h1>
      <p class="modal__description">Sentence that will tell user what this modal is for or something.</p>
    </div>
 
    <p class="modal__text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis ex dicta maiores libero minus obcaecati iste optio, eius labore repellendus.</p>
 
    <button class="modal__btn">Button &rarr;</button>
 
    <a href="#modal-closed" onclick="closs()" class="link-2"></a>
 
  </div>
</div>
  <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
    open();
    function closs(){
          $("#modal-opened").hide();
     
 
    }
    function open() {
          $("#modal-opened").show();
         
    }
</script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汇站网

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值