-1

I'm building a website and At the top of the website I have a that has a background-image. The background-image takes up the whole div but I don't want it to. I want the image to keep it's original dimensions and center itself horizontally. How would I do this?

  • 2
    Try `text-align: center` on the container. Add your html so we can have a clue as to what you're doing. – wazz May 28 '18 at 19:13
  • Since it is a background image, use the css background property `background:url(path) no-repeat center center;` – Ibu May 28 '18 at 19:14

1 Answers1

0

You have to use background:url(path_to_image) no-repeat center center; in the css for the background div.

.bg{
background:url(http://via.placeholder.com/350x150) no-repeat center center;
height:250px;
}
<div class="bg">
</div>
Sujan Gainju
  • 4,273
  • 2
  • 14
  • 34