html卡中的重叠问题

时间:2017-11-29 12:48:51

标签: javascript jquery html css

在我的网站中,有三列使用bootstrap来保存图像。每个图像都有图像的按钮中心。我添加了一个对话框,当用户点击图像中的按钮时,我想要显示该对话框。但是对话框窗口在作为图像的列的背面进行探索。我想在整个页面上显示我的内容对话框。请任何人帮我解决这个问题。 这里我附上了我的代码

<html>
<head>
<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
     <link rel = "stylesheet" type = "text/css" href = "hover.css">
     <link rel = "stylesheet" type = "text/css" href = "dialogue.css">
<style>
.card {
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
    transition: 0.3s;
    margin:43px;
    height:70%
}
.img {
    height:350px;
    width:100%;
}


  </style>
     </head>
<body>
<div class="container">
<div class="box">
    <a class="button" href="#popup1">Let me Pop up</a>
</div>

<div id="popup1" class="overlay">
    <div class="popup">
        <h2>Here i am</h2>
        <a class="close" href="#">&times;</a>
        <div class="content">
            Thank to pop me out of that button, but now i'm done so you can close this window.
        </div>
    </div>
</div>
      <div class="row">
           <div class="col-sm-4">
             <div class="card">
               <div class="hvrbox">
                 <img class = "img" src="img/7aam.jpg" alt="Mountains" class="hvrbox-layer_bottom">
                   <div class="hvrbox-layer_top">
                     <div class="hvrbox-text">
                     <a href="vido.html"><span class="button fa fa-play fa-2x"></span></a>
                       <div>surya, shruti hasan</div>
                    </div>
                 </div>
               </div>
           </div>
         </div>  
      <div class="col-sm-4">
             <div class="card">
                <div class="hvrbox">
                   <img class = "img" src="img/1000il.jpg" alt="Mountains" class="hvrbox-layer_bottom">
                     <div class="hvrbox-layer_top">
                        <div class="hvrbox-text"><a href="vido.html"><span class="fa fa-play fa-2x"></span></a>
                         <div>Karthi, Andriya</div>
                    </div>
                </div>
            </div>
       </div>
     </div>

      <div class="col-sm-4">
        <div class="card">
            <div class="hvrbox">
              <img class = "img" src="img/NK.jpg" alt="Mountains" class="hvrbox-layer_bottom">
                <div class="hvrbox-layer_top">
                  <div class="hvrbox-text"><a href="https://www.youtube.com/watch?v=mIQToVqDMb8"><span class="fa fa-play fa-2x"></span></a>
                    <div>Arya</div>
                </div>
           </div>
        </div>
     </div>
    </div> 
</div>    <!--row div-->

      </br>
      <div class="row">   

      <div class="col-sm-4">
          <div class="card">
            <div class="hvrbox">
               <img class = "img" src="img/bahu.jpg" alt="Mountains" class="hvrbox-layer_bottom">
                   <div class="hvrbox-layer_top">
                      <div class="hvrbox-text"><a href="https://www.youtube.com/watch?v=mIQToVqDMb8"><span class="fa fa-play fa-2x"></span></a>
                        <div>Prabas, Anushka</div>
                    </div>
                </div>
            </div>
        </div>
        </div>
      <div class="col-sm-4">
          <div class="card">
             <div class="hvrbox">
               <img class = "img" src="img/raam.jpg" alt="Mountains" class="hvrbox-layer_bottom">
                  <div class="hvrbox-layer_top">
                     <div class="hvrbox-text"><a href="https://www.youtube.com/watch?v=mIQToVqDMb8"><span class="fa fa-play fa-2x"></span></a>
                        <div>Jeeva, Saranya</div>
                    </div>
               </div>
            </div>
      </div>
      </div>

      <div class="col-sm-4">
          <div class="card">
            <div class="hvrbox">
                <img class = "img" src="img/sivaji.jpg" alt="Mountains" class="hvrbox-layer_bottom">
                    <div class="hvrbox-layer_top">
                      <div class="hvrbox-text"><a href="https://www.youtube.com/watch?v=mIQToVqDMb8"><span class="fa fa-play fa-2x"></span></a>
                           <div>Rajini, Shreya</div>
                      </div>
                 </div>
           </div>
      </div>
      </div>

      </div>  <!--row div-->
      </div>  <!--container div-->


</body>
</html>

Dialogue.css

body {
  font-family: Arial, sans-serif;
  background-size: cover;
  height: 100vh;
}

h1 {
  text-align: center;
  font-family: Tahoma, Arial, sans-serif;
  color: #06D85F;
  margin: 80px 0;
}

.box {
  width: 40%;
  margin: 0 auto;
  background: rgba(255,255,255,0.2);
  padding: 35px;
  border: 2px solid #fff;
  border-radius: 20px/50px;
  background-clip: padding-box;
  text-align: center;
}

.button {
  font-size: 1em;
  padding: 10px;
  color: #fff;
  border: 2px solid #06D85F;
  border-radius: 20px/50px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease-out;
}
.button:hover {
  background: #06D85F;
}

.overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  transition: opacity 500ms;
  visibility: hidden;
  opacity: 0;
}
.overlay:target {
  visibility: visible;
  opacity: 1;
}

.popup {
  margin: 70px auto;
  padding: 20px;
  background: #fff;
  border-radius: 5px;
  width: 30%;
  position: relative;
  transition: all 5s ease-in-out;
}

.popup h2 {
  margin-top: 0;
  color: #333;
  font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
  position: absolute;
  top: 20px;
  right: 30px;
  transition: all 200ms;
  font-size: 30px;
  font-weight: bold;
  text-decoration: none;
  color: #333;
}
.popup .close:hover {
  color: #06D85F;
}
.popup .content {
  max-height: 30%;
  overflow: auto;
}

@media screen and (max-width: 700px){
  .box{
    width: 70%;
  }
  .popup{
    width: 70%;
  }
}

Hover.css

.hvrbox,
.hvrbox * {
    box-sizing: border-box;
}
.hvrbox {
    position: relative;
    display: inline-block;
    overflow: hidden;
    max-width: 100%;
    height: auto;
}
.hvrbox img {
    max-width: 100%;
}
.hvrbox .hvrbox-layer_bottom {
    display: block;
}
.hvrbox .hvrbox-layer_top {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 15px;
    -moz-transition: all 0.4s ease-in-out 0s;
    -webkit-transition: all 0.4s ease-in-out 0s;
    -ms-transition: all 0.4s ease-in-out 0s;
    transition: all 0.4s ease-in-out 0s;
}
.hvrbox:hover .hvrbox-layer_top,
.hvrbox.active .hvrbox-layer_top {
    opacity: 1;
}
.hvrbox .hvrbox-text {
    text-align: center;
    font-size: 18px;
    display: inline-block;
    position: absolute;
    top: 50%;
    left: 50%;
    -moz-transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}
.hvrbox .hvrbox-text_mobile {
    font-size: 15px;
    border-top: 1px solid rgb(179, 179, 179); /* for old browsers */
    border-top: 1px solid rgba(179, 179, 179, 0.7);
    margin-top: 5px;
    padding-top: 2px;
    display: none;
}
.hvrbox.active .hvrbox-text_mobile {
    display: block;
}

preview on Plunker

1 个答案:

答案 0 :(得分:0)

您的问题是z-index问题,只需增加.overlay,如下所示:

.overlay {
    z-index: 999;
}

这是一个有效的JSfiddle