another way to create rounded corners for html buttons ?

Discussion in 'CSS' started by prince@life, Jul 31, 2011.

  1. #1
    Today , I have Created a simple tutorial on regarding CSS rounded corners on my rising programming blog. ( http://www.mayurgodhani.in )
    But i don't know that there is another simplest way to do this easier then my suggestion here ? http://goo.gl/oZDk7

    If you know more efficient way then my tutorial then kindly inform me here, so i can update my article asap. :)
     
    prince@life, Jul 31, 2011 IP
  2. xira

    xira Active Member

    Messages:
    315
    Likes Received:
    8
    Best Answers:
    4
    Trophy Points:
    68
    #2
    You forgot to mention that IE7&8 do not support rounded corners and this is CSS3.0, which isn't offically (fully) released or supported by all browsers. There is a google fix for rounded corners for IE, but it can cause problems for list menus.
     
    xira, Aug 1, 2011 IP
  3. prince@life

    prince@life Notable Member

    Messages:
    278
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    225
    #3
    oh....yeah. :)
    This is CSS3.0 but currently it is supported by New versions of Firefox.
    And about Google chrome, IE, Opera :
    If there is any fix , i will try to mention it in post....

    Thanks for Great suggestion :)
     
    prince@life, Aug 1, 2011 IP
  4. mjk19984

    mjk19984 Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, that's a good point about the rounded corners. 
    I tried some CCS3.0 and HTML5 elements recently and it works in the latest versions of Chrome and Firefox. No idea who still uses IE..but yeah, web devs should also think about these people.
     
    mjk19984, Aug 1, 2011 IP
  5. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #5
    Wouldn't another solution be to use an image background on the submit button? Set the width and height to that of your background image, remove the border, and set the line-height to the height so that the text vertically centers (assuming you have set vertical-align to middle). So if you have a 50x20 pixel image you want to use as your background, you could do:

    
    input[type=submit]{
    background: url('images/bg_filename.png') center no-repeat;
    border: 0;
    width: 50px;
    height: 20px;
    line-height: 20px;
    }
    
    Code (markup):
    By the way another 2 quick things:

    • I see you used "-moz-border-radius: 5px 5px 5px 5px;" in your example. It may be worth mentioning that you can shorten that by using "-moz-border-radius: 5px;" instead. Always good to know these things! :)
    • Another thing is maybe you should also include "-webkit-border-radius: 5px;" and "border-radius: 5px;" as well?
     
    Darkhodge, Aug 1, 2011 IP
  6. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #6
    Using images is neither simpler nor easier. Also, you can eliminate the -moz part since FF has supported border-radius since FF4 and intelligent FF users keep their browsers up to date.
     
    drhowarddrfine, Aug 1, 2011 IP
  7. ardianet

    ardianet Member

    Messages:
    494
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    33
    #7
    Well, for me , I rather use image for that kind of round-corner button, it's more 'safe' to apply with other browsers. :)
     
    ardianet, Aug 2, 2011 IP
  8. prince@life

    prince@life Notable Member

    Messages:
    278
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    225
    #8
    @Darkhodge
    Thanks for good suggestions..
    I have updated article on my site :)
     
    prince@life, Aug 2, 2011 IP
  9. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #9
    No problem at all. You forgot to update the code in the "Explanation" section to reflect the change though! :)
     
    Darkhodge, Aug 2, 2011 IP
  10. prince@life

    prince@life Notable Member

    Messages:
    278
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    225
    #10
    dude .. Now I have updated full post.
    Thanks :)
     
    prince@life, Aug 2, 2011 IP
  11. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #11
    How is it more safe? border-radius works in ALL browsers (except IE<9).
     
    drhowarddrfine, Aug 2, 2011 IP
  12. ardianet

    ardianet Member

    Messages:
    494
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    33
    #12
    That's why I said more "safe" (could be rendered with any browser,even on IE , I guess..). :)
     
    ardianet, Aug 2, 2011 IP
  13. getadviced

    getadviced Well-Known Member

    Messages:
    557
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    130
    #13
    We could use ie specific stylesheet which shows image instead of the css3 buttons.
     
    getadviced, Aug 3, 2011 IP
  14. 4under

    4under Greenhorn

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #14
    To take care of IE8 and below, I used "cornerz" java script... Do a google search for it. The "Bullet Proof Curved Corners" should be the first site you see.

    I built a Wordpress Theme using it and it did the job quite well.

    Hope this helps...
     
    4under, Aug 5, 2011 IP
  15. HighRankingSEO

    HighRankingSEO Well-Known Member

    Messages:
    423
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    125
    #15
    You can't really do rounded corners with IE but you can use border-radius property for it with any browser that supports CSS3.
     
    HighRankingSEO, Aug 5, 2011 IP