如何用垂直文本居中和左对齐使全高图像与背景覆盖图像对齐

时间:2019-04-05 06:02:08

标签: html css html5 css3 sass

如何制作顶部黑色覆盖(从顶部到中间到底部)的全高图像

0%-> 35%-> 0%

I am able to make each columns seperately But I have not find 
a way here to put (apples,banana,grapes) in one column called 'Fruits' and 
(elephant,lion,cat,dog) in one column called 'Animals' as shown in output 
above

1 个答案:

答案 0 :(得分:1)

我只是用background-image代码编写了一个基本的black overlay。试试这个,希望对您有所帮助。谢谢

header {
  background-repeat: no-repeat;
  background-size: cover;
  color: #fff;
  display: flex;
  align-items: center;
  height: 100vh;
  position: relative;
  width: 100%;
}

header:before {
  background-image: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.35), rgba(0,0,0,0));
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0.5;
  height: 100%;
  width: 100%;
}

.content {
  margin-left: 20px;
  position: relative;
}
<header style="background-image: url('https://images.unsplash.com/photo-1476820865390-c52aeebb9891?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80')">
  <div class="content">
    <h2>Title</h2>
    <p>Description...</p>
  </div>
</header>