Sub-Pixels calculated and rendered differently among browsers

前端 未结 2 1307
刺人心
刺人心 2020-11-27 20:00

The purpose:

I am working on a code similar to this to create a component where an input field has an embedded button:

http://codepen.io/ano

2条回答
  •  佛祖请我去吃肉
    2020-11-27 20:54

    Use http://autoprefixer.github.io/ to get the cross browser support you need for display: flex;

    button, input, wrapper {
      display: inline-block; <----- Remove "display: inline-block;"
      border-radius: 3px;
    }
    
    .wrapper {
      position: relative;
      display: -webkit-box;<----- Add "display: flex;"
      display: -webkit-flex;<----- Add "display: flex;"
      display: -ms-flexbox;<----- Add "display: flex;"
      display: flex;<----- Add "display: flex;"
      width: 60%;
      margin: 1em;
      background-color: #ccc;
    }
    

    Extra reading and learning material:

    https://css-tricks.com/snippets/css/a-guide-to-flexbox/

    http://flexbox.io/#/

    https://philipwalton.github.io/solved-by-flexbox/demos/holy-grail/

    http://www.sketchingwithcss.com/samplechapter/cheatsheet.html

    Note: to overide a flex rule you will need to use flex shorthand rather than specific over-ride due to current browser shortfalls eg.

    .item {
      flex: 0 0 300px;
    }
    
    /* overide for some reason */
    
    .item {
      flex: 1 0 300px;
    }
    
    /* NOT */
    
    .item {
      flex-grow: 1;
    }
    

    You MAY need to do an over-ride for ie11:

    .ie11std .wrapper {
      display:table;
    }
    
    .ie11std .item {
      display:table-cell;
    }
    

    although this won't be responsive.

提交回复
热议问题