Capsule shape using border-radius without a set width or height?

christian picture christian · Sep 13, 2013 · Viewed 41.4k times · Source

Is it possible to make a capsule shape using border-radius without a set width or height?

I want the left and right sides to be completely rounded while the capsule would remain straight along it's horizontal length. Setting the radius to 50% doesn't seem to give the desired affect.

Capsule Shape

Answer

Jeremy Cook picture Jeremy Cook · Sep 13, 2013

Applying a very large border radius seems to work on many browsers (IE9+, FF, Chrome) like this mod of David's fiddle http://jsfiddle.net/cthQW/1/

border-radius: 500px;