html - 按钮值属性不采用 css

标签 html css

您好,我需要使用 value 属性在按钮上应用 css。 但它没有采用 css

button[value=Export List to Excel] {
  margin-top: 14px;
  background: red;
}
<button type="submit" id="cp_export_excel" name="cp_export_excel" value="Export List to Excel" class="btn btn-warning form-submit icon-before"><span class="icon glyphicon glyphicon-export" aria-hidden="true"></span> Export List to Excel</button>

我将如何实现这个。我只需要专门使用值属性。有人可以帮忙吗。

最佳答案

您必须将您的值表达式放在引号中,因为您的空格会破坏 CSS 规则匹配:

button[value="Export List to Excel"] {
  margin-top: 14px;
  background: red;
}
<button type="submit" id="cp_export_excel" name="cp_export_excel" value="Export List to Excel" class="btn btn-warning form-submit icon-before"><span class="icon glyphicon glyphicon-export" aria-hidden="true"></span> Export List to Excel</button>

关于html - 按钮值属性不采用 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53007941/

相关文章:

html - 在媒体查询中使用 min 和 max-width 有什么实际区别吗?

php - 在输入框中显示该字段的最后一条记录

javascript - css背景在div高度重置时重复

html - CSS-删除 hr 标签空间不起作用

css如何将一个标题单元格合并到一个单元格中

html - 在 JWPlayer 中将控制栏与视频内容区域分开

javascript - 现场呈现 jquery 工具提示的问题

javascript - 如何定位 svg 图像的一部分

css - 滑动图像高度不一样

html - 如何更改 IE11 中所选选项的背景颜色?