停止在代码的特定部分应用 CSS 样式 [英] Stop CSS styles to be applied in particular sections of the code

查看:17
本文介绍了停止在代码的特定部分应用 CSS 样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能听起来有点奇怪/新手/愚蠢.请多多包涵.

This question may sound a bit weird/novice/stupid. Please bear with me.

以下代码是我使用 CSS 创建的网页的一小部分,HTML 和冷融合.

The below code is a small portion of a webpage I have created using CSS, HTML and coldfusion.

        <head>
    ---------------------Part 1--------------------------------------
    <CFIF CompareNoCase('#aid#', 0)>   
                <cfinclude template="show.cfm">
        <cfabort>
    </CFIF>
    -----------------------------------------------------------------

    <link rel="stylesheet" href="styles/style.css?1322665623">
        </head>
---------------------------PART 2------------------------------------
<body id="wp-home">
<div id="wrapper">
  <div class="header left">
    <h1><a href="index.cfm" class="right logo">Name Of Client</a></h1>
    <div class="tagline">
      <span class="left blair"><a href="index.cfm" class="homelink">home</a></span>
      <span class="headerline"></span>
      <span class="right blair"><a href="index.cfm" class="homelink">antiques</a></span>
    </div>
  </div>
 --------------------------------------------------------------------

如您所见,我包含了一个 css 文件 style.css,其中包含正确显示第 2 部分所需的所有样式类.

As you see, I have included a css file, style.css which contains all the style classes required to display PART 2 correctly.

问题是,只要第 1 部分处于活动状态(为真),相同css 也适用于文件 SHOW.CFM 中的元素.这完全打乱了页面的原始显示.

Problem is, whenever part 1 is active ( is true), the same css is applied to elements in file SHOW.CFM also. This totally messes up the page's original display.

我暂时在链接下方放置了一个标签,以阻止页面处理和加载 css 文件.

For the time being I have placed a tag below the link to stop page from processing and the css file being loaded.

我已经多次检查 show.css 并且可以确认其中没有使用来自 styles.css 的类.

I have checked show.css multiple times and can confirm that no class from styles.css is used in it.

因此,我的问题是我是否可以停止 style.css 中的样式应用于从 SHOW.CFM 加载的元素

Hence, my question is if I can stop the styles from style.css to be applied on elements loaded from SHOW.CFM

如果这个问题非常愚蠢,请原谅我;)

Pardon me if the question is insanely stupid ;)

推荐答案

如果选择器匹配,则规则应用,直到被级联更下方的规则(设置相同属性)覆盖.

If a selector matches then a rule will apply until overridden by a rule (which sets the same property) further down the cascade.

您可以更改选择器以阻止它们匹配您不希望它们匹配的元素,或者您可以覆盖该部分中的所有规则.

You can either change your selectors to stop them matching the elements you don't want them to match, or you can override all your rules in that section.

这篇关于停止在代码的特定部分应用 CSS 样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆