views:

273

answers:

3

I have to design a form with an input inside it. I use background image on the input so it would look like a button. Every time somebody clicks it, it would send $POST, a behavior I want to achieve.

But the problem is about the outline around the form. The outline shows when we click the form. It's minor, but it would be great to make the form (or input) lose the outline.

I test it using Firefox 3.6 and flock. Both of them show the outline behavior that I want to avoid.

<div id="hdrRight">     
    <form name="input"  action="/home.html"  method="post" id="buttonform" >
        <input type="submit" value="" id="gohome" />
    </form>

#----- CSS part #hdrRight { float:left; width:420px; height:30px; padding:0; } form#buttonform{ background-color:transparent; border:none; clear:both; outline:none; } input#gohome{ padding:0; margin:0; background-color:transparent; background-repeat:no-repeat; width:280px; height:60px; border:none; float:right; background-image: url('images/gohome.png'); outline:none; } input#gohome:hover { background-image: url('images/gohome_hover.png'); cursor:pointer; outline:none; }

Can you explain why this is happening and how to hide the outline?

+2  A: 

Insert this in your CSS file for the site

form input
{
    border: none;
    outline: none;
}

And done.

Following Removing The Dotted Ouline:

This is default styling for the purpose of accessibility. For folks without the ability to use a mouse, they still need some visual indicator that they currently have a link active (so, for example, they can press enter to navigate to that link).

After creating a small test page locally, I see the following in Chrome:

Screen shot

With this CSS code (I added the borders so I can see where the form is and where the button is, note that the Lorem Ipsum is inside the form):

#hdrRight {
        float:left; width:420px; 
        height:30px;  
        padding:0; 
        }

    form#buttonform{
        background-color:transparent;
        border:1px solid black;
        clear:both;
        outline:none;
    }

    input#gohome{
        padding:0;
        margin:0;
        background-color:transparent;
        background-repeat:no-repeat;
        width:280px;
        height:60px;
        border:1px solid black;
        float:right;
        background-image: url('images/gohome.png');
        outline:none;
    } 
    input#gohome:hover  {
        background-image: url('images/gohome_hover.png');
        cursor:pointer;
        border: 1px solid blue;
        outline:none;
    }
Josh K
i have done it before. but it's failed. i will change the question
justjoe
@justjoe: A link to the site or at least some CSS and HTML code would go a long way to getting a better answer.
Josh K
@josh : yes i know. but i don;t have any live server. i developed it in my laptop. it's a wordpress themes. btw, thanks josh k. maybe i will try to find it by myself ;D
justjoe
@justjoe: Then just the frontend HTML and CSS.
Josh K
@josh, i have give more information on the question.
justjoe
@justjoe: Updated answer, perhaps your original wording on the question wasn't clear?
Josh K
@josh, your code is not working on me. just my bad luck ;) thanks you by the way. please check @RussellUresti answer
justjoe
+1  A: 

Appy...

border: none;

to your input

Ben Shelock
Nope, you have to hit `border` **and** `outline`. Safari and Chrome will actually have an `outline` property similar to links when they are in the `:active` state.
Josh K
Nope? He's half right. How about, "Safari and Chrome need outline: none too"? And you downvoted him for this?
hobodave
If only we could upvote every half right answer....
Josh K
+1  A: 

Actually, the "outline: none;" only works for anchor tags, not input tags or button tags (please try testing a sample HTML page in Firefox if you don't believe me).

Since the browser in question is Firefox, there is a browser specific rule for this.

input::-moz-focus-inner { border: 0; }
RussellUresti
brilliant. it's working. i have test this in firefox, IE7, flock, safari. thanks you very much.
justjoe
The -moz-focus-inner will only apply to Firefox, unfortunately. Hopefully the "outline: none" values you already have on your input tags will work for the other browsers. I know they work in Chrome, which means they should work in Safari. Haven't tested IE or flock, though.
RussellUresti
i have test it in IE7 and flock and it's work. maybe the 'outline:none' have cover other browser. Because of Firefox is the most popular browser, your solution really help cover majority of user. thank you 1000 times ;)
justjoe
"Firefox is the most popular browser" - I hope that one day this is true for the whole world :-)
Nivas
@Nivas: If it does they are going to have to seriously rewrite the browser. Performance is in the toilet.
Josh K
@Josh Agreed. I almost exclusively use Chrome now. Firefox is just too damn slow now.
RussellUresti