最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Remove the arrow that appears for input type="time" for HTML5 - Stack Overflow

programmeradmin5浏览0评论

I am using the default HTML5 sample line of code: I have used a custom background. I want to remove the black arrow that appears on the right.

The image shows a black arrow that appears. Need it remove it. I tried many css tricks but didn't work.

Sample code

I am using the default HTML5 sample line of code: I have used a custom background. I want to remove the black arrow that appears on the right.

The image shows a black arrow that appears. Need it remove it. I tried many css tricks but didn't work.

Sample code

Share Improve this question edited Apr 6, 2017 at 15:35 Ravee S Gohiel asked Apr 6, 2017 at 5:20 Ravee S GohielRavee S Gohiel 791 silver badge4 bronze badges 3
  • 1 Show the HTML structure could be a good start – Jerome Commented Apr 6, 2017 at 5:22
  • Possible duplicate of Select removing dropdown arrow – soorapadman Commented Apr 6, 2017 at 5:31
  • As you edit your post, please remove "Hello Guys", and "Any help appreciated" – Anthon Commented Apr 6, 2017 at 12:43
Add a ment  | 

3 Answers 3

Reset to default 10
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    margin: 0; 
}

or

/* Hide the cancel button */
::-webkit-search-cancel-button { 
    -webkit-appearance: none; 
}

/* Hide the magnifying glass */
::-webkit-search-results-button {
     -webkit-appearance: none; 
}

/* Remove the rounded corners */
input[type=search] { 
    -webkit-appearance: none; 
}

Arrows

input[type="time"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

Clear (x) button

input[type="time"]::-webkit-clear-button {
  -webkit-appearance: none;
}

Just Hide that Arrow

The arrow for <input type="time"> itself — which for example appears on Android — can be removed like this:

input[type="time"] {
  -webkit-appearance: none; // Hide the down arrow
}

Take Full Control

But hiding the arrow will still leave you with an issue: the input renders a blank space on the right side of the input field, and it won't react to different settings of text-align. In order to control these, you need to make further adjustments:

input[type="time"] {
  -webkit-appearance: none; // Hide the down arrow
}

// Android renders the time input as a flex box
// with a left-aligned flex element "webkit-date-and-time-value" for the value.
// It also leaves a blank space of 24px for the down arrow.
input[type="time"]::-webkit-date-and-time-value {
  margin: 0; // By default Android renders this as 1px 24px 1px 1px
  width: 100%; // Let the flex element take the full width of the input
  text-align: center; // Control your text alignment here
}
发布评论

评论列表(0)

  1. 暂无评论