p1{&nbsp;&nbsp;</span></li><li class=""><span>color:blue;/*<span class="tag">&lt;</span><span class="tag-name">span</span><span>&nbsp;</span><span class="attribute">style</span><span>=</span><span class="attribute-value">"font-family:"</span><span>;"</span><span class="tag">&gt;</span><span>1</span><span class="tag">&lt;/</span><span class="tag-name">span</span><span class="tag">&gt;</span><span>没加important&nbsp;显示为红色&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li><li class="alt"><span>.p2{&nbsp;&nbsp;</span></li><li class=""><span>color:blue;&nbsp;&nbsp;</span></li><li class="alt"><span>color:red!important;/*2加上了important属性优先级高&nbsp;显示为红色&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li><li class="alt"><span>.p3{&nbsp;&nbsp;</span></li><li class=""><span>color:red!important;&nbsp;&nbsp;</span></li><li class="alt"><span>color:blue;/*3但是这种情况下在ie6一下ie版本会显示为蓝色但是在其他浏览器都显示为红色&nbsp;&nbsp;*/&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li><li class=""><span>/*4为了解决ie6及一下版本的兼容&nbsp;把样式分开写&nbsp;important的优先级高&nbsp;显示为红色&nbsp;*/&nbsp;&nbsp;</span></li><li class="alt"><span>.p4{&nbsp;&nbsp;</span></li><li class=""><span>color:red!important;&nbsp;&nbsp;</span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li><li class=""><span>.p4{&nbsp;&nbsp;</span></li><li class="alt"><span>color:blue;&nbsp;&nbsp;</span></li><li class=""><span>}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li class=""><span><span class="tag">&lt;/</span><span class="tag-name">style</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="tag">&lt;/</span><span class="tag-name">head</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;</span><span class="tag-name">body</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">p</span><span>&nbsp;</span><span class="attribute">class</span><span>=</span><span class="attribute-value">"p1"</span><span class="tag">&gt;</span><span>1没加important</span><span class="tag">&lt;/</span><span class="tag-name">p</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;</span><span class="tag-name">p</span><span>&nbsp;</span><span class="attribute">class</span><span>=</span><span class="attribute-value">"p2"</span><span class="tag">&gt;</span><span>2加了important属性</span><span class="tag">&lt;/</span><span class="tag-name">p</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">p</span><span>&nbsp;</span><span class="attribute">class</span><span>=</span><span class="attribute-value">"p3"</span><span class="tag">&gt;</span><span>3IE6及一下版本识别不出来</span><span class="tag">&lt;/</span><span class="tag-name">p</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;</span><span class="tag-name">p</span><span>&nbsp;</span><span class="attribute">class</span><span>=</span><span class="attribute-value">"p4"</span><span class="tag">&gt;</span><span>4解决ie6及一下版本的兼容问题</span><span class="tag">&lt;/</span><span class="tag-name">p</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="tag">&lt;/</span><span class="tag-name">body</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;/</span><span class="tag-name">html</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li></ol></div><pre class="html" name="code" style="display: none; ">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;style type="text/css"&gt;
.p1{
color:blue;/*&lt;span style="font-family:";"&gt;1&lt;/span&gt;没加important 显示为红色 */
}
}
.p2{
color:blue;
color:red!important;/*2加上了important属性优先级高 显示为红色 */
}
.p3{
color:red!important;
color:blue;/*3但是这种情况下在ie6一下ie版本会显示为蓝色但是在其他浏览器都显示为红色 */

}
/*4为了解决ie6及一下版本的兼容 把样式分开写 important的优先级高 显示为红色 */
.p4{
color:red!important;
}
.p4{
color:blue;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p class="p1"&gt;1没加important&lt;/p&gt;
&lt;p class="p2"&gt;2加了important属性&lt;/p&gt;
&lt;p class="p3"&gt;3IE6及一下版本识别不出来&lt;/p&gt;
&lt;p class="p4"&gt;4解决ie6及一下版本的兼容问题&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre><span>下面是测试结果:</span>
<p><font color="#000000" face="&quot;"><font face="&quot;"><font face="&quot;"><font face="&quot;"><font face="&quot;"><span><span>在ie6<span>显示结果</span></span></span></font></font></font></font></font></p>
<p><br></p>
<p><font color="#000000" face="&quot;"><font face="&quot;"><font face="&quot;"><font face="&quot;"><font face="&quot;"><span><span><span><img src="https://img-blog.csdn.net/20160728144725880?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""></span></span></span></font></font></font></font></font></p>
<p><span>在其他<span>浏览器及ie6以上显示</span></span></p>
<p><span><span><img src="https://img-blog.csdn.net/20160728144845226?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""></span></span><br></p>
<p><font color="#000000" face="&quot;"><font face="&quot;"><font face="&quot;"><font face="&quot;"><font face="&quot;"><span><span><span></span></span><br></span></font></font></font></font></font></p>
<p><font color="#000000" face="&quot;"><font face="&quot;"><font face="&quot;"><span><span><span></span><br></span></span></font><br></font></font></p>
</div>
<script type="text/javascript">
$(function () {

Prev | Next
Pg.: 1 ... 13 14 15 16 17 18 19 20 21 22 23


Back to home | File page

Subscribe | Register | Login | N