css - 在 Explorer 和 Safari 中调整内容

标签 css internet-explorer safari flexbox

我做错了什么?在 Chrome、Firefox、Opera 中很酷,但在 Safari/Explorer 中却不行。

父项位于右下角,child1 在父项之上(垂直居中于父项)。 parent 可能有不同的大小, child 必须还在上面。

example image

.cotainer{
   position: fixed;
   bottom: 0px;
   right: 0px;
   display: -webkit-box;
   display: -moz-box;
   display: -ms-flexbox;
   display: -webkit-flex;
   margin: 10px;
}


.parent {
   width: 80px;
   height:80px;
   min-width: 80px;
   min-height:80px;
   background-color:#8BBF46;
   border-radius:50%;
   bottom: 0px;
   right: 0px;
   position: relative;
   text-align: center;
   cursor: pointer;
   padding: 0;
   margin: 0;
   display: -webkit-box;
   display: -moz-box;
   display: -ms-flexbox;
   display: -webkit-flex;
   display: flex;
   align-items: center;
   justify-content: center;
   margin: 15px;
   order: 1;
   order: -webkit-1;
   order: -moz-1;
   order: -ms-1;
   order: -webkit-1;
}

.child1{
   position: absolute;
   bottom: 100%;
}

.child2{
   font-size: 16px;
   color: #222;
   padding: 0.4em;
   display: block;

}

.child2:hover{
   color: #fff;
}
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link type="text/css" rel="stylesheet" href="stylesheets/style-okrojone.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>

<body>
    <div class="cotainer">
        <div class="parent">
            <div class="child1"><img src="/image/tbnsI.jpg" alt="grafika-dodatkowa"></div>
            <i class="child2">parent</i>
        </div>
    </div>

</body>

</html>

最佳答案

问题是,您的 parent 容器是一个 flexbox,但是您的 child1 使用 position: absolute。你不应该对 flexbox 中的元素使用绝对定位,因为这是 not offically supported .

所以看起来 chrome 能够以“正确”的方式呈现它,但其他一些浏览器可能不会。最好的办法是更改您的布局,这样您就不再使用 flexbox 和绝对位置了。

关于css - 在 Explorer 和 Safari 中调整内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45493434/

相关文章:

Javascript 使用选项将单列 html 更改为多列

CSS/SVG背景图片IE11对齐问题

css - IE 中的 aviaslider 隐藏了 Super Suckerfish 下拉列表

firefox - 测试不同版本的非IE浏览器

html - 复选框背景颜色和样式

html - 移动导航 - 触摸不激活

javascript - Internet Explorer 8 chop iframe 内容

javascript - 'length' 为空或不是对象?浏览器 8

Safari 错误中的 CSS 列定义列表

javascript - safari 浏览器上的光标高度太高,但在 chrome 上还好