【发布时间】:2013-02-23 04:41:38
【问题描述】:
我有兴趣制作一个类似于https://new.myspace.com/ 主页上的html 按钮。我知道 html 看起来像这样:
<button class="button" id="join">Join</button>
虽然我不确定 css 应该是什么样子。我知道网上有很多关于 html 按钮的教程,但我不确定半矩形按钮。谢谢,哈里森
【问题讨论】:
我有兴趣制作一个类似于https://new.myspace.com/ 主页上的html 按钮。我知道 html 看起来像这样:
<button class="button" id="join">Join</button>
虽然我不确定 css 应该是什么样子。我知道网上有很多关于 html 按钮的教程,但我不确定半矩形按钮。谢谢,哈里森
【问题讨论】:
使用边框半径。该示例中的确切代码是border-radius: 4px;
https://developer.mozilla.org/en-US/docs/CSS/border-radius
遵循 Jake 的好建议,使用这个包罗万象的浏览器规则:
button#join {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
【讨论】:
input[type='button']{border-radius:4px;}
-moz-border-radius:4px; 和 -webkit-border-radius:4px; 以在所有浏览器上工作。
border-radius) 应该出现在特定于供应商的版本之后。此外,-webkit-border-radius 通常不再需要。最后,特定于供应商的前缀应以 - 开头。
试试:
<button class="button" id="join">Join</button>
CSS:
.button {
/*adjust the roundness*/
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
/*adjust height and width*/
height: 20px;
width: 20px;
/*change border colour*/
border:1px #245ec6 solid;
}
调整边框半径属性的像素数量,以改变它的圆角程度。
编辑:显然您发布的网站使用 4px(代码调整)
第二次编辑:对代码进行调整以制作更大的按钮并影响所有按钮。
【讨论】:
input[type='button']{border-radius: 4px; moz-border-radius: 4px; webkit-border-radius: 4px;height: enter_height_here; width: enter_width_here;}
input[type='button']{}' or button{}`。使代码更干净
这里有一些关于边界半径的信息:http://www.css3.info/preview/rounded-border/
这是一个很酷的小生成器,可以让事情变得简单:http://border-radius.com/
【讨论】: