Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Vinod Godti
Vinod Godti

Posted on

     

Complex shapes and layout design in CSS

Some shapes or layout design in CSS is a little bit tricky to design in CSS code. using border-radius we can create many different shapes.CSS clip-path property will make complex shapes CSS design a lot easier to write code.

using the border-radius property

I will start with simple shapes and go to complex shapes

let's create the rounded corner rectangle

<!-- Rectangle with single border radius--><div></div>.rectangle{    background:#3380FF;    width: 20rem;    height: 20rem;    border-radius:25px;}
Enter fullscreen modeExit fullscreen mode

In the above CSS code border-radius property applied and rounded corner rectangle formed.

Let's change border-radius property value 2 different values

.rectangle{    ....    border-radius:25px 10px;}
Enter fullscreen modeExit fullscreen mode

first value in the border-radius is for top left and bottom right corner.
second value is for top right and bottom left corner.Thus we can have different rounded corner.

border-radius property can also have 4 values.Each value for each corner.

.rectangle{    ....    border-radius:10px 20px 30px 40px;}
Enter fullscreen modeExit fullscreen mode

first in the border-radius is for top left and 2nd is top right,3rd value is for bottom right and finally 4th one is bottom left value.

There is another way of providing the value of the border-radius property which is eight different value with "/" with 1 to 4 value on each side of the slash

let's look into the CSS code

    border-radius:[top-left horizontal radius] [top-right horizontal radius] [bottom-right horizontal radius] [bottom-left horizontal radius] / [top-left vertical radius] [top-right vertical radius] [bottom-right vertical radius] [bottom-left vertical radius]
Enter fullscreen modeExit fullscreen mode

As mentioned in the above code before the slash are for horizontal border-radius and after the slash are for vertical border-radius

.rectangle{    border-radius:10px 20px 30px 40px/ 40px 30px 20px 10px;}
Enter fullscreen modeExit fullscreen mode

All the values of the border-radius can be provided as percentage or em. If I write border-radius as 50% with square it will be converted to circle which is the beauty of the border-radius property.

Recently I found an amazing tool to create asymmetric shapes. So guy's here it is9elements
In this tool, you can create n number of different shapes with a border-radius property only.
In the next blog, I will write about clip-path and other complex CSS shapes.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I am coding geek ,interest learning new technologies in web and mobile app development.My technology stack is JavaScript | React | React Native | Node/Express | Mysql/MongoDb.
  • Location
    Bengaluru,India
  • Education
    Bachelor Degree in Computer Science
  • Work
    Full Stack Javascript Developer at Octopolis Technologies
  • Joined

More fromVinod Godti

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp