div类和跨度内的CSS类IMG

前端之家收集整理的这篇文章主要介绍了div类和跨度内的CSS类IMG前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_1@嗨,开始我有这样的代码
<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”.

W3C Reference

原文链接:https://www.f2er.com/css/216065.html

猜你在找的CSS相关文章