微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

div类和跨度内的CSS类IMG

嗨,开始我有这样的代码
<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.jb51.cc/css/216065.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。