首页 \ 问答 \ CSS伪内容选择器(CSS pseudo content selector)

CSS伪内容选择器(CSS pseudo content selector)

我试图通过它的内容来确定div的风格。 如果内容为“0”,则颜色应为红色,如果不是,则返回通常的颜色。

我发现以前有:contains(value),但不再存在了。 我可以在css中使用替换吗?

提前致谢。


I'm trying to determine the style of a div by going by what is in it. If the content is '0', it should have color: red, and if not, fall back to the usual color.

I've found there used to be :contains(value), but that doesn't exist anymore. Is there any replacement I can use for this in css?

Thanks in advance.


原文:https://stackoverflow.com/questions/17790193
更新时间:2022-09-19 06:09

最满意答案

为每个按钮添加class =“button”:

<input class="button" type="button" id="button0" style="color:black; width:100px; height: 50px" />

add class="button" for each button:

<input class="button" type="button" id="button0" style="color:black; width:100px; height: 50px" />

相关问答

更多
  • 这是一个小代码来完成它: LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); ...
  • 在PrintDocument您可以在DefaultPageSettings对象上设置Margins : Margins margins = new Margins(100,100,100,100); p.DefaultPageSettings.Margins = margins; On the PrintDocument you can set the Margins on the DefaultPageSettings object: Margins margins = new Margins(100, ...
  • jQM CSS中的边距/填充使用单位em而不是像素; 和em基于当前的字体大小。 因此,当缩小font-size时,有效边距也是如此。 您的解决方法是将文本放在按钮内的范围内,然后更改范围的字体大小: .my_menu_btn{ font-size: 0.7em; font-weight: bold; } 这是一个DEMO 您可以将其余C ...
  • 您无法更改边距颜色,但您可以做的是将内容包装在新的线性布局中并更改其背景颜色! 这是一个例子: 顺便说一句,运行应用程序时,按钮上的阴影不会出现。 和代码:
    这是使用样式的完美示例。 样式只是您希望应用于大量对象的一组公共属性。 例如,您可以使用以下代码创建一个名为buttonStyle的样式,这样可以完全按照您的要求执行。 如果您决定要更改边距,只需更改样式即可。 如果您决定为不同尺寸的手机设置不同的边距值,只需创建两种样式,一种用于普通,一种用于大型,如果需要则可以使用更多。