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

How do I get an image to appear behind the header?

I am currently working in HTML and CSS. I need to make an image the background of the header.

#banner {
  padding: 60px;
  text-align: center;
  background-image: url("https://via.placeholder.com/800x300");
  background-color: #1abc9c;
  color: white;
  font-size: 30px;
}
<div id="banner">
  <h1>AlexArgent</h1>
  <p>My Personal Homepage</p>
</div>

>Solution :

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

The background shorthand property overrides the background-image property. Use background-color instead of the former, or include the color value in it.

See https://developer.mozilla.org/en-US/docs/Web/CSS/background.

#banner {
  padding: 60px;
  text-align: center;
  background: #1abc9c url("https://via.placeholder.com/300x100");
  /* or this:
  background-image: url("https://via.placeholder.com/300x100");
  background-color: #1abc9c;
  */
  background-repeat: no-repeat; /* for demo only */
  color: white;
  font-size: 30px;
}
<div id="banner">
  <h1>AlexArgent</h1>
  <p>My Personal Homepage</p>
</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