How to make CSS3 rounded corners hide overflow in Chrome/Opera

后端 未结 13 1719
无人及你
无人及你 2020-11-22 09:10

I need round corners on a parent div to mask content from its childen. overflow: hidden works in simple situations, but breaks in webkit based browsers and Oper

相关标签:
13条回答
  • 2020-11-22 09:39

    Seems this one works:

    .wrap {
        -webkit-transform: translateZ(0);
        -webkit-mask-image: -webkit-radial-gradient(circle, white 100%, black 100%);
    }
    

    http://jsfiddle.net/qWdf6/82/

    0 讨论(0)
  • 2020-11-22 09:43

    Add a z-index to your border-radius'd item, and it will mask the things inside of it.

    0 讨论(0)
  • 2020-11-22 09:46

    Supported in latest chrome, opera and safari, you can do this:

    -webkit-clip-path: inset(0 0 0 0 round 100px);
    clip-path: inset(0 0 0 0 round 100px);
    

    You should definitely check out the tool http://bennettfeely.com/clippy/!

    0 讨论(0)
  • 2020-11-22 09:47

    Not an answer, but this is a filed bug under the Chromium source: http://code.google.com/p/chromium/issues/detail?id=62363

    Unfortunately, doesn't look like there's anyone working on it. :(

    0 讨论(0)
  • 2020-11-22 09:50

    based on graycrow's excellent answer...

    Here's a more real world example that has two cicular divs with some filler content. I replaced the hard-coded png background with just a hex value, i.e.

    -=-webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
    

    is replaced with

    -webkit-mask-image:#fff;
    

    See this JSFiddle... http://jsfiddle.net/hqLkA/

    0 讨论(0)
  • 2020-11-22 09:52

    opacity: 0.99; on wrapper solve webkit bug

    0 讨论(0)
提交回复
热议问题