首页 > 编程开发 > CSS    日期:2021-11-18 / 来自互联网 / 浏览

css设置button为直角的方法

在css中可以使用border-radius属性来设置元素的圆角边框,border-radius属性的语法为:

border-radius: 1-4 length|% / 1-4 length|%;

其中需要注意的是:

length用来定义圆角的形状,%用来以百分比定义圆角的形状。

button元素在默认情况下是有一些圆角的:

css怎样设置button为直角

想要将button设置为直角,只需要给button元素添加“border-radius:0px;”或者“border-radius:0%;”样式即可。

示例代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
button{
    border-radius:0%;
    }
</style>
<body>
    <button>123</button>
</body>
</html>

或者另一种形式:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
button{
    border-radius:0px;
    }
</style>
<body>
    <button>123</button>
</body>
</html>

上述两种方法输出结果是相同的:

css怎样设置button为直角

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章

1 2 3 4 5