configure "search Cancel" button position in input type=search in Safari 7

Asked

Viewed 708 times

6

I have a input[type=search] with padding. How I want to have the same style in different browsers I used -webkit-appearance: none; but in Safari 7 (Vericks at least) the reset/reset button of the search gets cut. How can I fix this?

I’ve been trying with the dial ::-webkit-search-cancel-button which works for example for the econder (display: none;) but I can’t turn it left anymore...

Suggestions?

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" />

I asked the same question on Soen

1 answer

3


Use the ::-webkit-search-cancel-button, turn his position into absolute, position:absolute and align with the right.

To get his position inside the input, define the position of the element as relative, position:relative and set the text limit within the input with the padding-right.

input {
    float: left;
    clear: both;
    margin: 1em;
}
input[type="search"] {
    position:relative;
    padding-right: 30px;
    -webkit-appearance: none;
}

/* saf3+, chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {

    input[type="search"] {
        position:relative;
        padding-right: 30px;
    }

    ::-webkit-search-cancel-button {   
        right: 10px;
        position:absolute;
    }
}
 
   
#withPadding {
    padding: 0.7em;
}
<input type="search" value="I'm ok" />
<input type="search" id="withPadding" value="I'm cutoff" />

  • Very interesting! Interestingly when I press x I see that the cursor does not change to load, as if the image and the area of the screen that accepts click on x is undone. But adjusting to right: 0px; worked well. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.