简体   繁体   English

当源 HTML 有多个嵌套标签时,如何在 CSS 中添加 select 标签?

[英]How to select <html> tag in CSS when the source HTML has multiple nested <html> tags?

I'm working on making a dark mode for the Kaplan website tests so I don't blind myself studying.我正在为 Kaplan 网站测试制作一个黑暗模式,这样我就不会盲目地学习。

The following HTML code is representative of the structure of the source, and the tag with id="stylish-23" is what's added by a chrome extension to change the page's CSS styling:下面的 HTML 代码代表了源的结构,id="stylish-23" 的标签是由 chrome 扩展添加的,用于更改页面的 CSS 样式:

<html> // html 1
  <html> // html 2
    <html> // html 3
      <html> // html 4
        <div id="divQuestions"> </div> //actual tag I want to change
      </html> // html 4
    </html> // html 3
  </html> // html 2
  <style id="stylish-23" type="text/css">...</style>
</html> // html 1

I put div#divQuestions in the style tag's CSS and it does not appear to have any effect at all.我将div#divQuestions放在样式标签的 CSS 中,它似乎根本没有任何效果。 Due to the nature and limitation of the extension, I'm only able to add CSS to the style tag, and the CSS appears to not be able to select HTML tags (or at least when I do, nothing happens). Due to the nature and limitation of the extension, I'm only able to add CSS to the style tag, and the CSS appears to not be able to select HTML tags (or at least when I do, nothing happens). I've noticed that dragging the style tag into html #4 in developer console will properly apply the CSS.我注意到将样式标签拖到开发人员控制台中的 html #4 将正确应用 CSS。

The element in question's CSS from inspect:有问题的元素 CSS 来自检查: 有问题的元素的 CSS 来自检查

My CSS in the style tag:我在样式标签中的 CSS:

div#divQuestions {
  background: black;
}

Thanks for the help!谢谢您的帮助!

#divQuestions selector works for me if I fix the div's closing tag (or even if I don't, as it turns out):如果我修复了 div 的结束标签(或者即使我没有,结果证明), #divQuestions选择器对我有用:

 <html> <html> <html> <html> <div id="divQuestions"> </div> </html> </html> </html> <style id="stylish-23" type="text/css"> #divQuestions { padding: 48px; background: aliceblue; border: 4px solid blue; } </style> </html>

nth-of-type is a selector that matches the nth element of their "type". nth-of-type是匹配其“类型”的第 n 个元素的选择器。
So, you can do this:所以,你可以这样做:

html:nth-of-type(1)
html:nth-of-type(2)
html:nth-of-type(3)
...

Or, you can do this since you said "multiple nested tags":或者,您可以这样做,因为您说过“多个嵌套标签”:

html
html > html
html > html > html
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 响应式(HTML&CSS):是否可以在HTML的嵌套TAGS中隐藏特定的TAG? - Responsive(HTML & CSS) : Is it possible to HIDE a particular TAG in a nested TAGS in HTML? HTML / CSS:select标签内的浮动选项标签 - HTML/CSS: floating option tags inside select tag 如何使用正则表达式选择可能包含多个空嵌套标签的空HTML标签? - How to select empty HTML tags that may have multiple empty nested tags using regex? 如何使用可在 Firefox 上使用的编解码器规范获取具有多个源标签的 HTML5 视频标签? - How can I get HTML5 video tag with multiple source tags with codec specification working on Firefox? 将多个嵌套DIV居中标记为HTML CSS - Centring Multiple Nested DIVs Within The Body Tags HTML CSS 如何格式化 <select>标签和<form> HTML / CSS中的标签? - How do I format <select> tags and <form> tags in HTML/CSS? 将CSS应用于HTML select标签 - Apply CSS to HTML select tag html select 标签申请 css - html select tag to apply css HTML文件中有多个“ HTML”标签:当类和ID可以相同时,如何分隔CSS规则? - multiple “HTML” tags in HTML file: how to separate CSS rules when classes and id's can be the same? 当文本中存在多个标签时,如何正则表达式将单个 html 标签与内部标签匹配 - How to regex match individual html tag with inner tag when multiple tags exists in text
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM