Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

border-radius + overflow:hidden = thin black line

Tags:

html

css

here is my issue:

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

.wrap {
    position: relative;
    width: 200px; 
    height: 66px;
    background: black;
    overflow: hidden;
    border-radius: 100px;
}

.inner {
    position: absolute;
    top: 0;
    left: 50%;
    right: 0;
    bottom: 0;
    background: white;
}

http://jsfiddle.net/cjW7Q/1/

Notice thin black line on the right side. Any ideas how to get rid of it?

UPDATE

There is a lot of workarounds, but problem is that overflow:hidden doesn't work correctly. Imagine that instead of .inner I have an image, that I want to move around with transition using transform (for hardware acceleration). I'll try to update demo later.

like image 686
Roman Pominov Avatar asked Apr 18 '14 10:04

Roman Pominov


People also ask

Why border-radius is not working?

If there are contents within the div that has the curved corners, you have to set overflow: hidden because otherwise the child div's overflow can give the impression that the border-radius isn't working.

What is the difference between border and border-radius?

The only difference between them is the right button has a radius of 5px applied. As with borders, radius allows you to set different properties for each side of the element using the toggle controls.

What does border-radius inherit mean?

The border-radius property defines the radius of the element's corners. Tip: This property allows you to add rounded corners to elements! This property can have from one to four values.

How do you give the border-radius only at the bottom?

CSS Syntaxborder-bottom-left-radius: length|% [length|%]|initial|inherit; Note: If you set two values, the first one is for the bottom border, and the second one for the left border. If the second value is omitted, it is copied from the first. If either length is zero, the corner is square, not rounded.


1 Answers

<edit>multiple bg mixing image and gradient can be used with animation too without extra markup DEMO </edit>


This is a commun defaut , you see it in FF too.

I would say , paint it the other way round : .wrap doesn't even need a bckground color. http://jsfiddle.net/cjW7Q/2/

.wrap {
    position: relative;
    width: 200px; 
    height: 66px;
    overflow: hidden;
    border-radius: 100px;
}

.inner {
    position: absolute;
    top: 0;
    width: 50%;
    left:0;
    bottom: 0;
    background: black;
}

Else you can use a gradient and no inner element:

.wrap {
    position: relative;
    width: 200px; 
    height: 66px;
    overflow: hidden;
    border-radius: 100px;
    background:linear-gradient(to left,white 50%,black 50%);
}

DEMO

like image 141
G-Cyrillus Avatar answered Sep 21 '22 06:09

G-Cyrillus