1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Rounded corners in CSS

Discussion in 'HTML & Website Design' started by Cazman, Jul 30, 2009.

  1. #1
    I'm trying to create some tabs for this website, and I want the two bottom corners to be rounded, so I thought I'd create two divs, assign a different background image to each, and position them properly. But when I view the result through firefox, I only see one corner of the box when I hover over the link. Does anyone have a solution for this problem? Here's the code:

    HTML:
    <div class = "bg"><div class = "br">
    <ul>
    <li><a href = "link.htm">Contact us</a></li>
    <li><a href = "link.htm">Portfolio</a></li>
    </ul>
    </div></div>
    Code (markup):
    CSS:
    div.br li:hover{
    	background: url(rcurve.png) no-repeat bottom right;}
    	
    div.bg li:hover{
    	background: url(lcurve.png) no-repeat bottom left;}
    Code (markup):
     
    Cazman, Jul 30, 2009 IP
  2. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You don't need the DIVs. Just apply the styles to the list items and anchors directly. The anchors will either need to be floated or given a display: block state and have a height declared either way in order for it to work though.
     
    Dan Schulz, Jul 30, 2009 IP
  3. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    li {
        float: left;
        margin-right: 1em;
        background: url('rcurve.png') right bottom no-repeat;
    }
    	
    a {
        display: block;
        background: url('lcurve.png') left bottom no-repeat;
        line-height: 1em;
    }
    .clear {
        clear: both;
    }
    
    Code (markup):
    
    <ul>
        <li><a href="#">Contact us</a></li>
        <li><a href="#">Portfolio</a></li>
    </ul>
    
    <!-- next tag that comes after this will have class="clear" -->
    
    Code (markup):
    Something like this? Eventually you can float both list items and anchors.

    Also, when you want to change the background color on onmousehover, you will either have to add an obtrusive <span> tag inside anchors or use JavaScript.
     
    risoknop, Jul 30, 2009 IP
    Dan Schulz likes this.
  4. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #4
    pretty much, but without the pointless and unnecessary "clearer" class. A couple things though. I'd put padding on the links instead of the margin on the LIs, and set the line-height on the anchors to be the same as the list itself. It works FAR far better cross-browser that way. Oh, and JavaScript is NOT necessary for this.
     
    Dan Schulz, Jul 30, 2009 IP
  5. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If he wants the rounded corners to change color on onmoushover then yes, either JavaScript or adding <span> tags inside anchors. I don't know about any other way (unless the anchors are fixed width, of course).
     
    risoknop, Jul 30, 2009 IP
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well, my mom's funeral is Saturday and I still have a lot of house cleaning to do (my brother is coming in from out of state for the funeral), so I won't be able to show you how it's done until Monday at the earliest.

    But it IS possible.
     
    Dan Schulz, Jul 30, 2009 IP
  7. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'm sorry to hear that.

    Take your time and if you feel like posting here again in week or two I would like to see how it's done without JavaScript.
     
    risoknop, Jul 30, 2009 IP
  8. Cazman

    Cazman Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    what I would like is for the rounded corners to be visible with a same colour background on hover. Thanks for the help guys, it worked great without hover, I'll try my best to make it work with hover.
     
    Cazman, Jul 31, 2009 IP
  9. Tarkan

    Tarkan Peon

    Messages:
    491
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Tarkan, Jul 31, 2009 IP