Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alter input style when text entered using just CSS

Tags:

html

css

I am styling a page where I have only been given access to the CSS files.

I am looking to alter the style of an input element if it's value is not blank.

Here's what I have so far...

<input id="myInput" type="text" name="myInput" autocomplete="off" placeholder="Enter your Card Number">

and

input {
    font-style:italic;  
}

input:not([value='']) {
    font-style:normal;  
}

This doesn't work though as the text is never italicised.

Is it even possible to achieve this taking into consideration I can only edit the CSS file.?

like image 843
Tom Avatar asked Apr 09 '13 15:04

Tom


People also ask

Is used to apply CSS style to the individual input element is used?

The easiest way to select input elements is to use CSS attribute selectors. These selectors will select all the input elements in the document.


1 Answers

Looks like you're using HTML5...if so just edit your PLACEHOLDER tag

::-webkit-input-placeholder {font-style: italic} /*Chrome */
:-moz-placeholder {font-style: italic} /*ff*/
:-ms-input-placeholder {font-style: italic} /*ie latest */

JSFIDDLE:

http://jsfiddle.net/Riskbreaker/wCff9/

like image 95
Riskbreaker Avatar answered Sep 19 '22 22:09

Riskbreaker