Results 1 to 8 of 8

Thread: rendering problem with custom buttons on firefox =(

  1. #1
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default rendering problem with custom buttons on firefox =(

    hello, i am facing a really nasty firefox bug and cant find the problem in google.
    Firefox basically refuses to middle align the text of a button with a background image, it works fine on any other browser.

    - the buttons have small height.
    - the problem diminishes in ff if you increase the height. (dont want to )

    the culprit: http://img155.imageshack.us/img155/7136/picture4gm3.png
    the css: http://pastie.textmate.org/338918

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    To really help with this, it would be useful to have a link to your page that shows the problem. That would make it relatively easy to experiment using FF's developer extension as to what style(s) might work out best in that browser.

    I have had some experience with this sort of thing though the accommodations to get it to work cross browser can be quite complex, depending upon how everything is supposed to line up.

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    To really help with this, it would be useful to have a link to your page that shows the problem. That would make it relatively easy to experiment using FF's developer extension as to what style(s) might work out best in that browser.

    I have had some experience with this sort of thing though the accommodations to get it to work cross browser can be quite complex, depending upon how everything is supposed to line up.

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    Thanks for the help, my site isnt online yet but i could perfectly replicate the problem in this small css fragment:

    <style type="text/css" media="screen">
    .mybutton {
    color:green;
    border: 1px solid red;
    height: 17px;
    line-height: 10px;
    font-family: Comic Sans MS;
    }
    </style>

    <a href="#">asdf</a> <button class="mybutton">Push Me</button> <a href="#">sdfg</a>

    The buttons have the text vertically centered while on firefox the text appears at the bottom of the button.

    I have played tweaking the values, and changing the font, increasing the height decreases the problem in firefox =(

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    it's a value of adjustments. margins, padding, what ever. You can "fake" it by making line-height exactly half of height. (change height to 20px to see what I mean.)
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    changing the padding/margin/line-height does nothing in ff in this case.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I suggest completely rethinking this, as it doesn't line up right in Opera either, and though it looks OK in Safari, there is no button effect (it will not depress when clicked). Even in IE, it looks a bit cramped on the top.

    Custom buttons are best designed using regular (not form) elements. Form elements like inputs, buttons, etc. just do not behave consistently as regards style across browsers.

    Is this part of a form? If so, just use a standard input element of the type button and let the browser decide how to display it. With forms there is no real way to control the precise look of things across browsers. Forms are for gathering data, not artistic presentation. If it isn't part of a form, use a link and and possibly a container for that link. To get the exact effect you want in all browsers may still be tricky or impossible, but you will have much better luck getting it at least acceptable across browsers. I did something like that here:

    http://www.mediajazzbynight.com/
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default

    I just had the same problem, and found this through Google. I got around the problem by putting a SPAN inside the BUTTON and styling that instead (while removing any styles for the BUTTON element).

    I would have gone a different route if I could, but this had to be able to submit a form for users without Javascript enabled, so I was stuck with the BUTTON element.
    My site: FreshCut :)

  8. #8
    Join Date
    Sep 2008
    Location
    Seattle, WA
    Posts
    135
    Thanks
    1
    Thanked 11 Times in 11 Posts

    Default

    Basically your CSS is styling the button or container but not the content.

    <style type="text/css">
    .mybutton {
    border: 1px solid red;
    height: 30px;
    width: 200px;
    text-align: center;
    vertical-align: middle;

    }

    .mybutton a:link {
    font-family: "Comic Sans MS";
    font-size: 14pt;
    text-decoration: none;
    color: green;
    }

    .mybutton a:hover {
    color: red;
    text-decoration: none;
    }

    </style>

    Then place the links in a div class="mybutton" like so:

    <body>
    <div class="mybutton"><a href="#">This is a Test</a></div>
    </body>

    Notice I raised the height to 30px. Your container height needs to be approx. twice the height of your font size.
    Last edited by simcomedia; 02-02-2010 at 04:23 AM.

Bookmarks

Posting Permissions

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