“width: calc(100% / 3);” not working properly in any IE

后端 未结 3 1766
滥情空心
滥情空心 2020-12-19 00:01

I have a 3 column layout that should fill the whole screen so on my columns I am using:

width: calc(100% / 3);

So lets say for example my s

相关标签:
3条回答
  • 2020-12-19 00:15

    Try width: calc(100% * 0.33333); to make sure float rounding errors err on the side of caution or width: calc((100% / 3) - 0.1px);.

    0 讨论(0)
  • 2020-12-19 00:20

    Better option:

    li {
        &:last-child {
            margin-right: -1px;
        }
    }
    

    And you can use: width: calc(100% / 3)

    0 讨论(0)
  • 2020-12-19 00:22

    2020 Answer

    Use flexbox:

    .container {
       width: 242px; /* /3 = 80.66̅  */
       height: 100px;
       
       display: flex;
    }
    
    .col {
      flex: 1 0 0; /* Set flex basis to 0 to force equal widths */
    }
    
    .col1 {
      background-color: red;
    }
    .col2 {
      background-color: green;
    }
    .col3 {
      background-color: blue;
    }
    <div class="container">
      <div class="col col1"></div>
      <div class="col col2"></div>
      <div class="col col3"></div>
    <div>

    Old Answer

    It would seem that the suggestion by @web-tiki with:

    width:33.33%;
    

    is the best option.

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