日期:2014-05-17  浏览次数:20625 次

按钮button或submit 宽度的默认CSS控制
新手求教:如何用默认的CSS控制按钮(button&submit)的宽度属性?

------解决方案--------------------
<html>
<head>
<title> 测试 </title>
<style>
.button{
width:200px;
}
</style>
</head>
<body>
<form>
<input class= "button " type= "button " value= "button ">
</form>
</body>
</html>
这样需要指定class或者id
------解决方案--------------------
用button标签
<style>
button{
background:#f0f0f0;
border:1px solid #888;
}
</style>
<button type= "button "> button </button>
<button type= "submit "> submit </button>

或者用expression

<style>
input{
background:expression(this.type== "button "||this.type== "submit "? "#f0f0f0 ": " ");
border:expression(this.type== "button "||this.type== "submit "? "1px solid #888 ": " ");
</style>
<input type= "button " value= "button ">
<input type= "submit " value= "submit ">
------解决方案--------------------
楼上的,要灵活……
你就不会 form.my_form input { width: 50px; background: #CCC; border: 1px solid #999; } 这样设置吗?
这样只对 class= "my_form " 的 form 标签之内的 input 起作用