Reset Styles for input elements and restyling to bring back the default appearance

前端 未结 2 619
無奈伤痛
無奈伤痛 2021-01-19 03:44

I have a simple input field.



        
相关标签:
2条回答
  • 2021-01-19 04:37

    Short answer is change

    border: 1px inset #F0F0F0;

    to

    border: 1px solid #A9A9A9;


    Long Answer

    I feel there is a better answer to the problem that the OP had in their fiddle.

    The problem was with their use of inset instead of solid.

    Here is the original js Fiddle code:

    input
    {
        padding: 0;
        margin: 0;
    }
    
    input[name="1"]
    {
        margin: 10px;
    }
    
    input[name="2"]
    {
        border: none;
        border: 0;
        border: 1px inset #F0F0F0;
    }
    <input name="1" onfocus="this.value=''" type="text" size="20" value="input 1" title="Enter your search here" />
    <input name="2" onfocus="this.value=''" type="text" size="20" value="input 2" title="Enter your search here" />

    Here is the fix that I believe the OP was looking for:

    input
    {
        padding: 0;
        margin: 0;
    }
    
    input[name="1"]
    {
        margin: 10px;
    }
    
    input[name="2"]
    {
        border: 1px solid #A9A9A9;
    }
    <input name="1" onfocus="this.value=''" type="text" size="20" value="input 1" title="Enter your search here" />
    <input name="2" onfocus="this.value=''" type="text" size="20" value="input 2" title="Enter your search here" />

    All I changed was the

    input[name="2"]
    {
        border: none;
        border: 0;
        border: 1px inset #F0F0F0;
    }
    

    to

    input[name="2"]
    {
        border: 1px solid #A9A9A9;
    }
    

    There is no need to set border to none then set it to 0 and then set it to your desired settings. The only reason to do this would to be if there were different fallback options necessary for different browsers. But as far as I know all browsers that should be considered support the basic border property with the shorthand above. As for the actual settings that I changed, the inset gives you that old 3D-ish looking cut in look and the color was too close to the jsFiddle background plus this color looks closer to the default I see in most browsers.

    0 讨论(0)
  • 2021-01-19 04:46

    You can't get the default styles back once you change them. If you want to normalize the margins and padding across browsers, just normalize the margins and padding and don't touch any of the other styles, especially border and background.

    0 讨论(0)
提交回复
热议问题