我有一个包含多个页面,关于页面,联系页面等的网站模板。
每页顶部的图片容器都分配了一个ID标签#subheader。因此,它分布在所有页面中。我想更改每页的照片,因此我复制并粘贴了#id标签的css,并为每张标签稍作更改。我希望只更改每个网址,并更改标签名称,以便我可以相应地更改html。
问题在于,后续的ID标记始终会破坏图像。它将整个结构排除在外。但是,当我将URL分配给原始类时,照片效果很好。
我在这里想念什么?
#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
:
这是#subheader标记的完整CSS。
/* 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 */
答案 0 :(得分:0)
此:
#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>