douyan6958 2017-02-15 12:02
浏览 32

图像显示模式的Onclick与更大的图像

(pardon my English) I am trying to create a modal gallery every which will popup when ever the image is clicked on which is gotten from database with the query, so i want the a larger image of the image clicked on in the middle of the modal. i have some js but that doesn't work properly when clicked it only flashes the larger image, Meanwhile i want the larger image appended into the modal which all happens on the click of the image. Pls can someone help me with this, i'm new to all of this

This is the php query

include('includes/settings.php');
$user_id= $_SESSION['user_id'];
$result =  mysqli_query($con,"SELECT * FROM images where user_id='$user_id' ");


while($row = mysqli_fetch_array($result)) {
echo '    <img onclick="gmshow()" class="gallery-image" src="' . $row['img_loc'] . '">
<a href="" ><p>' . $row['img_name'] . '</p><a>

<button class="del-btn btn btn-danger" rel="' . $row['id'] . '">Delete</button>

and this is the html for the modal

<div id="g-modal" class="gallery-modal" onclick="gmleave()">
  <span class="">&times;</span>
  <div class="gm-imagebox">
  <img onclick="gmshow()" class="gallery-modal-picture" src="' . $row['img_loc'] . '">
</div>

here is the css

.gallery-container {
  text-align: center;
  border-radius: 4px;
  margin-left: 100px;
  height: 600px;
  width: 1000px;
  padding-left: 100px;
  padding-right: 20px;
}


.gallery-image {
  width: 300px;
  height: 200px;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.3s;
}


.gallery-image:hover{
   opacity: 0.7;
}

.gallery-modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
}


.gallery-modal-image {
  width: 80%;
  max-width: 700px;
  margin: auto;

}

here is the js

    $(".gallery-imagelink").click(function gmshow(){
    var photoSrc = $(this).find("img").attr("src");
    $(this).append("<img class src='"+photoSrc+"' />");
    $(".gallery-modal").fadeIn()

});
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集