Johann
Johann

Reputation: 29867

Rounded corners only on some corners in css

Is it possible to create a rounded corner using css where I only get rounding on some specific corner rather than all of the corners? Currently I am using:

  -webkit-border-radius: 7px;
  -moz-border-radius: 7px;
  border-radius: 7px;

But I don't see any way to specifying the top left or some other corner. I want the other corners to remain square.

Upvotes: 19

Views: 18542

Answers (5)

Hussain
Hussain

Reputation: 73

Its very simple to create a rounded border by specifying a particular corner :-

If u want to create the top left corner rounded and all other corners straight ,then use this code instead of "border-radius" and give your desired value in pixels

border-top-left-radius: 10px;
-moz-border-top-left-radius: 10px;
-webkit-border-top-left-radius: 10px;

you can do this in a differnt way also :-

border-radius: 10px 0px 0px 0px ;

where the first one in for top-left corner(10px) , second is for top-right corner (0px) , third is for bottom-right corner (0px) and the fourth is for bottom-left corner (0px).

by this , only top-left corner will be made rounded and all other corners will remain the same

Upvotes: 0

Sobin Augustine
Sobin Augustine

Reputation: 3765

.rounded-corners {
   -moz-border-radius: 20px;
   -webkit-border-radius: 20px;\
    border-radius: 20px;
}

Changes can be made like this,

    -webkit-border-top-left-radius: 0px;
    -webkit-border-top-right-radius: 0px;
    -moz-border-radius-topleft: 0px;
    -moz-border-radius-topright: 0px;
     border-top-left-radius: 0px;
     border-top-right-radius: 0px;
    -webkit-border-bottom-left-radius: 0px;
    -webkit-border-bottom-right-radius: 0px;
    -moz-border-radius-bottomleft: 0px;
    -moz-border-radius-bottomright: 0px;
     border-bottom-left-radius: 0px;
     border-bottom-right-radius: 0px;

Upvotes: 1

Brian
Brian

Reputation: 5028

You can use: DEMO

  • border-radius-top-left
  • border-radius-top-right
  • border-radius-bottom-left
  • border-radius-bottom-right

    border-radius: 5px 0 10px 0;
    

    enter image description here

For more information visit this website.

Upvotes: 1

Mr. Alien
Mr. Alien

Reputation: 157284

You can do it like

border-radius: 5px 10px 15px 20px; /* This is a short hand syntax */

The above syntax works like a fan, starting from 5px and ends on 20px, just added a diagram below, the arrow in there depicts the start of the shorthand syntax flow.

enter image description here

Demo

To specify a particular radius, you can use property like

border-top-left-radius: 10px;

Which is equivalent to

border-radius: 10px 0 0 0;

Upvotes: 46

Anurag-Sharma
Anurag-Sharma

Reputation: 4388

Try using this : -

border-radius: <specific_value>px <specific_value>px <specific_value>px <specific_value>px 

these 4 values represent the different corners in a clock-wise manner .

Upvotes: 1

Related Questions