View Full Version : reusing elements with differant attributes
cpl_hicks
09-14-2005, 07:59 PM
in a external css file i am setting the a element to have specific attributes, but now ive done the site ive realised that the attributes given dont allow one sections links to be shown
i.e.
the background is the same colour as the active a element
im just wondering if its possible to use the same a element but give it differant attributes for the specific section, or will i have to change the colour scheme
cheers
cpl_hicks
harbingerOTV
09-14-2005, 11:32 PM
if you had a page to look at or some code you would get a more specific answer but let's see.
http://www.htmldog.com/
if you write something like:
div {
border: 1px solid #000;
background-color: #666;
}
all your divs in your page will have a black border and a grey background.
What you need are classes and IDs.
if you wrote something like:
div {
border: 1px solid #000;
background-color: #666;
}
div.white {
border: 1px solid #000;
background-color: #fff
}
and in your html:
<div>text</div>
<div class="white">text</div>
the first div will be a blackborder/gray background and the second will be blackborder/white background.
is that the kinda of thing your asking or do you already know all that and are asking something really specific?
cpl_hicks
09-15-2005, 11:15 AM
i know about the classes and id
the css im using for most of the links in the page as below
a{
color: #CC9900;
}
a:visited{
color: white;
text-decoration:none;
}
a:hover{
color:#8B0000 ;
text-decoration: overline underline;
}
a:active{
color: #CC9900;
text-decoration:underline;
}
except on one part of the page where it has to be
a{
color: black;
}
a:visited{
color: white;
text-decoration:none;
}
a:hover{
color:#8B0000 ;
text-decoration: overline underline;
}
a:active{
color: black;
text-decoration:underline;
}
ive tried to put it as a class/id but then it takes the ability to act as a hyperlink away, ive tried putting it inline but then it overrides the external css
ronaldb66
09-15-2005, 12:15 PM
it takes the ability to act as a hyperlink away Whaaaaat?!!
That can't be right!
Again, if you could supply the actual markup and styles it would be less of a guess, but if the links you want to style differently are children of an identifiable enveloping element, it would be a cinch to write some rules to specificly style those links.
cpl_hicks
09-15-2005, 12:22 PM
ive actually worked it out differantly instead of using a solid colour of the specific items that where causing me the problem, ive used a fade from the #CC9900 colour to black, it works out okay now
paulajackson
09-15-2005, 12:23 PM
Have you tried attaching a class name to the a: code in the css?
eg
a.here: link { }
a.here: hover { }
and the html would be
<a class="here" href="where.htm"> </a>
etc
Is that the sort of thing you were after or have I missed something?
Paul
cpl_hicks
09-15-2005, 12:30 PM
Have you tried attaching a class name to the a: code in the css?
eg
a.here: link { }
a.here: hover { }
and the html would be
<a class="here" href="where.htm"> </a>
etc
Is that the sort of thing you were after or have I missed something?
Paul
THANK YOU :thumbsup:
when i put the class names in i was putting them in the wrong place, for some reaons i was putting them before the a instead of after it
loll im so stupid, anyway thanks for the help
@ronaldb66 thats why it wasent working asa hyperlink cause i messed it up
paulajackson
09-15-2005, 12:39 PM
Its a pleasure.
I often pull my hair out over something like that and find that it was just a simple little thing after all.
Cheers
Paul :)
ronaldb66
09-15-2005, 01:07 PM
That's why we always ask for the actual markup and styles used; if you would've supplied them in your first post, this thread would probably be no longer than two. Anyway, good that your problem is solved.
paulajackson
09-15-2005, 02:22 PM
The code I've used in a similar way is:
a.cdborder:link, a.cdborder: visited {border: solid 1px gray;}
a.cdborder:hover {border: solid 1px white;}
html is...
<a class="cdborder" href="octobercd.htm"><img src="october.jpg" width="20%" /></a>
<a class="cdborder" href="cupidcd.htm"><img src="cupid.jpg" width="20%"></a>
This works fine in IE but in Netscape, Opera and Firefox the border doesn't surround the whole image. Instead there's just a small rectangle at the bottom. Anyone know how I can alter the code so it works fine?
The page is at http://www.jacksonline.plus.com/pjtest2/cds.htm
Thanks
Paul
_Aerospace_Eng_
09-15-2005, 07:39 PM
Please don't attempt to hijack a thread by posting your own problem unless its related to the original problem.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.