Why is my container background image so zoomed in?

后端 未结 2 1665
广开言路
广开言路 2021-01-05 18:17

I am having an issue with my background image of a container being zoomed in on the browser. The picture is 1200px wide and my container is also 1200px

2条回答
  •  醉梦人生
    2021-01-05 19:14

    You need to specify a few more properties for your background-image like this:

    .container {
      width: 1200px;
      height:600px;
      background-image: url("img/background.jpg");
      background-size: cover; /* or contain depending on what you want */
      background-position: center center;
      background-repeat: no-repeat;
      text-align:center;
      margin:auto;
      padding:0;
    }
    

提交回复
热议问题