Submit Your Article Forum Rules

Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Custom CSS links

  1. #1
    Senior Member grease's Avatar
    Join Date
    Aug 2003
    Posts
    323

    Custom CSS links

    Hi,
    I have my basic SSL site link settings set up: a:link,a:visited,a:active:,and a:hover
    They all seem to work fine.
    The problem is, I want a unique look for a navigation area at the bottom of my page.
    To create this area I made the following test style:


    .navbar {
    font-size: 24px;
    text-align: center;
    text-decoration: underline overline line-through;
    color: #666600;
    font-weight: bold;
    }

    It seems that all of the settings (overline,line-through,font size,etc) override the standard link settings....except for color and underline - the only two I really want to change. How can I fix this?
    P.S. I am using an external CSS style sheet, if that makes any difference.

    I am new to CSS and appreciate any help I can get!
    Thanks,

    Grease
    http://www.flamedesign.ca


    Logo,Web,Print,Advertising

  2. #2
    Senior Member sijpie's Avatar
    Join Date
    Sep 2003
    Posts
    105
    I think you should use an additional set of css stements here like this:

    a.navbar:hover {....}
    a.navbar:link {...}
    etc.

    This specifies the properties of the link behaviour in the navbar class.

    (I'm not the guru you're taking me for, feeling my way around css land as much as the next guy!)
    Jaap

    PalmVenue
    Broekhuizen Paintings
    MacSijp

    You've done it all
    You've broken every code (Steve Harley)

  3. #3
    Senior Member
    Join Date
    Jul 2003
    Posts
    1,332
    Grease, if you are going to use CSS & want to have different link formats, its a good idea to name each link class. Having a generic class like a:hover, etc, usually over rides any other formatting of links. If you use the same style sheet for the whole site, there is bound to be situations where you dont want the same link formatting.
    [url returns 404 - removed by mod 07/11]
    It' time for Progressive Web & IT Development!

  4. #4
    Junior Member
    Join Date
    Feb 2004
    Posts
    3
    Quote Originally Posted by sijpie
    I think you should use an additional set of css stements here like this:
    a.navbar:hover {....}
    a.navbar:link {...}
    Adding class="navbar" to every A tag would be superfluous since he's already identified those links as navbar links by placing them in the div (or td) with class="navbar". Your mark up should be something like:

    <div class="navbar">
    <ul>[*]Item 1[*]Item 2[*]Item 2[/list]
    </div>

    And then your style sheets would read something like this:

    .navbar a { ... }
    .navbar a:link { ... }
    .navbar a:visited { ... }
    .navbar a:hover { ... }
    .navbar a:active { ... }

    (If you don't want them to be underlined, you only need the text-decaration style in the first selector (.navbar a), it doesn't need to be in every one.)

    If you 'd like to see how to style the nav bar with it being a UL instead of in a table, you can look at an example I set up for someone on the css-d mailing list at http://fluidmind.org/test/css/centeredlist.html

    Cheers
    --Dan

  5. #5
    Senior Member netman4ttm's Avatar
    Join Date
    Aug 2003
    Posts
    350
    "The future is here. It's just not evenly distributed.

  6. #6
    Here's a link to some css 'toys' that sre so interesting it makes learning easy.

    http://theimposter.org/cascade/

  7. #7
    Senior Member paulhiles's Avatar
    Join Date
    Jul 2003
    Posts
    2,073
    The link behaviour that you're describing can be achieved by using pseudo-classes for your link selectors. The number of CSS statements depends on exactly how you want your 'navbar' links to appear and behave. See the following page from the Style Master site.

  8. #8
    Senior Member grease's Avatar
    Join Date
    Aug 2003
    Posts
    323

    Div Problems

    Thank you all for your helpful advice!
    I can finally make seperate links colors and styles.
    I am still have a problem with the DIV command that you recommended danfluidmind.

    When I use the following, it will format everything but the color:

    Code:
    <div class="top">
    Item1
    Item2
    Item2
    </div>
    When I do this, I can get the proper look, but seems to be very redundent:

    Code:
    Item1
    Item1
    Item1
    Why does the DIV only handle certain formatting?

    Thanks again,

    Grease
    http://www.flamedesign.ca


    Logo,Web,Print,Advertising

  9. #9
    Junior Member
    Join Date
    Feb 2004
    Posts
    3

    Re: Div Problems

    Quote Originally Posted by grease
    When I do this, I can get the proper look, but seems to be very redundent:
    Item1
    Item1
    Item1
    Redundent indeed, especially if you have a lot of links. I'd have to see your style sheets to see why you're not getting the color, but try this:

    Code:
    <div class="top">
    Item 1
    Item 2
    Item 3
    </div>
    Then your style sheets would be something like this (you replace with the correct colors for your design):

    Code:
    div.top {
        background: #000000;  /* bgcolor of whole area */
        text-align: center;
    }
    div.top a, div.top a:link {
        text-decoration: none;
        color: #111111;
        padding: 0.5em 1em;
    }
    div.top a:visited {
        color: #222222;
    }
    div.top a:active {
        color: #333333;
    }
    div.top a:hover {
        color: #444444;
    }
    So the A tags are selected in relation to the "top" DIV. Those selectors basically say: "apply these styles to A tags that appear anywhere within a DIV tag of class 'top'."

    Again, if take a look at that example I gave you the link to in my previous post and look at the source code for it.

    --Dan

  10. #10
    Senior Member cooper's Avatar
    Join Date
    Jul 2003
    Posts
    132

    CSS for navigation

    depending on how you want your lower navigation to look, and how much CSS you want to write you might want to consider using ID's and classes to get the effect you are going for. This works especially well for location sensitive styling.

    First, I think that Dan had the best HTML:
    Code:
    <ul>[*]Item 1 [*]Item 2 [*]Item 3 [/list]
    and I would add to that a descriptive class or ID for the ul tag:
    Code:
    <ul id="bnav">[*]Item 1 [*]Item 2 [*]Item 3 [/list]
    ID's are best for applying specific styles to only one element (and its child elements), where classes can be applied to multiple elements, in a document.

    So the CSS can be applied as:

    ul#bnav {list-style:none;}
    #bnav li a {text-decoration:none;}
    #bnav li a:link {color:#00F;}
    #bnav li a:visited {color:#888;}
    #bnav li a:hover {color:#F00;}
    #bnav li a:active {color:#0F0;}

    (Those three character hex colors are shorthand.)
    Obviously you can adjust the styles as needed. One more thing, in order for links to function properly with all browsers, make sure to order your psuedo-classes in the above order (link, visited, hover, active). Someone more clever than I got me to remember it this way: LoVe, HA! (kind of a cynic, I know)

    The redundancy you wrote about is covered by applying the style to one parent element to control those pesky children! That's the Cascading part of CSS.

    BTW - Flame, assuming you are using the web site to post your replies, you can edit your posts and use the "Code" button to allow HTML tags to be shown.

Page 1 of 2 12 LastLast

Similar Threads

  1. Custom 404 page
    By FabianSnr in forum Web Programming Discussion Forum
    Replies: 19
    Last Post: 01-25-2010, 12:06 PM
  2. Custom IE Toolbar Development, Custom Firefox Toolbar Development
    By pankaj.sharma in forum Services for Sale/Hire
    Replies: 3
    Last Post: 08-06-2008, 02:13 AM
  3. Custom Shapes
    By WPW_Feedbot in forum Graphics & Design Discussion Forum
    Replies: 0
    Last Post: 03-11-2005, 12:30 AM
  4. Validating a Custom DTD
    By WPW_Feedbot in forum Graphics & Design Discussion Forum
    Replies: 0
    Last Post: 03-08-2005, 05:39 PM
  5. Links wanted for Custom Clothing Designer (bridal, grad )
    By love2travel in forum Marketing Strategies Discussion Forum
    Replies: 3
    Last Post: 02-16-2004, 03:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •