Why is my container background image so zoomed in?

后端 未结 2 1664
广开言路
广开言路 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:11

    This works fine!

    background:rgb(37, 16, 13) url("images/bc02.jpg");
    background-repeat: no-repeat;
    width: 100%;
    height:100%;
    background-position: center center;
    text-align:center;
    margin:auto;
    padding:0;
    
    0 讨论(0)
  • 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;
    }
    
    0 讨论(0)
提交回复
热议问题