Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML元素共享某些样式,某些HTML元素使用CSS添加特定样式_Html_Css_Class - Fatal编程技术网

HTML元素共享某些样式,某些HTML元素使用CSS添加特定样式

HTML元素共享某些样式,某些HTML元素使用CSS添加特定样式,html,css,class,Html,Css,Class,我有多个按钮(输入类型=“提交”)。我想所有的按钮共享相同的风格,除了一个按钮,我需要给宽度和高度作为自动 将类用于公共样式,将id用于特定样式似乎不起作用。您可以像这样选择所有提交按钮: input[type=submit] { /*styles for normal buttons*/ } 要选择单个按钮,最好使用ID: #special_button { /*styles for special button*/ } 确保按照给定的顺序包含样式,以便正确覆盖。尝试以下操

我有多个按钮(输入类型=“提交”)。我想所有的按钮共享相同的风格,除了一个按钮,我需要给宽度和高度作为自动


将类用于公共样式,将id用于特定样式似乎不起作用。

您可以像这样选择所有提交按钮:

input[type=submit] {
    /*styles for normal buttons*/
}
要选择单个按钮,最好使用ID:

#special_button {
    /*styles for special button*/
}
确保按照给定的顺序包含样式,以便正确覆盖。

尝试以下操作: HTML:


请随问题附上相关代码。最好是作为一个你所描述的应该工作,所以请显示一个代码示例。这个答案的问题是,OP想要样式除了一个以外的所有按钮。此答案为所有按钮提供相同的样式。我希望在同一网页中有多个表单(例如登录表单和注册表单)。我希望在一个按钮中添加特定样式。。其余属性可以与其他按钮相同。我不想为所有的按钮写重复的样式。。
<input type='submit' class='one'>
<input type='submit' class='one'>
<input type='submit' class='one'>
<input type='submit' class='one'>
<input type='submit' class='one'>
<input type='submit' class='two one'>
input.one {
    //your style here
}
input.two {
    width: auto;
    height: auto;
}