html - CSS - 在不使用其样式的情况下在另一个样式列表中添加列表

标签 html css list class

好吧,让我解释一下。

这是 HTML:

<ul class="children">
   <li class="bypostauthor">
    This image should have borders:
    <img width="67" height="67" src="http://i.imgur.com/BRUVD7s.jpg">
    <ul class="children">
     <li>
      This should NOT have borders:
      <img width="67" height="67" src="http://i.imgur.com/BRUVD7s.jpg"> 
     </li>
    </ul>
   </li>
</ul>

和 CSS:

.bypostauthor img{
 border:5px solid red;
}

我想为列表类 bypostauthor 中的图像添加边框,而不是列表中的图像。

参见 this fiddle例如。

不幸的是,我无法为图像本身添加一个独特的类。仅到父列表。

最佳答案

变化:

.bypostauthor img{
    border:5px solid red;
}

收件人:

.bypostauthor > img{
    border:5px solid red;
}

参见 Child Selectors

关于html - CSS - 在不使用其样式的情况下在另一个样式列表中添加列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20751059/

相关文章:

html - CSS 如何设置样式以便我可以切换 Bootstrap 导航栏固定顶部上方的另一个菜单?

python - 循环列表时的累积加法

javascript - 查找数组中最近的日期

html - 受所用字体影响的表格布局

javascript - 浏览器在上传到服务器时找不到背景图像?

html - 在 CSS 中的每个字符后插入一个空格

MYSQL:创建可以对每个整数元素使用外键约束的整数(ID)列表?

C# 更改列表中的对象

javascript - 本地镜像的 getImageData 错误

html - 使用 Bootstrap 水平对齐 div