Forgotten how to get a child element optimised in CSS.
Lets day I have the headers:
<h1>Welcome</h1>
<h1>Content</h1>
<h1>Summary</h1>
The CSS might be:
.header h1 {margin:0; padding:10px 10px 10px 10px; background:url(../img/header.png) no-repeat; background-position:10px 10px; font-weight:bold; font-size:120%;}
I want to change the background for one of the headers, but retain all the other formatting. I figured that:
<h1>Welcome</h1>
<h1 class="different">Content</h1>
<h1>Summary</h1>
with
.header h1 {margin:0; padding:10px 10px 10px 10px; background:url(../img/header.png) no-repeat; background-position:10px 10px; font-weight:bold; font-size:120%;}
.header h1.different {background:url(../img/header2.png) no-repeat;}
Unfortunately this changes the image, but the position is lost. However:
.header h1.different {background:url(../img/header2.png) no-repeat;background-position:10px 10px;}
...does the trick. Is there a shorter way to do it? I'm trying to minimise the code.



Pages in this thread:
Print Thread
camieabz
