How to make a div with rounded corners
Asked Answered
C

6

28

How do you make a div so that its border corners are rounded?

Cisco answered 18/8, 2011 at 11:51 Comment(0)
Q
38

Here it is:

<style type="text/css">
div.test
{
    width: 115px;
    padding: 10px;
    border: 2px solid #000;
    border-radius: 15px;
    -moz-border-radius: 15px;
}
</style>
<div class="test">This is some text!</div>
Quiroz answered 18/8, 2011 at 11:52 Comment(1)
It's best if you remember to use prefixes such as "moz" (for Mozilla) and "webkit" (for Safari and Chrome.) Maybe there are more that I don't know about.Quiroz
A
16

Use the border-radius property. The higher the specified amount (typically in px), the more rounded your shape. Example:

myDiv { border-radius:30px;}

Hope that helps.

Arni answered 25/5, 2014 at 1:58 Comment(0)
S
10

add this css:

border-top-right-radius:15px;
border-top-left-radius:15px;
border-bottom-right-radius:15px;
border-bottom-left-radius:15px;
Spicule answered 14/11, 2013 at 23:48 Comment(0)
S
6

With CSS add the code: border-radius: 10px.

I use 10px for example, but you can experiment with however amount of pixels you like.

Squatter answered 13/11, 2013 at 23:21 Comment(0)
J
1

If you don't want to rely on pixels, you can always use %

border-radius: 50%;

Jammiejammin answered 8/6, 2021 at 9:0 Comment(0)
T
0

Just use "border-radius" css property like this:

div {
     border-radius:8px;
}
Tilla answered 17/10, 2023 at 21:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.