【发布时间】:2018-10-05 03:16:09
【问题描述】:
我有一个页面一半的背景图片,我在它下面有一个 div,我还想把它的四分之一放在背景图片上方。我试图将 padding-top 放在 profile 类上,但在将 background-pic 和 profile 包装在 div 中时它不起作用。
CSS:
.background-pic{
background-image: url('https://images.pexels.com/photos/825262/pexels-photo-825262.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260');
height: 60%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-color: rgba(0,0,0,0);
}
.profile{
padding-top: 300px;
}
HTML:
<div class="background-pic">
</div>
<div class="container">
<div class="profile" style="background-color: grey; height : 300px;">
<div class="profile-pic">
</div>
</div>
</div>
【问题讨论】:
-
指定html和body高度为100%,查看div高度的百分比