How do I prevent an image from overflowing a rounded corner box?

前端 未结 10 819
盖世英雄少女心
盖世英雄少女心 2020-12-03 09:50

If I use this code, the image isn\'t clipped by the div\'s rounded corners (resulting in the image\'s square corners covering up the div\'s rounded ones):

&l         


        
10条回答
  •  半阙折子戏
    2020-12-03 10:23

    This may or may not work in your situation, but consider making the image a CSS background. In FF3, the following works just fine:

    I'm not sure there's another workaround — if you apply a border to the image itself (say, 1em deep), you get the same problem of square corners.

    Edit: although, in the "adding a border to the image" case, the image inset is correct, it's just that the image isn't flush with the div element. To check out the results, add style="border:1em solid black;border-radius:1em;-moz-border-radius:1em;" to the img tag (with width and height set appropriately, if necessary).

提交回复
热议问题