How can i center a div in a parallax background image

时间:2017-12-18 08:38:47

标签: html css html5 twitter-bootstrap css3

I'd like to horizontally and vertically center a div with a parallax background image. I've tried DocumentReference docRef = db.collection("distinctTitles").document("titleToCheck"); docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() { @Override public void onComplete(@NonNull Task<DocumentSnapshot> task) { if (task.exists()) { //Do something } else { //Do something else } } }); class bootstrap 4, d-block, mx-auto. It centered it horizontally but not vertically. How can I also center it vertically?

text-center
.parallax_bg {
  background: url(assets/img/corinne-kutz-211251.jpg);
  background-size: cover;
  height: 100%;
  min-height: 100%;
  overflow: auto;
}

.parallax {
  background-attachment: fixed;
  background-size: cover;
  background-repeat: no-repeat;
}

.parallax_text > p {
  font-size: 20px;
}

2 个答案:

答案 0 :(得分:1)

只需将let ext = NSURL(fileURLWithPath: path/of/your/file as! String).pathExtension print(ext!) 应用于position: relative课程,然后将以下css应用于parallax课程:

parallax_text

答案 1 :(得分:0)

您可以像这样尝试flex:

&#13;
&#13;
.parallax_bg {
  background: url(https://lorempixel.com/400/400/);
  background-size: cover;
  height: 100%;
  min-height: 100%;
  overflow: auto;
}

.parallax {
  background-attachment: fixed;
  background-size: cover;
  background-repeat: no-repeat;
  height: 120vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.parallax_text {
  background: #fff;
}

.parallax_text>p {
  font-size: 20px;
}
&#13;
<section data-stellar-background-ratio="0.5" class="parallax parallax_bg text-center mx-auto d-block">
  <div class="parallax_text">
    <h3><em>Venenatis Nisl Porta</em></h3>
    <p>Lorem vestibulum gravida ipsum non velit aliquam</p>
    <a class="btn btn-primary mt-3" href="#">Read More&nbsp;<i class="fa fa-angle-double-right" aria-hidden="true"></i></a>
  </div>
</section>
&#13;
&#13;
&#13;