100% width divs not spanning entire width of the browser in webkit

前端 未结 8 1016
南方客
南方客 2021-01-08 01:10

I\'m having a hard time with what I thought would be a dead simple issue.

I\'m trying to create a div that spans 100% of the width of a browser window. The div is f

相关标签:
8条回答
  • 2021-01-08 01:23

    I have fixed mine by

    body
    {
    background-color:#ffffdffffd;
    width:100%;
    margin:0px;
    }
    
    0 讨论(0)
  • 2021-01-08 01:24

    I fixed by using display: table-cell

    #field {
        width: 100%;
        background: #009900;
        height: 100px;
        margin: 0;
        margin-bottom: 25px;
        padding: 0;
        display: table;
    }    
    
    .singleyard {
        width: 1%;
        margin: 0;
        padding: 0;
        background: #090;
        display: table-cell;
    }
    
    .fiveyards {
        width: 5%;
        margin: 0;
        padding: 0;
        display: table-cell;
    }
    
    0 讨论(0)
  • 2021-01-08 01:24

    I have fixed mine by adding

    html, body
    {
      width: 100%;
      margin: 0px;
    }
    

    happy coding!!!

    0 讨论(0)
  • 2021-01-08 01:25

    Only thing I can think of is to add:

    html, body
    {
        width: 100%;
    }
    

    Just to make sure safari knows the parent container of field is also 100%;

    Another thing to try is to add:

    html { overflow-y: scroll; }
    

    That should force a side scrollbar, even if it's grayed out. I wonder if some webkit rendering temporarily flashes a scrollbar, but fails to give the space back. Any of that work?

    0 讨论(0)
  • 2021-01-08 01:31

    I had the same problem, this is what I discovered: somewhere in your CSS you have another div that has a width of 100% and ALSO has padding. Since the padding value is added to the width, the value of that div becomes greater than 100%. The solution is to make sure not to use padding on any div that is set to 100% width. If you need padding, try adding the padding to the element inside the div instead.

    0 讨论(0)
  • 2021-01-08 01:32

    adding min-width: 100% seems to do the trick

    0 讨论(0)
提交回复
热议问题