<input type="text" id="reviews_nm" class="input_field" placeholder="Ваше имя*" name="name">
So that the * sign is red?
So that the * si...">
<input type="text" id="reviews_nm" class="input_field" placeholder="Ваше имя*" name="name">
So that the * sign is red?
http://jsfiddle.net/oceog/WddQ8/1/
.place_holder { z-index: 100; left: 10px; cursor: text; position: absolute; top: 1px; left: 5px; width: 100%; display: none; color: lightgrey; } .placeinput input:invalid + .place_holder { display: inline; } /*вся проблема в том, если placeholder больше инпута*/ .placeinput { position: relative; overflow: hidden; } .place_holder span { color: red; }
<label class="placeinput"> <input required="1" type="text" id="text" /> <div class="place_holder">Some text<span>*</span></div> </label> <label class="placeinput"> <input required="1" type="text" id="text" /> <div class="place_holder">другой текст text<span>*</span></div> </label>
here's another version of the truth with the support of browsers I'm not sure, it did not even work through a comma (in fact, it works only in chrome).
something like this
::-webkit-input-placeholder { /* WebKit browsers */ color: #999; } :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #999; } ::-moz-placeholder { /* Mozilla Firefox 19+ */ color: #999; } :-ms-input-placeholder { /* Internet Explorer 10+ */ color: #999; }
$('#text').focus(function () { $('#hint').hide(); }); $('#text').blur(function () { if ($(this).val().trim() === '') { $('#hint').show(); } });
input { width: 200px; } label { z-index: 100; position: relative; left: -200px; cursor: text; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <input type="text" id="text" /> <label for="text" id="hint">Some text<span style="color: red">*</span> </label>
Take a look
Markup
<div class="holder"> <input type="text" /> <label>Some text<span>*</span></label> </div>
Styles
.holder { height: 26px; position: relative; } .holder input, .holder label { position: absolute; top: 0; } .holder input { background: rgba(0, 0, 0, 0); height: 20px; padding-left: 3px; } .holder input:focus { background: #ffffff; } .holder label { height: 26px; left: 5px; line-height: 26px; z-index: -1; } .holder label > span { color: #ff0000; }
Source: https://ru.stackoverflow.com/questions/298676/
All Articles