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"/>
<label for="subdomain">Subdomain:</label>
<input type="text" placeholder="ExampleDomain" id="subdomain" />
<input type="text" id="subdomaintwo" value=".domain.com" disabled/>
input[type="text"]#subdomaintwo{
-webkit-appearance: none!important;
color: red;
text-align: right;
width: 75px;
border: 1px solid gray;
border-left: 0px;
margin: 0 0 0 -7px;
background: white;
}
input[type="text"]#subdomain{
-webkit-appearance: none!important;
border: 1px solid gray;
border-right: 0px;
outline: none;
}
JS Fiddle for this
You can achieve this with the following approach:
<input>
in a <label>
with position:relative
<label>
an ::after
pseudo-element with position:absolute
box-sizing
of the <input>
to border-box
<input>
a padding-right
equal to the width of the ::after
pseudo-elementWorking Example:
label, input {
position: relative;
display: block;
padding-right: 76px;
width: 170px;
box-sizing: border-box;
}
label::after {
content: '.' attr(data-domain);
position: absolute;
top: 4px;
left: 94px;
font-family: arial, helvetica, sans-serif;
font-size: 12px;
display: block;
color: rgba(0, 0, 0, 0.6);
font-weight: bold;
}
<label data-domain="domain.com">
<input type="text" placeholder="exampledomain" />
<label>
The readonly
property should be used:
<label for="subdomain">Subdomain:</label>
<input type="text" placeholder="ExampleDomain" id="subdomain" />
<input type="text" id="subdomaintwo" value=".domain.com" readonly="readonly" />
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 a div
(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'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.
In angular you can do this:
In the html file add placeholder attribute to input with text variable:
<input type="time" class="timepicker" placeholder="{{text_variable}}">
In the css:
.timepicker:before {
content:'.' attr(placeholder);
margin-right:5px;
color:#9d9d9d;
}
I´ve written an span and given it the bootstrap class .form-control, a grey background and filled in that span the static word.
<span class="form-control bg-grey">Exampledomain</span>
But I think, the Answer of nerkn solves it´s best.