firefox adds strange space arround Pseudo-elements

后端 未结 3 1850
别跟我提以往
别跟我提以往 2021-01-24 06:25

Take a look at these photos
JSFiddle link at the bottom

firefox:
\"enter

3条回答
  •  醉梦人生
    2021-01-24 06:59

    I made you this solution, it places the button relative and the :before class absolute. Then you can use the top, bottom and left position, which will be relative to parent.

    Note that I added a overflow: hidden to the button, so the rounded borders are still visible.

    This is the altered CSS:

    .like {
        float: left;
        height: 30px;
        margin: 12.5px 0;
        background-color: #FAFAFA;
        border-radius: 4px;
        box-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
        padding: 0 10px 0 40px;
        overflow:hidden;
        margin: 12.5px 10px;
        background-color: #000;
        font: 16px/30px arial;
        color: #FFF;
        border:none;
        position: relative;
    }
    .like::before {
        float: left;
        width:30px;
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        content:'\F011';
        background-color: #FF7373;
        color: #FFF;
        border-right: 1px solid #CCC;
    }
    

    Also, see the updated Fiddle.

提交回复
热议问题