Remove 3 pixels in iOS/WebKit textarea

前端 未结 7 1452
说谎
说谎 2021-02-06 23:39

I\'m trying to create a textarea that looks exactly like a div.

However, on iOS there\'s 3 pixels coming from somewhere that I can\'t remove.

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 00:33

    Based off the previous answers it seems like the best way to tackle this is by adding a margin-left: -3px to the textarea element. We can do this with some CSS tackling particularly iOS Safari which won't mess things up on Android

    textarea @supports (-webkit-overflow-scrolling: touch) {
        /* CSS specific to iOS devices */
        margin-left: -3px;
    }
    textarea::placeholder @supports (-webkit-overflow-scrolling: touch) {
        /* CSS specific to iOS devices */
        text-indent: -3px;
    }
    

提交回复
热议问题