Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounded corners fail to cut off content in webkit browsers if position:relative

Tags:

Rounded corners fail to cut off content in webkit browsers (e.g. Chrome) if position:relative;

See this demo.

HTML:

<div class="outer">     <div class="inner">     </div> <div> 

CSS:

.outer {     background:yellow;     border:solid 1px black;     position:relative;/* Setting this means rounded corners don't cut off content! */     overflow:hidden;      -moz-border-radius: 12px;     border-radius: 12px;    } .inner {     background:red;     height:50px; } 

Anyone know of a fix? Thanks-

like image 997
Yarin Avatar asked May 26 '11 20:05

Yarin


People also ask

Which CSS property can be used to give rounded corners to an element?

The border-radius CSS property rounds the corners of an element's outer border edge.

Which of the CSS property below will allow you to apply rounded corners?

The border-radius property defines the radius of the element's corners. Tip: This property allows you to add rounded corners to elements!

What CSS property must be used if you want to add rounded corners for your text inputs?

The CSS property border-radius adds rounded corners on images. You can round all of the image's corners or just select corners, vary the radius on different corners or display an image in the shape of an oval or a circle.

What is rounded corners in CSS?

CSS3 Rounded corners are used to add special colored corner to body or text by using the border-radius property.A simple syntax of rounded corners is as follows − #rcorners7 { border-radius: 60px/15px; background: #FF0000; padding: 20px; width: 200px; height: 150px; }


2 Answers

http://jsfiddle.net/USd5s/

Hate to add extra dom elements but a simple wrapper fixes this right up. You don't have to use my choice of element or css method either, span and qualified css is just my taste. or something would work just as well.

like image 151
Fresheyeball Avatar answered Sep 19 '22 12:09

Fresheyeball


You can force it to render in 3d with:

-webkit-transform: translateZ(0);    -moz-transform: translateZ(0);    transform: translateZ(0);     
like image 21
KIm Avatar answered Sep 21 '22 12:09

KIm