嗨,开始我有这样的代码:
<div class="123_test" tabindex="0" role="button"> <span class=""> <img class="" alt="" src="picturetopic"></img> </span> </div>
如何用123_test类设置这个img的样式?
解决方法
首先你不能用数字开始一个类名,我假设它是从某个地方生成的,因为类是空的,但如果你可以,那么考虑改变它,就像
class="name_123_test"
并使用下面的选择器
.name_123_test > span img { /* Styles goes here */ }
In CSS,identifiers (including element names,classes,and IDs in
selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646
characters U+00A0 and higher,plus the hyphen (-) and the underscore
(_); they cannot start with a digit,two hyphens,or a hyphen followed
by a digit. Identifiers can also contain escaped characters and any
ISO 10646 character as a numeric code (see next item). For instance,
the identifier “B&W?” may be written as “B\&W\?” or “B\26 W\3F”.