0
<div class="form-group form-group-lg">
    <label class="col-md-2 control-label">{{translation.FIRST_NAME}}:</label>
    <div class="col-md-10 required">
        <input type="text" name="firstName" class="form-control" ng-model="Addressid.nameFirst" ng-minlength="3" placeholder="First Name" required>
        <div ng-messages="rmaForm.firstName.$error">
            <div ng-message="required">
                Please enter your first name
            </div>
        </div>
    </div>
</div> 

css

.required:after { content:" *"; }

Question

I know how to get asterisk after a label, but I want it to be after the Input fields. At the moment it is after the error message in second div. Is this possible with CSS to get it after a input field?

4
  • Possible duplicate - stackoverflow.com/questions/11197671/… Commented May 27, 2015 at 11:55
  • My problem is that there is another div inside the first div, so the asterisk goes after that and I don't want that. So partly this is duplicate, partly not. Commented May 27, 2015 at 11:59
  • That's why I linked it as a possible duplicate. If I'd actually voted to close it it would have been 'gold-badge hammered' and closed. Commented May 27, 2015 at 12:00
  • Sorry, my mistake :) Commented May 27, 2015 at 12:01

3 Answers 3

0

You can do this for example

.required:after {
  content: " *";
  position: absolute;
  top: 30px;
  left: 190px;
}

(demo)

Or you just add a new span after the input and put the asterix in:

<input type="text" name="firstName" class="form-control" ng-model="Addressid.nameFirst" ng-minlength="3" placeholder="First Name" required>
<span class="required-field">*</span>
Sign up to request clarification or add additional context in comments.

1 Comment

Problem with your html approach is that * is displayed in next line
0

What about

.required input:after {
  content: " *";
}

Just realised you can't put an after on an input field. The best way would be a span, which could even be added by javascript on every .required field:

$('.required input').after('<span class="asterisk">*</span>');

This would automate the task, which could come in handy

Comments

0

This is what you wanted DEMO

.required:after {
  content: " *";
  position: absolute;
  top: 0px;
  right: 6px;
}

1 Comment

But in my case there is an another div inside the first one, so this is not working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.