【发布时间】:2016-12-15 17:02:21
【问题描述】:
我有一个 div,我想在覆盖屏幕的不透明图像上居中。我已经让它在 Chrome (blink) 中正常工作,但我无法让它在 Safari (webkit) 中显示。我创建了一个simplified JSFiddle version of my issue 并在此处包含了代码 sn-ps。
HTML
<div id="home">
<div class="wallpaper"></div>
<div class="info-wrapper">
<span class="name">John Doe</span>
</div>
</div>
SCSS
#home {
position: relative;
width: 100%;
height: 100vh;
min-height: inherit;
display: flex;
align-items: center;
background-color: black;
}
.wallpaper {
width: 100%;
height: 100%;
min-height: inherit;
opacity: .5;
background: url(https://images.unsplash.com/photo-1440700265116-fe3f91810d72);
background-size: cover;
background-repeat: no-repeat;
}
.info-wrapper {
position: absolute;
display: flex;
justify-content: center;
width: 100%;
color: white;
> .name {
font-weight: 700;
font-size: 7em;
}
}
如果这样可以更轻松地解决此问题,我愿意更改我的 HTML 结构。
【问题讨论】:
标签: html css safari sass webkit