What is the best method to reset the default styling of input[type="text"]:focus in Chrome and Safari?

Recently, I implemented a search feature on this codepen and everything appeared to be working fine in Firefox.

The state currently showing is :focus, with the input[type="reset"] displaying a background image.

HTML

<input type="reset" value="">

CSS

.lab-search-field input[type="reset"] {
  background-color: #fff;
  background-image: url('http://bones-bruxzir.jgallardo.me/assets/img/template/sprite-global.png');
  background-repeat: no-repeat;
  border: none;
  float: right;
  height: 30px;
  width: 30px;
  line-height: 36px;
  vertical-align: middle;
}
.lab-search-field input[type="reset"] { 
  background-position: -70px -280px; }
.lab-search-field input[type="reset"]:hover { 
  background-position: -110px -280px; }

However, in Chrome and Safari, it seems that the input type reset may not be necessary as there is a button that appears to clear the input field.

Chrome

Safari

In addition, I noticed that Chrome adds a border to my input[type="search"] while Safari rounds out the input. Despite setting the CSS class for border: none, only Firefox seems to respect this style.

.lab-search-field input[type="search"] {
  font-size: 23px;
  line-height: 36px;
  vertical-align:middle;
  width: 240px;
  border:none;
}



EDIT 1:

After some research, I came across How can I get rid of input border in chrome? where the addition of outline: none; helped remove the blue border in Chrome but did not address the issue with the "X".

Answer №1

If you want to remove the reset button feature of webkit, you can use the following CSS code:

input[type="search"] {
    -webkit-appearance: none;
}

::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

This solution has been tested and confirmed to work in Chrome, but its functionality in Safari has not yet been verified.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using jQuery to establish a canvas element and define its dimensions by adjusting its width and height attributes

My attempt at using jQuery to create a canvas element was not quite as expected. Here is the code I tried: var newCanvas = $('<canvas/>',{'width':100,'height':200,'class':'radHuh'}); $(body).append(n ...

Adjust the size of the image file for uploading

I am attempting to restrict the file upload size to 1MB by using this jQuery code snippet : <td><label> Upload image </label> <input type="file" class="upload" name="image" value="<?php echo set_value('image'); ?>" ...

Adjust the size of the Google custom search bar to suit your preferences

I am looking to adjust the height of the Google custom search bar, and while there are various styling options available through the Google custom search editor, none specifically cater to changing the height. Currently, the search bar includes top and bo ...

Time whizzes by too swiftly

After attempting to create an automated slideshow with clickable buttons, I encountered a problem. The slideshow functions properly, but as soon as I click one of the buttons, the slideshow speeds up significantly. This is what I implemented in my attempt ...

Managing text size in HTML email designs

How can I maintain consistent font sizes in HTML EMAILS? The fonts look great on the website, but in my email they appear small and close together. Check out Live Demo I've attached a screenshot of how the email appears to me. Any suggestions on h ...

Experiencing problems with the CSS styles after including the file.php in

I have a main PHP page called index.php where all other PHP files are included using index.php?page=example. These pages are located in a separate folder, as shown below: public_html/index.php public_html/css/style.php public_html/pages/ The index.php fi ...

How can I pass an array object from an HTML form that adheres to a Mongoose schema

I have this HTML form that I'm using to create a new document in my mongo database. The document represents notes given to a teacher based on various criteria. I am storing the notes in an array within the note property, each object containing the aut ...

Utilizing the power of HTML5 drag and drop functionality in conjunction with Angular Material 2's md

When working with Angular Material 2 and attempting to enable reordering of list elements, I encountered an issue where the functionality works perfectly for li-tag but fails with md-list-item. Why is that? Here is a snippet of my template: <md-nav-li ...

I am looking to incorporate a scroll feature into my form, as it is being displayed within a modal that is a separate component

Due to the size of my employee form exceeding the screen capacity, I need to incorporate a scroll property into my modal content. The form contains numerous fields that cannot be modified. Could you assist me in resolving the scrolling issue? Thank you! ...

Trim the edges of a photo and add the Kinetic filter

Currently, I am utilizing Kinetic for image processing purposes. The issue arises when I crop an image and then attempt to convert it to black and white by clicking a button. Unfortunately, the straightforward setFilter function does not seem to work in th ...

A guide to assigning multiple classes to an element in Vue.js depending on the props!

Take a look at my code to grasp the issue. <template> <div class="header" :class="flat ? 'flat' : null" :class="app ? 'app' : null"> </div> </template> <script> export default ...

Two collapsible menus featured in the navigation bar

My navbar is displaying two collapse menus, but when one is active and I open the second one, the collapsed content from the second menu gets added to the end of the first one's content. How can I close the other menu when opening the second one? h ...

Navigating to a precise location on initial page load using Angular 11

Within the structure of my app, I have a parent component that displays a large image from a child component. When the parent component loads, I want the browser window to automatically scroll to a specific position in order to center the image. Currently ...

Mastering the CSS Art of Working with Sprite Images and Their Positioning

I am currently working on an educational project as a front-end developer, where I aim to clone the Google homepage. To achieve this, I am utilizing Google's own sprite and here is the image of the sprite that I am using. https://i.stack.imgur.com/YT ...

Is it possible to impose dimensions on a content-editable div?

Is there a way to make a content editable div act like a text box with a fixed horizontal width and unlimited vertical expansion? Take a look at this jsfiddle, and find the code below: http://jsfiddle.net/seoj7cgq/ <!--How do I force the text to stay ...

Tips for automatically floating elements to the right or left

I am currently working on a page that displays orders dynamically generated by Flask when a customer places an order. https://i.sstatic.net/W8f1s.png When clicking to expand an order, everything works smoothly if the order is on the left side. However, s ...

What are the essential Bootstrap CSS and JavaScript files that need to be connected to our HTML document?

I recently downloaded the most recent version of Bootstrap, which is version 4. Upon extraction, I noticed that it includes two folders: one for CSS and the other for JS. The CSS folder consists of approximately 12 CSS files, while the JS folder contains ...

Discovering text on a webpage and extracting its XPath or CSS using Selenium and Java

Imagine a scenario where there is a page displaying various items on a table that changes in both order and quantity randomly. The task at hand is to locate a specific item labeled "Itemx" by its text, extract its XPath or CSS, and then use it in another ...

What is the best way to display a header element in front of an article element?

I'm struggling with making my header element sticky and appear in front of my article. Modifying the z-index hasn't given me the desired result so far. Is the z-index ineffective when dealing with floating elements? Or is there a workaround to m ...

Utilize a pair of drop-down menus to concurrently filter a data table

I am interested in implementing two select option filters on a datatable at the same time. Currently, they function well when individually selected, but do not work together for filtering by two variables simultaneously. Currently, selecting a second filt ...