Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Position of search cancel button in Safari 7

Tags:

html

css

safari

I have a input[type=search] and gave it some padding.
In Safari 7 (mavericks at least) the search cancel button gets cutoff. How can I correct this?

I've been trying with the ::-webkit-search-cancel-button selector and box-sizing, but no luck.

enter image description here

jsFiddle: http://jsfiddle.net/hjtkarLc/

The jsFiddle setup:

CSS

input {
    float: left;
    clear: both;
    margin: 1em;
}
input[type="search"] {
    -webkit-appearance: none;
}
#withPadding {
    padding: 0.7em;
}

HTML

<input type="search" value="I'm ok" />
<input type="search" id="withPadding" value="I'm cutoff" />
like image 513
Sergio Avatar asked Mar 19 '23 00:03

Sergio


2 Answers

Adding a z-index to the input[type="search"]::-webkit-search-cancel-button and then adjusting the padding-right worked for me.

Now it works properly in Chrome AND Safari.

jsfiddle: http://jsfiddle.net/celeryclub/u8mhs7aj/1/

like image 159
Cat Gelinas Avatar answered Mar 26 '23 02:03

Cat Gelinas


The solution at your problem might be to apply an extra padding only to the cancel button, something like this:

input[type="search"]::-webkit-search-cancel-button{
    padding-right:30px;
}

You said that you tried with -webkit-search-cancel-button, but in your jsFiddle is not implemented, so I gave you this hint.

like image 26
Gianmarco Avatar answered Mar 26 '23 02:03

Gianmarco