Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webkit css pseudo elements for time field

I've found an interesting post about webkit pseudo elements for inputs here, so I was going to remove the cancel button from input type="time". But by murthy's law exactly this pseudo element is not described anywhere.

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 is no pseudo element for this

input[type="time"]::after
{
    content: "";
    background: #FFF;
    height: 20px;
    width: 10px;
    position: absolute;
    margin: 0 -10px;
}
like image 719
VoVaVc Avatar asked Jun 27 '13 09:06

VoVaVc


People also ask

Can I use a before or after pseudo-element on an input field?

The input element has no content in the CSS view, and so has no :before or :after pseudo content. This is true of many other void or replaced elements.

When would you use the :: before or :: after pseudo-element in your CSS?

The ::before selector inserts something before the content of each selected element(s). Use the content property to specify the content to insert. Use the ::after selector to insert something after the content.

Can I use pseudo elements on input?

Because these pseudo elements are only allowed to be used on container elements. Elements like inputs, images, and any other self closing element can't use pseudo elements because they aren't “container elements”.

What is a pseudo-element give an example of pseudo-element?

A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s). For example, ::first-line can be used to change the font of the first line of a paragraph. Note: In contrast to pseudo-elements, pseudo-classes can be used to style an element based on its state.


2 Answers

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..

like image 139
Gabriele Petrioli Avatar answered Oct 11 '22 06:10

Gabriele Petrioli


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;
}
like image 25
Rob W Avatar answered Oct 11 '22 04:10

Rob W