对除特定 ID 之外的所有按钮应用 CSS

  • 本文关键字:按钮 应用 CSS ID css
  • 更新时间 :
  • 英文 :


我有一个代码:

button {
background: rgb(1, 81, 227);
background: linear-gradient(
90deg,
rgba(1, 81, 227, 1) 35%,
rgba(0, 90, 255, 1) 100%
);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 4px 2px;
cursor: pointer;
border-radius: 6px;
}

还有大量的按钮。我想将该 css 代码应用于除两个按钮之外的所有按钮,ID 为 startAction 和 endAction。

我该怎么做?

button:not(#startAction):not(#endAction)

按@underscore_d

您的startActionendAction按钮可能共享其中一些样式。

如果是这样,只需将这些共享行保留在通用button声明中,并将其他内容移动到新样式中,然后将其应用于其余按钮。

像...

button {
display: inline-block;
border: none;
color: white;
...
}
.fancybutton {
background: rgb(1, 81, 227);
background: linear-gradient(
90deg,
rgba(1, 81, 227, 1) 35%,
rgba(0, 90, 255, 1) 100%
);
margin: 4px 2px;
...
}

最新更新