webkit css pseudo elements for time field

爷,独闯天下 提交于 2019-12-06 02:58:01

问题


I found an interesting post about webkit pseudo elements for inputs here, so I needed to remove cancel button from input type="time", but by murthy's law exactly this pseudo element not described anywhere. If someone knows please post me.

P.S. I already tryed

::-webkit-search-cancel-button
::-webkit-input-cancel-button 
::-webkit-time-cancel-button
::-webkit-time-cancel-button

Of course there is a way to do this with :after element, but I don't believe there are no pseudo element for this

input[type="time"]::after
{
    content: "";
    background: #FFF;
    height: 20px;
    width: 10px;
    position: absolute;
    margin: 0 -10px;
}

回答1:


That would be ::-webkit-clear-button

So use

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

To find such things you can enable Show Shadow DOM from the console options, under Elements.

This way when you select the input element, you can open it and look under the hood..




回答2:


I knew that Internet Explorer 10 supports such a pseudo-element with ::-ms-clear.
So I searched in the source code of Chromium for "webkit-clear" and discovered the presence of ::-webkit-clear-button.

This JSFiddle shows that the ::-webkit-clear-button pseudo-element has the desired effect.

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


来源:https://stackoverflow.com/questions/17340038/webkit-css-pseudo-elements-for-time-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!