我已经设置了一个照片模式,所以当我点击一张小照片时,我得到一张较大的照片,模态为position: fixed;
,模态内容有position: absolute;
我可以margin: auto; left: 0; right: 0;
居中但随后的宽度变为一路左右,我想要的模式内容宽度是相同里面的照片或模态内容如何在一个固定div中居中放置一个绝对div
的内容我代码:
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding: 30px;
left: 0;
top: 0;
right: 0;
bottom: 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.4); /* Black w/ opacity */
}
.modal-content {
background-color: #fefefe;
position: absolute;
top: 50px;
margin-bottom: 30px;
margin: auto;
border: 1px solid #888;
}
.modalimg {
position: relative;
text-align: center;
}
.modalimg img{
max-width: 100%;
max-height: 400px;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
position: relative;
box-shadow: 0 0 20px rgba(0,0,0,0.4);
}
它也许现在有点混乱,但我已经尝试ALO t不同的东西没有运气..
嗨,你能提供的jsfiddle链接或剪断代码 – krychuq
你可以使用'变换:翻译()' – Swellar
https://jsfiddle.net/ e5smw1s9/18/ –