Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make div rounded corners with transparent background?

How can I create a div with rounded corners and transparent backgrounds? A bit like twitter does. So that at the edge of the corners you can see the page background and not a black edge.

like image 329
Yesterday Avatar asked Jan 31 '11 19:01

Yesterday


1 Answers

For full control over which elements are transparent and which are not, specify colors in rgba instead of hex:

div{
  -moz-border-radius:10px;
  -webkit-border-radius:10px;
  border-radius:10px;
  background: #fff; /* fallback for browsers that don't understand rgba */
  border: solid 10px #000; /* fallback for browsers that don't understand rgba */
  background-color: rgba(255,255,255,0.8); /* slighly transparent white */
  border-color: rgba(0,0,0,0.2); /*Very transparent black*/
}

The fourth number within rgba is the level of transparency (alpha channel), 1 represents fully opaque and 0 is fully transparent.

like image 187
methodofaction Avatar answered Oct 15 '22 17:10

methodofaction