CSS - Dif Coloured Links For Different Ids Or Classes?
Right, say i've got a css file:
Code: a { color: red; } and thats the universal code for any tag starting with <a anyway I want to be able to have a different coloured link in a certain id or class, how do I do this? I tried things like Code: #id { whatever } #id:a { color: blue; } Now Im pretty sure that doesnt work, any help will be appreciated Similar TutorialsHiya. I've got a bunch of javascript links which I want to be part of a css class. the problem is because the links are nulled for the javascript (i.e. <a href="#" onClick= etc etc.>) they are not responding to the class declarations (e.g. a.nav:hover { color: #414f63; text-decoration: none; } has no effect). If i remove the null href value, then the css works, but, of course, the javascript doesn't. any ideas? thanks, _e. I'm having a problem with my links becoming deactive within some nested elements. I followed some instruction on creating rounded corner boxes via a tutorial by Andy Budd. Anyway, it all works great except when I wrap link tags around a few pieces of copy. I'm a bit of a beginner still so maybe this is a simple fix but I've spent over a days worth of time now trying to figure it out on my own and can't seem to get it. Just to clear this up, the links work everywhere on the page outside of the "box" element I'll list below and I've double and triple checked that the link within the "box" element is written correctly and it is. The CSS even finds the link and styles it correctly, however, the mouse function seems to be disabled. Does this all make sense? Below is the CSS, any help would be greatly appreciated... This is the code that creates the box and it works correctly... Code: .box { width:831px; background:url(../imgs/box-spacer.gif) repeat-y; } .box h1 { background:url(../imgs/box-top.gif) no-repeat left top; padding-top:40px; font-weight: normal; } .box .last { background:url(../imgs/box-bottom.gif) no-repeat left bottom; padding-bottom:60px; } .box h1, .box p { padding-left:60px; padding-right:60px; } And this is the code I used to test that the page is seeing it as a link... Code: .box h1 a:link { color:#00CCFF; } .box h1 a:hover { color: #FF0066; } It changes the color correctly but the hover doesn't work and if you click, it doesn't link you anywhere. Again, the link is written correctly on the page. Can anyone help please? I appreciate it. Hello all Does anyone know how / if it's possible to create a gradated background colour for a series of dropdown menus? hi, i worked pretty hard yesterday and finally my website works in firefox and internet explorer. for some reason, though, in internet explorer, the scrollbars on the index page are not showing up as coloured, even though it's specified in style.css and newsstyle.css . can anyone tell why i'm getting grey scrollbars, even in IE ? http://www.formone.net . Thanks. Simple question, but i'm trying to create a decent sized space in between my links, and make them white. I can make my links white, but can't seem to change the space inbetween them. HTML Code: div id="bar-links"> <center> <div class="content box1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="4"><img src="images/barlist_01.gif" width="500" height="23" alt=""></td> </tr> <tr> <td background="images/barlist_02.gif" width="20"></td> <td background="images/barlist_03.gif" width="456"> </p> <div id="bar-links"> <h4><a href="#" title="Riley's Pub">Riley's Pub</a> <a href="#" title="Ho Down Bar"style="color: #fff">Ho Down Bar</a> <a href="#" title="Depot Square"style="color: #fff">Depot Square Bar</a> <a href="#" title="Egans Pub"style="color: #fff">Egans Pub</a> </h4> </div> </td> <td background="images/barlist_04.gif" width="24"></td> </tr> <tr> <td colspan="4"><img src="images/barlist_05.gif" width="500" height="27" alt=""></td> </tr> </table> </div> CSS Code: #bar-links { text-indent:inherit; text-align:left; } ok here is the question. i have done two websites, i have tested them out in multiple browsers and all seemed fine. When i test them in IE the text runs into to image. I am using div classes to control the image. Any insight on why this is happening would be greatly appreciated and hints or solutions would be more then welcomed. I am banging my head against a will trying to figure this out. Thankyou All I've been trying to clean up my code and in the past I never seemed to make use of predefined html element tags like the H1-H6...and instead I just find that I just make a new class but I was wondering if there is anything wrong with using the H-tags in place of a few classes? Obviously it would have to make logical sense to use, but I'm wondering if there has been any changes in how browsers use those tags in the past few years as I wouldn't want to be using an outdated, soon to be phased out element. heya this doesnt seem to work the second class complety overwrites the first ? id like it to append the second one ? any ideas eg main.css .main-header-back { background-repeat: no-repeat; background-position: 793px 0px; overflow: hidden; } index.php .main-header-back { background-image:url('/images/main/image.gif'); } Hi people, critique this piece of code for a yellowheader and a blue id and tell me what the problem is. It seems both end up as black <style type="text/css"> h3.Big Bird{color:yellow;}/*Class Font#CookieM{color:blue;}/*Id*/ </style> <h3 class="BigBird">Big Bird</h3> <font Id="CookieM">Cookie Monster</Id> Hope to hear from you soon. kaz I cant seem to get my cellpadding working for tables, what do i have to input. I have tried: .header {background:#2D759F; width:100%; cellpadding:5} all the others work, jus the cellpadding which does not. Hello, I am creating a message to display on my web sites. The HTML markup is as follows: <div class="Error"> <h3> <img id="Icon" src="Images/Error_Icon.gif" alt="Icon" style="border-width: 0px;"> <span>Header</span> </h3> <p>Description</p> </div> And the CSS: div.Error { background-color: #FFD9D9; border: solid 1px #FF9595; padding: 0.4em; position: relative; min-height: 1.25em; width: 120px; } div.Error h3 {} div.Error h3 img {vertical-align: middle;} div.Error h3 span {color: #B30000; font: bold 1.0em Georgia, Geneva, sans-serif;} div.Error p {color: #B30000; font: normal 0.8em Arial, Geneva, sans-serif; I have 3 types of messages: Warning, Error and Success. The only difference between the CSS of each message is the colors properties. Should I use a class named Message to define all common properties and then 3 other classes: Error, Warning and success to define the color properties: <div class="Message Error"> Or should I use three different classes? How is this usually done? Any other advice on how I am building my message is welcome to. Thanks, Miguel Hi, This is such a simple thing and it's causing so much grief. For an assignment in our class we are creating a calendar with tables with CSS, and one element in the table (the heading) and certain table data cells themselves must have the same class tag, but they have to do different things to their respective cells. In the heading cells i want a white background and in the other regular cells it must use a jpeg. The regular cells with the jpeg are working fine, but i can't get the buggers up top to go white. Here is my code: Code: td.prev {background-image: url(back.jpg)} td.next {background-image: url(back.jpg)} th.prev {background-color: white} th.prev{background-color: white} Any ideas? thanks in advance. I have a series of image buttons with rollovers that are generated in CSS so I've applied a class to each like this: <a class="homebutton" title="Home" href="#">This is the Home Button</a> This works great but I now would like to apply a second class to the href that calls an animated scroll function from a javascript file. I've tested the function on a simple button and it worked perfect: <a href="#divtwo" class="scroll">Scroll Down</a> What I would like to do is essentially combine the two so that it would be something like: <a class="homebutton" title="Home" href="#divtwo" class="scroll">This is the Home Button</a> But when I do that it ignores the "scroll" class and simply jumps to the #divtwo location on the page without the animation. Ideas on how to have two classes on one button? Any help would be GREATLY appreciated! www. cooperworkskilns.com/kilns.html Two things: The .section classes (images and borders in the middle) are not stretching the width of the parent <div> in IE. Do I have to specify a width with IE? The margin below the images in the .section classes is greater than what it should be. (noticeable when compared to FF) CSS: #subnav { margin: 15px 0px 0px 10px; padding:0px; } .section { width: 51em; border: solid #999999 1px; padding: 10px; margin: 0 0 10px 0; overflow:hidden; text-align:left; } .section img, img a { float: left; border: solid #999999 1px; margin: 0 10px 0 0; } I have a question. If i create a custom class : p.q {color: black !important;} and a user has a css with the fallowing code: p {color: red !important;} will my text <p class="q">My text</p> be red or black and how can i prevent the user css from overriding my css i have <div class="h">this is type 1</div> <div class="h offer">this is type 1 with backgroundA</div> <div class="hd">this is type 2</div> <div class="hd offer">this is type 2 with backgroundB</div> how do I achieve the CSS for accessing only divs with a class of h AND offer? thanks in advance I am very confused how best to define my style sheet for a given goal. Here is what I need to do: I need to have various styles of tables. Some whose text is centered (like the table header), some whose text is left justified. I need to be able to define link colors for each different type of table (i.e. a.link, a.active, etc). I just don't know how to proceed. It seems that I would do something like Code: TD.centered { text-align: center; } TD.left{ text-align: left; } But then I don't know how to define the link colors. Would I have to do something like Code: .centered a:link { color: #000000; } Isn't there a way I can create one selector that contains everything without having to have all these separate entries? Any help is vastly appreciated! Also, I am confused by the use of SPAN. Is this still used? Or is it best to specify the class in the element tag? thanks, brian Hi, I'm trying to use multiple classes: div class="class1 class2". As usual, IE 6 does all but not what you would expect. Please allow me to post a code snippet: Code: <html> <head> <style type="text/css"> .class1 { background-color: red; } .class2 { background-color: green; } .class1.class2 { background-color: yellow; } </style> </head> <body> <div class="class1"> .class1 -- should be red </div> <div class="class1 class2"> .class1.class2 -- should be yellow </div> <div class="class2"> .class2 -- should be green </div> </body> </html> Sadly, the rule for .class1.class2 is also applied to the third div, where it should clearly NOT apply, so it is yellow instead of green. I know that using subclasses "is not safe for IE", as is CSS in general -- but is there a workaround that doesn't force me to abandon the technique? Thank you, answers appreciated! Hi all, I have about 10 different titles on my page. I would like to have 10 different colors for each of these titles. Can this be done without having to create classes for each one of them like: .title_one { color: #ffcc00; } .title_two { color: #cc00aa } and so on... Please advise. Thanks. I have encountered a really annoying bug in IE6 and would be very interested to know if anyone else hase encountered it and found a solution. Look at the following example: PHP Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css" media="screen"> .class1,.class2,.class3 { border: 1px solid black; width:400px; line-height: 100px; text-align: center; } .class1 { background: none; } .class2 { background: red; } .class3 { background: blue; } .class1.class2.class3 { background: black; } </style> </head> <body> <div class="class1">Test Content 1</div> <div class="class2">Test Content 2</div> <div class="class3">Test Content 3</div> <div class="class1 class2 class3">Test Content 4</div> </body> </html> The four divs should all be different colours as follows: div1: transparent/white div2: red div3: blue div4: black However, both divs 3 & 4 are black. The rule: .class1.class2.class3 { background: black; } is incorrectly effecting divs with only .class3. Any ideas? |