Border-radius and padding not playing nice

后端 未结 5 1598
萌比男神i
萌比男神i 2020-12-29 23:49

I\'m having trouble trying to get a radius on images. I\'ve simplified my problem and exaggerated the variables for demonstration purposes.

CSS:

5条回答
  •  庸人自扰
    2020-12-30 00:34

    This is a byproduct of applying both padding and a border-radius to the same element in some browsers (mostly IE and safari). The border-radius changes the curvature of the border component of the box model, which surrounds the padding component.

    In addition to the other answers, another interesting thing that seems to fix the issue is adding a border line. If you don't want to see the border, you could use border: 1px solid transparent, like this:

    .invisible-border {
        border: 1px solid transparent;
    }
    

    Demo in jsFiddle

    screenshot

提交回复
热议问题