Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input field in safari browser: border + uppercase text

Tags:

html

css

safari

As the title says, the output of the following code doesn't show as it should on safari browser:

1) Border of input type-search not showing

2) text-transform: uppercase doesn't work.

The rest of browsers show exact output. Refer to the image attached below.

Fiddle

HTML:

<div class="searchLob">
    <input type="search" class="searchInput" placeholder="Search the website"></input>
    <button onclick="Submit();" class="searchInputBtn">Search</button>
</div>

CSS:

.searchLob{
    position: relative;
    display: inline-block;
    }

.searchInput{
    position: relative;
    border: 2px solid #d2d4d8;
    height: 44px;
    padding: 0 10px;
    background-color: #fff;
    width: 200px;
    margin: 2px 0 0 2px;
    float: left;
    text-transform: uppercase;
    }

.searchInputBtn{
    position: relative;
    float: left;
    border: medium none;
    color: #fff;
    cursor: pointer;
    font: 14px 'arial';
    height: 44px;
    margin-left: -4px;
    margin-top: 2px;
    text-decoration: none;
    text-transform: uppercase;
    width: 70px;
    background-color: #6692a7;
    }

.searchInputBtn:hover{
    background-color:#547e92;
    }

textarea:focus, input:focus, select:focus{
    border-color: #cccfd0;
    box-shadow: 0 1px 1px rgba(204, 207, 208, 0.075) inset, 0 0 8px rgba(204, 207, 208, 1);
    outline: 0 none;
    }

I've have also tried the following method:

CSS:

@media screen and (-webkit-min-device-pixel-ratio:0) { 
    /* Safari and Chrome */
    .myClass {
     color:red;
    }

    /* Safari only override */
    ::i-block-chrome,.myClass {
     color:blue;
    }
}

to make it work for safari, but that didn't do anything.

How should i fix:

Other Browsers Vs Safari Browser

?

[I'm using Safari browser version: 5.1.7 (Build:7534.57.2)]

like image 787
CodeMonk Avatar asked Mar 20 '14 14:03

CodeMonk


1 Answers

If you remove all your CSS, and you inspect the element in Safari, you'll notice that there's a lot of CSS being added from the user agent stylesheet - this is the browsers default stylesheet and will vary from browser to browser.

For example, this is some of the default styling that is added to the input:

input[type="search"] {
    -webkit-appearance: searchfield;
    box-sizing: border-box;
}
user agent stylesheet
input, input[type="password"], input[type="search"], isindex {
    -webkit-appearance: textfield;
    padding: 1px;
    background-color: white;
    border: 2px inset;
    -webkit-rtl-ordering: logical;
    -webkit-user-select: text;
    cursor: auto;
}
user agent stylesheet
:focus {
    outline: 5px auto -webkit-focus-ring-color;
}

As mentioned in the blog post - Resetting HTML5 Search Input in Webkit

  • credit to Priyank Sharma

The way to reset the Safari default styling, is to add the following CSS:

/* Reset HTML5 Search Input in Webkit */
input[type=search]::-webkit-search-cancel-button,
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-results-button,
input[type=search]::-webkit-search-results-decoration {
  -webkit-appearance:none;
}
input[type=search] {
  -webkit-appearance:textfield;
  -webkit-box-sizing:content-box;
}

So if you check the Fiddle now - http://jsfiddle.net/Hg2A6/8/ you'll notice that it gets the proper styling

like image 191
Nick R Avatar answered Oct 31 '22 01:10

Nick R