Select first occurring element after another element(在另一个元素之后选择第一个出现的元素)
问题描述
我在一个页面上有以下 HTML 代码:
<h4>一些文字</h4><p>还有一些文字!</p>在我的 .css 中,我有以下选择器来设置 h4 元素的样式.上面的 HTML 代码只是整个代码的一小部分;有几个 div 更多地包裹在属于 shadowbox 的周围:
#sb-wrapper #sb-wrapper-inner #sb-body #myDiv h4{颜色:#614E43;边距顶部:5px;左边距:6px;}所以,我的 h4 元素具有正确的样式,但我还想在我的 HTML 中设置 p 标记的样式.
这可以通过 CSS 选择器实现吗?如果是,我该怎么做?
#many .more.selectors h4 + p { ... }这称为相邻兄弟选择器.p>
I've got the following HTML code on a page:
<h4>Some text</h4>
<p>
Some more text!
</p>
In my .css I've got the following selector to style the h4 element. The HTML code above is just a small part of the entire code; there are several divs more wrapped around belonging to a shadowbox:
#sb-wrapper #sb-wrapper-inner #sb-body #myDiv h4
{
color : #614E43;
margin-top : 5px;
margin-left : 6px;
}
So, I have the correct style for my h4 element, but I also want to style the p tag in my HTML.
Is this possible with CSS-selectors? And if yes, how can I do this?
#many .more.selectors h4 + p { ... }
This is called the adjacent sibling selector.
这篇关于在另一个元素之后选择第一个出现的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在另一个元素之后选择第一个出现的元素
基础教程推荐
- 在 contenteditable 中精确拖放 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bokeh Div文本对齐 2022-01-01
