如何获得这些ID标签以正确设置样式? [英] How do I get these id tags to style properly?

查看:110
本文介绍了如何获得这些ID标签以正确设置样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个页面,一个关于页面,联系页面等的网站模板。

I have a website template with multiple pages, an about page, contact page etc.

在该图片的容器中分配了一个ID标签#subheader每个页面的顶部。因此,它分布在所有页面中。我想更改每一页的照片,因此我复制并粘贴了#id标签的css,并为每张标签稍作更改。而且我希望只更改每个网址,并更改标签名称,以便我可以相应地更改html。

There is an id tag #subheader assigned to the container for the picture at the top of each page. So it is distributed amongst all the pages. I wanted to change the photo for each page, so I copy and pasted the css for the #id tag and changed the tag slightly for each one. And i hoped to just change the url for each one, and the change the tag name so i could change the html accordingly.

问题是,后面的Id标签总是搞砸图像。它将整个结构排除在外。但是,当我将URL分配给原始类时,照片效果很好。

The problem is, the subsequent Id tags always screw up the image. It throws the whole structure out of whack. But the photo acts just fine when i assign the url to the original class.

我在这里想念什么?

  #subheader {
  padding-bottom: 70px;
  background: #222;
  background: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Services.jpg)top fixed;
  background-size: cover;
    background-repeat: no-repeat;

    }

    #subheader2 {
  padding-bottom: 70px;
  background: #222;
  background: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Architect.jpg)top fixed;
  background-size: cover;
    background-repeat: no-repeat;
}

#subheader3 {
  padding-bottom: 70px;
  background: #222;
  background: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Architect.jpg)top fixed;
  background-size: cover;
    background-repeat: no-repeat;
}

#subheader2

原始 #subheader

#subheader2: Original #subheader:

这里是#subheader标记的完整CSS。

Here is the full CSS for the #subheader tag.

    /* subheader */
#subheader {
  padding-bottom: 70px;
  background: #222;
  background: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Services.jpg)top fixed;
  background-size: cover;
    background-repeat: no-repeat;

}

#subheader h1 {
  color: #eceff3;
  text-align: center;
  margin-top: 40px;
  font-size: 32px;
  font-weight: 00;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 2px 2px 2px black;
}
#subheader span {
  letter-spacing: 2px;
  display: inline-block;
  font-size: 15px;
  margin-top: 88px;
  color: #fff;
}
#subheader .subdetail {
  font-size: 11px;
  letter-spacing: 2px;
  text-align: center;
  margin-top: 10px;
  text-transform: uppercase;
  color: #777;
  padding-left:0px !important;
}
#subheader .subdetail li {
  display: inline-block;
  color: #fff;
  margin:0;
  text-shadow: 2px 2px 6px black;
  font-weight: 700;
}
#subheader .subdetail li a {
  color: #ff6600;
}
#subheader .subdetail li.sep {
  margin-right: 20px;
}
/* subheader end */


推荐答案

此:

#subheader {
  padding-bottom: 70px;
  background: #222;
  background: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Services.jpg)top fixed;
  background-size: cover;
  background-repeat: no-repeat;
}

#subheader2 {
  padding-bottom: 70px;
  background: #222;
  background: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Architect.jpg)top fixed;
  background-size: cover;
  background-repeat: no-repeat;
}

#subheader3 {
  padding-bottom: 70px;
  background: #222;
  background: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Architect.jpg)top fixed;
  background-size: cover;
  background-repeat: no-repeat;
}

可以减少为:

.subheader {
  padding-bottom: 70px;
  background-color: #222;
  background-position: top left;
  background-attachment: fixed;
  background-size: cover;
  background-repeat: no-repeat;
}

.subheader.services {
  background-image: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Services.jpg);
}

/* H1s specific to services */
.subheader.services h1 {
  …
}

.subheader.architect {
  background-image: url(file:///Users/Nineborn/Desktop/New%20LW%20Construction%20Site/Architect.jpg);
}

/* H1s specific to architect */
.subheader.architect h1 {
  …
}

HTML

<div class="subheader services">
  <h1>…</h1>
</div>
<div class="subheader architect">
  <h1>…</h1>
</div>

这篇关于如何获得这些ID标签以正确设置样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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