我不喜欢默认的按钮样式。它非常无聊。我正在使用
<input type="submit">
我能用CSS样式来改变type为button的按钮吗?如果不行,那我猜就得使用一个div代替这个按钮,并将它设置为超链接。那么如何让它在表单中起作用呢?
通过 CSS,您可以轻松实现所需的效果:
HTML
<input type="submit" name="submit" value="Submit Application" id="submit" />
CSS
:层叠样式表。#submit {
background-color: #ccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius:6px;
color: #fff;
font-family: 'Oswald';
font-size: 20px;
text-decoration: none;
cursor: pointer;
border:none;
}
#submit:hover {
border: none;
background:red;
box-shadow: 0px 0px 1px #777;
}
是的,这很简单:
input[type="submit"]{
background: #fff;
border: 1px solid #000;
text-shadow: 1px 1px 1px #000;
}
我建议给它一个 ID 或类,这样你就可以更容易地针对它进行定位。
是的,您可以使用 input[type=submit]
来针对特定内容进行目标定位,例如:
.myFormClass input[type=submit] {
margin: 10px;
color: white;
background-color: blue;
}
input
元素需要成为具有该类的元素的子元素。我已经在很多项目中使用了这个选择器。你能否创建一个例子并发布一个问题? - Dave Anderson input[type=button]
{
//Change the style as you like
}
你可能想要添加:
-webkit-appearance: none;
将以下样式写入同一HTML文件的头部,或者写入一个.css文件中
<style type="text/css">
.submit input
{
color: #000;
background: #ffa20f;
border: 2px outset #d7b9c9
}
</style>
<input type="submit" class="submit"/>
.submit - 在 CSS 中表示类,因此我创建了一个具有一组属性的 submit 类,并将该类应用于 submit 标签,使用 class 属性