How can I put this static text in an input form?
It's there all the time.
This is my code:
<label for="subdomain">Subdomain:</label>
<input type="text" placeholder="ExampleDomain" id="subdomain"/>
How can I put this static text in an input form?
It's there all the time.
This is my code:
<label for="subdomain">Subdomain:</label>
<input type="text" placeholder="ExampleDomain" id="subdomain"/>
HTML
CSS
JS Fiddle for this
I'm not sure if this can be accomplished using just one input form.
Maybe what you are seeing there is not a single input form, but an input form next to a static text.
So my idea here is to put an input form (where the user can write) followed by a static text (.domain.com). Then you can put both them inside a container and style the container to look like a input form.
This will do the trick.
The
readonly
property should be used:Because disabled controls that do not receive focus and are ignored in tabbing navigation, are not posted. The readonly property only can't be changed by the user.
How about wrapping your
input
inside adiv
(let's call it div.wrapper for ease), and then you can add some text in the div.wrapper with ".domain.com" aligned to the right? Like this for example:<div class="wrapper"> <input type="text" name="subdomain"/> <p class="input-text">.domain.com</p> </div>
You can style your div to make it look like your input and can make sure the actual input has no border, etc., so it's indistinguishable from div.wrapper.
It is a bit of a hack, but why not?
I´ve written an span and given it the bootstrap class .form-control, a grey background and filled in that span the static word.
But I think, the Answer of nerkn solves it´s best.
You can achieve this with the following approach:
<input>
in a<label>
withposition:relative
<label>
an::after
pseudo-element withposition:absolute
box-sizing
of the<input>
toborder-box
<input>
apadding-right
equal to the width of the::after
pseudo-elementWorking Example: