不同页面的不同css

时间:2013-07-18 05:37:05

标签: css css3

我在Blogger上有一个博客,并有一些小部件。我想知道,与其他页面相比,主页上的窗口小部件显示方式可能不同吗?

例如一个方框

/* on home page, it should appear like this */
#box {
background: green;
width:200px; height:100px;
}

/* on other pages, it should appear like this */
#box {
background: red;
width:200px; height:200px;
}

4 个答案:

答案 0 :(得分:4)

我建议,在你的主页上加上一个ID,

<body id="home">以及其他网页的其他ID

现在CSS更改将是

/* on home page, it should appear like this */
#home #box {
background: green;
width:200px; height:100px;
}

/* on other pages, it should appear like this */
#others #box {
background: red;
width:200px; height:200px;
}

答案 1 :(得分:1)

给身体一个身份

<body id="page">

然后你可以用

识别它
#page #box { 
    .... your CODE
}

我保证这会有效:)

答案 2 :(得分:0)

如果你说的话,你必须把这段代码html代码页放到css代码页中!重要的是它覆盖其他代码

      <style>
             #box {
              background: red !important;
    width:200px !important; 
height:200px !important;
    }    
        </style>

答案 3 :(得分:0)

您无法将不同的样式表应用于页面的不同部分。您有几个选择:

最好的方法是使用类名将页面的不同部分包装在div中: REFER

  <div class='part1'>
    ....
</div>

<div class='part2'>
    ....
</div>

然后在你的part1 CSS中,为每个CSS规则添加前缀“.part1”,并在你的part2 CSS中,为每个CSS规则添加前缀“.part2”。请注意,通过使用类,您可以使用许多不同的“part1”或“part2”div,灵活地划分页面的哪些部分受哪些CSS规则的影响。