Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Put text on top div that is inside another div

I want to put the text over the div that is containing an image and that div is inside another div that also has an image.

.marioHeader {
  background-image: url("resources/marioBackground.jpg");
  background-size: 600px;
  height: 500px;
  background-position: bottom;
  display: flex;
  justify-content: center;
  align-items: center;
  background-repeat: repeat-x;
  background-color: #6096ff;
  margin-top: 50px;
  text-align: center;
}

.title {
  text-align: center;
}

.headermario {
  background-image: url("resources/banner.png");
  background-size: 600px;
  background-repeat: no-repeat;
  background-position: bottom;
  background-color: red;
  height: 200px;
  width: 90%;
}
<div class="marioHeader">
  <h1 class="title">Super Mario</h1>
  <div class="headermario">
  </div>
</div>

It looks like this: enter image description here

I want it to look like this: enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use the below code:

    .marioHeader {
      background-image: url("resources/marioBackground.jpg");
      background-size: 600px;
      height: 500px;
      background-position: bottom;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background-repeat: repeat-x;
      background-color: #6096ff;
      margin-top: 50px;
      text-align: center;
    }

    .title {
      text-align: center;
    }

    .headermario {
      background-image: url("resources/banner.png");
      background-size: 600px;
      background-repeat: no-repeat;
      background-position: bottom;
      background-color: red;
      height: 200px;
      width: 90%;
    }
    <div class="marioHeader">
      <h1 class="title">Super Mario</h1>
      <div class="headermario">
      </div>
    </div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading