如何制作带圆角的div

25

如何使一个 div 的边框圆角呢?

6个回答

35

就是这样:

<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>

4
最好记得使用诸如“moz”(代表Mozilla)和“webkit”(代表Safari和Chrome)等前缀,可能还有我不知道的其他前缀。 - SilverHorn

13
使用border-radius属性。指定的数值越大(通常是以px为单位),形状就越圆。例如:
myDiv { border-radius:30px;}

希望这能帮到你。


8

添加以下 CSS:

border-top-right-radius:15px;
border-top-left-radius:15px;
border-bottom-right-radius:15px;
border-bottom-left-radius:15px;

6

使用CSS添加代码:border-radius: 10px

我使用10px作为示例,但您可以尝试任何您喜欢的像素数量。


1

如果你不想依赖像素,可以使用百分比

border-radius: 50%;


0
只需像这样使用"border-radius" CSS 属性:
div {
     border-radius:8px;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接