我的网站有一个使用 CSS 设置样式的弹出窗口,但我一直想不出如何将它居中。所有常规方法都不起作用,因为无论宽度如何,我都需要它居中。
这是背景和弹出框的 CSS:
.filterbox {
background-color: #000000;
display: none;
height: 100%;
left: 0%;
opacity: 0.5;
position: absolute;
top: 0%;
width: 100%;
z-index: 10;
}
.floatbox {
background-color: white;
border: 2px solid #FD6907;
display: none;
margin:0 auto;
min-height: 200px;
min-width:500px;
overflow: hidden;
padding: 10px;
position: absolute;
top: 30px;
left:30%;
z-index: 11;
-moz-border-radius: 15px;
border-radius: 15px;
-webkit-border-radius:15px;
}
这是弹出框内的 div。
#boxcontent {
height: auto;
width:100%;
left: 0pt;
margin-bottom: 50px;
min-height: 150px;
padding: 10px;
}
目前它是绝对定位的,但我想知道一种更符合要求的方式,无论弹出框的大小如何,它都能使弹出窗口居中。
最佳答案
.floatbox{
width:600px;
margin-left:auto;
margin-right:auto;
}
或者你选择的宽度
关于css - 如何使我的弹出窗口死点,不管它的宽度是多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10330363/