所以,我在输入元素上有一个自定义样式,我想使用 :after
在输入上放置一些文本。
我遇到的问题是我似乎无法更改 :after
元素上的字体粗细,这个问题只发生在 input
的组合中和 :after
元素。
CSS
input[type="checkbox"] { /* enable styling of the checkbox ! */
-moz-appearance: none;
-webkit-appearance: none;
}
input { /* set up some basic styles.... */
background-color:#ccc;
width:200px;
height:200px;
background-color:grey;
}
input:after { /* and we create the :after element */
width:100%;
text-align:center;
font-weight:100; /* THIS DOESN'T WORK FOR SOME REASON */
content: "This should be thin"; /* some text */
}
JSFIDDLE
已测试
Mac 版 Chrome(最新)
问题
为什么我不能在 :after
元素上设置字体粗细?input
元素?
最佳答案
这里已经回答了。似乎 :after 仅用于附加到容器标签。 Can I use the :after pseudo-element on an input field?
关于html - 无法在 :after pseudo-element used on <input> elements 上设置字体粗细,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18149845/