html按钮样式
如何向一个按钮添加多个样式…这不起作用html按钮样式,html,button,Html,Button,如何向一个按钮添加多个样式…这不起作用 <button style="background:red", "cursor:pointer">click me</button> 点击我 我试过: style=“背景:红色”,“光标:指针” style=“背景:红色”“光标:指针” style=“背景:红色”style=“光标:指针” 是否可以组合多种样式?使用分离属性并将所有属性放在同一组引号之间: <button style="background:red;
<button style="background:red", "cursor:pointer">click me</button>
点击我
我试过:
style=“背景:红色”,“光标:指针”
style=“背景:红色”“光标:指针”
style=“背景:红色”style=“光标:指针”
是否可以组合多种样式?使用
分离属性代码>并将所有属性放在同一组引号之间:
<button style="background:red; cursor:pointer">click me</button>
您应该真正使用css类,并避免内联设置DOM节点的样式:
<style type="text/css">
.btn {
background-color:red;
cursor:pointer;
}
</style>
<button class="btn">Click me</button>
HTML:
<link rel="stylesheet" href="style.css" />
<button class="btn">Click me</button>
点击我
用分号分隔所有html样式属性-强>
style="background: red; cursor: pointer;"
您应该看看如何正确声明内联样式。。。看看这个:@Dan或如何正确地避免它们…@AlienWebguy-是的,这也是…避免style
属性是一种方法,而不是规则(例如,此页面的源代码有几个style
属性)。这个问题的答案是如何格式化属性,而不是如何完全避免style
属性(这是一种观点)。您的代码也可以工作,但类是一种更整洁的方式。我不知道你能那样做。
<link rel="stylesheet" href="style.css" />
<button class="btn">Click me</button>
style="background: red; cursor: pointer;"