替换变换:translate()

时间:2014-03-04 20:35:20

标签: javascript html css html5 css3

我需要修改我的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%);

1 个答案:

答案 0 :(得分:0)

如果您可以为.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;
}
相关问题