【发布时间】:2011-12-02 00:53:28
【问题描述】:
我正在尝试用按钮元素替换 div 元素以提高可访问性,但我需要按钮来像以前的 div 那样进行布局。 (注意这只需要在 webkit 中工作)
div 占用父容器的宽度,而按钮只占用显示其内容所需的位置。
我该如何改变呢?
我不想设置像 width: 100% 这样的东西,因为如果你在一个容器中使用多个按钮 display: webkit-box div 很好地布局以使用剩余空间。
这是一个小示例:
<!DOCTYPE html>
<html>
<head>
<title>button test</title>
<style>
.mybutton{
display: block;
border: 1px solid red;
-webkit-appearance: none;
-webkit-border-radius: 6px;
background-color: transparent;
-webkit-gradient(linear,left bottom,left top,color-stop(0, #A8ACB9),color-stop(1, #eee));
text-align: center;
}
</style>
</head>
<body>
<div class="mybutton">Div Button</div>
<button class="mybutton">Button</button>
</body>
</html>
【问题讨论】: