Jquery 从单击位置到中心的图像缩放

Jquery 从单击位置到中心的图像缩放,jquery,html,css,Jquery,Html,Css,单击时的图像需要缩放并定位在页面中心 我正在努力得到这个。但图像从其位置缩放,但未到达中心 请帮忙 单击时的图像需要从其位置缩放到页面中心 提前谢谢 HTML: 代码:此处应用此更改- div[id^=image]:target { width: 450px; height: 300px; z-index: 5000; top: 50%; transform: translate(-50%, -50%); left: 50%; positi

单击时的图像需要缩放并定位在页面中心

我正在努力得到这个。但图像从其位置缩放,但未到达中心

请帮忙

单击时的图像需要从其位置缩放到页面中心

提前谢谢

HTML:


代码:

此处应用此更改-

div[id^=image]:target {
    width: 450px;
    height: 300px;
    z-index: 5000;
    top: 50%;
    transform: translate(-50%, -50%);
    left: 50%;
    position:fixed;
}

你将有你的弹出图像水平和垂直居中

我建议使用jquery中的.toggleClass(classname)向单击的图像添加一个类,并将新元素的css设置为页面的中心。下面是API参考()
#images-box {
    width: 100%;
  height:100%;
}

.image-lightbox img {
    width: inherit;
    height: inherit;
    z-index: 3000;
}

.holder {
    width: 200px;
    height: 200px;
    float: left;
  position:relative;
}

.image-lightbox {
    width: inherit;
    height: inherit;
    background: #fff;
    position: relative;
    top: 0;
    -webkit-transition: all ease-in 0.25s;
    -moz-transition: all ease-in 0.25s;
    -ms-transition: all ease-in 0.25s;
    -o-transition: all ease-in 0.25s;
}

.image-lightbox span {
    display: none;
}

.image-lightbox .expand {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    z-index: 4000;
}

.image-lightbox .close {
    position: absolute;
    width: 20px; height: 20px;
    right: 20px; top: 20px;
}

.image-lightbox .close a {
    height: auto; width: auto;
    padding: 5px 10px;
    color: #fff;
    text-decoration: none;
    background: #22272c;
    float: right;
}

div[id^=image]:target {
    width: 450px;
    height: 300px;
    z-index: 5000;
    top: 25%;
    left: 25%;
  position:absolute;
}
div[id^=image]:target .close {
    display: block;
}

div[id^=image]:target .expand {
    display: none;
}
div[id^=image]:target {
    width: 450px;
    height: 300px;
    z-index: 5000;
    top: 50%;
    transform: translate(-50%, -50%);
    left: 50%;
    position:fixed;
}