【发布时间】:2014-06-03 01:58:52
【问题描述】:
我有一个文章页面,我正在对其进行小的 CSS 更改,例如边距和字体大小。我的代码必须能够受 Internet Explorer 8 及更高版本的支持。问题是,我使用了一些 IE8 不支持的 CSS 选择器。如何在不使用 :not 选择器的情况下编写 CSS 代码?
示例文章页面的 HTML
<div class="entry">
<h3 class="social-title>Share This Article </h3>
<div class="social-content>
<table>
<td><a href="twitter.com"><img class="" src="twitter.png"><span class="">Twitter</span></a></td>
<td><a href="facebook.com"><img class="" src="facebook.png"><span class="">Twitter</span></a></td>
</table>
</div>
<!-- The article would start here -->
<p class="category_row"><h1 class="category-title>Lifestyle</h1></p>
<p style="margin: 0in 0in 0.0001pt; line-height: 13.5pt; vertical-align: baseline;"><a href="example.com/article.html"><img alt="" style="float: left;" src="example.jpg"></a>Article goes starts here...</p>
<p style="margin: 0in 0in 0.0001pt; line-height: 13.5pt; vertical-align: baseline;">Second paragraph</p>
Third paragraph
</div>
我正在使用的 CSS
.entry p:not(.category_row) {
font-size: 14px;
line-height:22px;
}
img (margin: 10px)
到目前为止,如果我想为文章部分中的图像添加边距,我将如何编写 CSS 代码以便它只影响文章部分中的图像而不影响 <div class="social-content"> 中的图像?不使用 :not?
另外,我将如何编写 CSS 代码来将文章的字体大小更改为 14 像素的字体大小和 22 像素的行高?在不影响上述所有内容的情况下(不在文章部分)?
对不起,如果这令人困惑,但如果需要,我会澄清更多!
【问题讨论】:
-
你反对使用一些javascript来填充支持吗?如果不是...那么您的解决方案是 selectivizr.js - selectivizr.com
-
这里没有javascript。由于我可以访问的代码存在某些限制,我只能使用 CSS。
-
除了通过给这些特定段落一个类并增加特异性来做到这一点之外,没有使用 :not 就没有其他动态解决方案。所以它要么不支持 IE,要么在其中粘贴一个 javascript 库......
-
您的 HTML 似乎格式不正确。您的多个属性值包含不匹配的引号,
p不能包含h1。其中一些错误实际上会干扰您的选择器,因此您首先需要确保您的 HTML 有效。 -
ewww...内联样式...您可以根据需要设置
p标签的样式,然后在.category_row上使用!important以确保这些样式显示为您喜欢的样式。
标签: html css internet-explorer-8 css-selectors