Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overflow hidden with border-radius and translate3d

Tags:

html

css

When content of block with overflow: hidden; and border-radius translated, its corners aren't hidding. Is there any solution to fix this?

HTML

<div class="scroller">
    <div class="scroller-content"></div>
</div>

CSS

.scroller{
    width: 300px;
    height: 500px;
    border: 3px solid red;
    border-radius: 30px;
    overflow: hidden;
}
.scroller-content{
    width: 300px;
    height: 300px;
    background: green;
    -webkit-transform: translate3d(0, -8px, 0);
}

http://jsfiddle.net/aZ5Qn/

like image 345
Artem Svirskyi Avatar asked Jun 25 '13 14:06

Artem Svirskyi


2 Answers

Accually, you can just put

transform: translate3d(0,0,0);

On your element that needs the overflow + border-radius combo...

like image 171
curly_brackets Avatar answered Nov 09 '22 01:11

curly_brackets


Since you are not using the z in the translate, you can change it to translate2d, that does work:

demo

.scroller{
width: 300px;
height: 500px;
border: 3px solid red;
border-radius: 30px;
overflow: hidden;
}
.scroller-content{
width: 300px;
height: 300px;
background: green;
-webkit-transform: translate(0, -8px);
}

This is documented in the link that Chtiwi Malek provided, but there it states that is only for mobile browser, and I have this issue in desktop.

edit

It also works (at least in desktop) if you set overflow and transform in the same element

.scroller{
    width: 300px;
    height: 500px;
    border: 3px solid red;
    border-radius: 30px;
    overflow: hidden;   
    -webkit-transform: translate3d(0, -8px, 5px);
}
.scroller-content{
    width: 300px;
    height: 300px;
    background: green;
}
like image 31
vals Avatar answered Nov 09 '22 00:11

vals