我需要修改我的 Css。 这是我的 CSS
.msg {
background-color: #fff;
border: 3px solid #fff;
display: inline-block;
left: 50%;
color:#123456;
opacity: 0;
padding: 35px;
position: fixed;
text-align: justify;
top: 40%;
visibility: hidden;
z-index: 10;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
如何删除下面的部分并仍然获得相同的结果?
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
最佳答案
如果您可以为 .msg
定义一个特定的高度,这可能会起作用。
.msg {
background-color: #fff;
border: 3px solid #fff;
display: inline-block;
height:200px; /*If you can define this*/
width:200px; /*and this*/
top:calc(40% - 100px); /*then use calc() to subtract half of .msg from top*/
left:calc(50% - 100px); /*then use calc() to subtract half of .msg from top*/
color:#123456;
opacity: 0;
padding: 35px;
position: fixed;
text-align: justify;
visibility: hidden;
z-index: 10;
}
关于javascript - 替换变换 : translate(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22182448/