CSS3 : a div on text box - html

I have a textbox with having character limit box on it. What I want is. the text that is to be input should be upto the length of visible part of textbox.
I have tried this code.
.add_caption_div input[type="text"] {
border: thin #dee5e7 solid;
width: 190px;
border-top-left-radius: 0;
border-top-right-radius: 0;
display: inline-block;
float: left;
padding: 7px 12px;
}
.add_caption_div .image_galley_char_limit_div {
display: inline-block;
height: 31px;
width: 50px;
font-size: 9px;
color: #999999;
position: relative;
z-index: 100001;
background:#f6f8f8;
top:-6px;
right:51px;
}
.add_caption_div .form-control:focus {
border: thin #66afe9 solid;
}
.add_caption_div span {
position: relative;
top: 10px;
}
<div class="add_caption_div" >
<input type="text" class="form-control" placeholder="Enter Caption">
<div class="image_galley_char_limit_div text-center">
<span> 0/30</span>
</div>
</div>
When I type input then it goes behind the character_limit_div.
How can I prevent it?
Any help would be great.
Thank You.

.add_caption_div {
position: relative;
width: 190px;
}
.add_caption_div input[type="text"] {
border: thin #dee5e7 solid;
width: 190px;
border-top-left-radius: 0;
border-top-right-radius: 0;
display: inline-block;
float: left;
padding: 7px 12px;
}
.add_caption_div .form-control {
padding-right: 60px !important;
}
.add_caption_div .image_galley_char_limit_div {
display: inline-block;
height: 31px;
width: 50px;
font-size: 9px;
color: #999999;
position: absolute;
z-index: 100001;
top: 1px;
right: -73px;
background:#f6f8f8;
}
.add_caption_div .form-control:focus {
border: thin #66afe9 solid;
}
.add_caption_div span {
position: relative;
top: 10px;
}
<div class="add_caption_div" >
<input type="text" class="form-control" placeholder="Enter Caption">
<div class="image_galley_char_limit_div text-center">
<span> 0/30</span>
</div>
</div>
Is this the same that you are looking for?
Hope this helps.

you can give padding-right for input, something like this:
.add_caption_div input[type="text"] {
border: thin #dee5e7 solid;
width: 190px;
border-top-left-radius: 0;
border-top-right-radius: 0;
display: inline-block;
float: left;
padding: 7px 12px;
}
.add_caption_div .image_galley_char_limit_div {
display: inline-block;
height: 31px;
width: 50px;
font-size: 9px;
color: #999999;
position: relative;
z-index: 100001;
background:#f6f8f8;
top:-6px;
right:51px;
}
.add_caption_div .form-control:focus {
border: thin #66afe9 solid;
}
.add_caption_div span {
position: relative;
top: 10px;
}
.form-control{
padding-right: 70px !important;
}
<div class="add_caption_div" >
<input type="text" class="form-control" placeholder="Enter Caption">
<div class="image_galley_char_limit_div text-center">
<span> 0/30</span>
</div>
</div>

Related

How can you put a line inside a input?

I'm trying to build a input with a line inside of it in the middle. But I don't seem to know how to build it as the line always falls in the bottom but it gets inline with the button's border.
Here is what I've tried so far:
<div>
<input className={styles.replyInput} placeholder='Reply...' />
<div className={styles.grayLine}></div>
</div>
And here is the CSS:
.replyInput {
border: 2px solid #E0E0E0;
border-radius: 10px;
padding: 10px;
outline: none;
width: 100%;
}
.grayLine {
width: 80%;
margin-left: 5%;
position: absolute;
border: 1px solid #E0E0E0;
}
I'm trying to build this with CSS
You can use some approach like this
.mainDiv{
position:relative;
width: 80%;
padding: 2%;
height: 60px;
border: 2px solid #E0E0E0;
border-radius: 8px;
}
.replyInput {
outline: none;
border: none;
width: 100%;
}
.grayLine::after {
position: absolute;
width: 95%;
height: 1px;
content: "";
background: #E0E0E0;
margin-top: 10px;
}
.icons {
margin-top: 20px;
}
<div class='mainDiv'>
<input class='replyInput' placeholder='Reply...' />
<div class='grayLine'></div>
<div class='icons'>Some icons</div>
</div>
.replyInput {
display:block;
border: 2px solid #E0E0E0;
border-radius: 10px;
padding: 10px;
outline: none;
width: 100%;
}
.grayLine {
width: 80%;
top:50%;
position: absolute;
border: 1px solid #E0E0E0;
margin-left:20%;
}
#a{
position:relative;
}
<div id='a'>
<input class='replyInput' placeholder='Reply...' />
<div class='grayLine'></div>
</div>
Use <hr>
fieldset {
padding: 3px 6px;
border-radius: 10px;
border-color: #fefefe;
}
input {
display: inline-block;
width: 90%;
border: 0;
outline: none;
}
hr {
margin: 3px 0;
border-color: #fefefe;
}
menu {
margin: 0 0 0 -40px;
}
button {
border: 0;
background: transparent;
cursor: pointer;
}
.font::before {
content: '\f031';
font-size: smaller;
}
.font::after {
content: '\f031'
}
.contacts::before {
content: '#';
}
.emoticons::before {
content: '\f599'
}
.attach::before {
content: '\f0c6'
}
.send {
float: right
}
.send::before {
content: '\f1d8'
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet">
<fieldset>
<input id='reply' class='component' placeholder='Reply...'>
<hr>
<menu>
<button class='font fa' type='button'></button>
<button class='contacts fa' type='button'></button>
<button class='emoticons fa' type='button'></button>
<button class='attach fa' type='button'></button>
<button class='send fa' type='button' disabled></button>
</menu>
</fieldset>

In Dual Slider HTML component, click inside first element is not recognized in Internet Explorer

I am trying to build a Dual Step Slider using HTML and CSS alone without any JQuery. It is working fine in Chrome and Mozilla, But in IE11, it is not registering the click inside first input element.
I designed the slider by using position:absolute and made two html input sliders on top of each other. In IE, i could click and drag on Second Input Elemenr only.
.slider {
-webkit-appearance: none;
width: 100%;
//height: 10px;
position: absolute;
//background: #f3f3f3;
outline: none;
border-radius: 8px;
}
.slider input {
pointer-events: none;
position: absolute;
overflow: hidden;
left: 25%;
top: 15px;
width: 50%;
outline: none;
height: 18px;
margin: 0;
padding: 0;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 8px;
background: #E6E6E6;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
//border: none;
height: 20px;
width: 20px;
border-radius: 50%;
background: white;
border: 1px solid #3972D6;
margin-top: -4px;
cursor: pointer;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: #e6e6e6;
border: 2px solid #cdcdcd;
pointer-events: all;
position: relative;
z-index: 1;
outline: 0;
}
.slider::-moz-range-thumb {
width: 20px;
height: 20px;
background: #ea4550;
pointer-events: all;
position: relative;
z-index: 10;
-moz-appearance: none;
}
.slider input::-moz-range-track {
position: relative;
z-index: -1;
border: 0;
}
.slider input:last-of-type::-moz-range-track {
-moz-appearance: none;
background: none transparent;
border: 0;
}
.slider input[type="range"]::-moz-focus-outer {
border: 0;
}
.flex-next {
display: flex;
justify-content: flex-start;
}
.dual-slider-container {
position: relative;
width: 100%;
}
.dual-slider-text-left {
position: relative;
bottom: 12px;
right: 8px;
.text-style {
color: #303030;
font-size: 20px;
font-weight: 600;
text-align: right;
}
.text2 {
text-align: right;
font-size: 14px;
}
}
.dual-slider-text-right {
position: relative;
bottom: 12px;
left: 8px;
.text-style {
color: #303030;
font-size: 20px;
font-weight: 600;
text-align: left;
}
.text2 {
text-align: left;
font-size: 14px;
}
}
.pointer {
cursor: pointer;
}
//Internet Explorer Support
input[type=range]::-ms-track {
width: 100%;
height: 8px;
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
background: transparent;
/*leave room for the larger thumb to overflow with a transparent border */
border-color: transparent;
border-width: 6px 0;
/*remove default tick marks*/
color: transparent;
}
#lower::-ms-fill-lower {
background: #E6E6E6;
border-radius: 10px;
}
#lower::-ms-fill-upper {
background: #E6E6E6;
border-radius: 10px;
}
#higher::-ms-fill-lower {
background: transparent;
border-radius: 10px;
}
#higher::-ms-fill-upper {
background: transparent;
border-radius: 10px;
}
input[type=range]::-ms-thumb {
//border: none;
height: 18px;
width: 18px;
border-radius: 50%;
background: white;
border: 1px solid #3972D6;
//cursor: hand;
}
input[type=range]::-ms-tooltip {
display: none;
}
<div style="padding:8px" class="col-12 row m-0">
<div class="dual-slider-text-left col-2 p-0">
<div class="text-style">
{{minValue}}
</div>
<div class="text2">{{minValueText}}</div>
</div>
<div class="col-8 p-0">
<div class="dual-slider-container">
<input (click)="getSliderOneValue($event)" type="range" min="{{minValue}}" max="{{maxValue}}" step="1"
value="{{sliderOneValue}}"
class="slider" [disabled]="disabled" [ngClass]="{'pointer' : !disabled}"
id="lower">
</div>
<div class="dual-slider-container">
<input (click)="getSliderTwoValue($event)" type="range" min="{{minValue}}" max="{{maxValue}}" step="1"
value="{{sliderTwoValue}}"
class="slider" [disabled]="disabled" [ngClass]="{'pointer' : !disabled}"
id="higher">
</div>
</div>
<div class="dual-slider-text-right col-2 p-0">
<div class="text-style">{{maxValue}}</div>
<div class="text2">{{maxValueText}}</div>
</div>
</div>
It seems that you can only reach the second slider if they're lapped in IE. You could use two slides side by side as a workaround. I make a demo and you could refer to it.
body {
min-height: 100px;
}
div {
display: flex;
}
input {
flex: 1 0 0;
min-width: 0;
padding: 0;
}
input::-webkit-slider-thumb {
margin: 0;
padding: 0;
}
output {
display: block;
text-align: center;
margin-top: 3px;
color: gray;
}
<div>
<input id="a" type="range" min="0" max="10" value="0" />
<input id="b" type="range" min="11" max="20" value="20" />
</div>
<output></output>

stop input breaking out of container

I am trying to have some pre-input on my forms and I want the input field to expand to the end of the container div. The problem is the input field seems to expand past the container div due to the length of the pre-input text.
.container {
width: 70%;
}
.input-field {
display: inline-block;
white-space: nowrap;
vertical-align: bottom;
background: #fff;
position: relative;
vertical-align: middle;
width: 100%;
min-width: 16px;
border: 1px solid #ddd;
}
.input-field .addon {
padding-left: 8px;
padding-right: 8px;
padding-top: 2px;
padding-bottom: 2px;
text-align: center;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding-left: 5px;
padding-top: 0;
padding-bottom: 0;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
width: 100%;
}
.input-field:hover {
border: 1px solid #05c9f0;
}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
Another example here: http://codepen.io/anon/pen/wgdErO
If you try the example code, you will note you can click the input box way outside where I want it to end.
Any thoughts on a fix?
Try using the flexbox layout.
.container {
width: 300px;
}
.input-field {
background: #fff;
border: 1px solid #ddd;
display: flex;
align-items: center;
}
.input-field .addon {
padding: 2px 8px;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding: 0 4px;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
flex: 1;
}
.input-field:hover {
border: 1px solid #05c9f0;
}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
<img src="//dummyimage.com/300x50">
Just decrease the input width from 100% to a lower value like 99.7% and that will do the trick:
.container {
width: 70%;
border: 1px solid red;
}
.input-field {
display: inline-block;
white-space: nowrap;
vertical-align: bottom;
background: #fff;
position: relative;
vertical-align: middle;
width: 99.7%;
min-width: 16px;
border: 1px solid #ddd;
}
.input-field .addon {
padding-left: 8px;
padding-right: 8px;
padding-top: 2px;
padding-bottom: 2px;
text-align: center;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding-left: 5px;
padding-top: 0;
padding-bottom: 0;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
width: 100%;
}
.input-field:hover {border: 1px solid #05c9f0;}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
You can calculate the width like this! width: calc(100% - 125px); rather than set it to 100%

CSS content Property not working as expected in firefox

What i am doing is that in search box when user enter a search term, i display a close button ('x' character to be specific, embedded as content after reset button) to clear the contents of search box.
It works fine in both Chrome and IE but not in firefox.
Any kind of help would be highly appreciated.
.search-box,.close-icon,.search-wrapper {
position: relative;
padding: 10px;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent;
display: inline-block;
vertical-align: middle;
outline: 0;
cursor: pointer;
}
.close-icon:after {
content: "X";
display: block;
width: 15px;
height: 15px;
position: absolute;
z-index:1;
right: 35px;
top: 0;
bottom: 0;
margin: auto;
padding: 2px;
border-radius: 50%;
text-align: center;
color: black;
font-weight: normal;
font-size: 12px;
cursor: pointer;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
<div class="search-wrapper">
<form>
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset"></button>
</form>
</div>
This code should help you
.search-box,.search-wrapper {
position: relative;
padding: 10px;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box
{
width:300px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent,
display: inline-block;
vertical-align: middle;
outline: 0;
position: absolute;
top:19px;
left:305px;
z-index:1;
padding: 1px 2px;
border-radius: 50%;
text-align: center;
color: black;
font-weight: normal;
font-size: 12px;
cursor: pointer;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
<div class="search-wrapper">
<form>
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset">X</button>
</form>
</div>
NOTE : set your .search-box width and according to it set left of your .close-icon
Try this code: Hope this solve your problem. Adjust "outer_box" class for width.
<style>
.search-box, .search-wrapper {
padding: 10px;
box-sizing: border-box;
}
.search-box {
position:relative;
width:100%;
}
.outer_boxs{
position:relative;
width:60%;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent,
display: inline-block;
vertical-align: middle;
outline: 0;
cursor: pointer;
position: absolute;
right:5px;
top: 10px;
background:#f2f2f2;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
</style>
<div class="search-wrapper">
<form>
<div class="outer_boxs" >
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset">X</button>
</div>
</form>
</div>

How to use position:relative to different browsers? Or is it not the best way?

I'm creating static web site and sometimes use position:relative. And when I tested my page on different browsers I got different displays of some elements like 1-2 pixels higher or lower.
How I can solve the problem or I should use something else?
Thought about some gulp package but didn't find anything.
Example.
HTML:
<p id="search-form-menu">
<input type="search" name="search-input" placeholder="Поиск">
<input type="submit" value="">
</p>
CSS:
input[type='search'] {
height: 35px;
width: 250px;
border: 0px;
border-radius: 5px;
position: relative;
top: -10px;
padding-left: 15px;
padding-right: 45px;
}
input[type='submit'] {
height: 35px;
width: 45px;
background-color: white;
border: 0;
border-left: 3px solid #d1d1d1;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
position: relative;
top: -10px;
left: -47px;
background-image:url("../image/search-loop-2.svg");
background-position: center;
background-repeat:no-repeat;
}
Why not use float style on the submit input?
<p id="search-form-menu">
<input type="search" name="search-input" placeholder="Поиск"/>
<input type="submit" value=""/>
</p>
css
p#search-form-menu{
width: 250px;
height: 35px;
}
input[type='search'] {
display: inline-block;
height: 35px;
width: 205px;
border: 0px;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
padding-left: 15px;
padding-right: 15px;
}
input[type='submit'] {
display: block;
float: right;
height: 35px;
width: 45px;
background-color: white;
border: 0;
top:10px;
border-left: 3px solid #d1d1d1;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background-image:url("../image/search-loop-2.svg");
background-position: center;
background-repeat:no-repeat;
}
created a fiddle and got this to work in chrome and ie.
https://jsfiddle.net/1r8a2u87/2/
There should be no need to use positioning here at all.
Just box-sizing and vertical-align.
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
background: #c0ffee;
}
input[type='search'] {
height: 35px;
width: 250px;
border-radius: 5px;
border: none;
}
input[type='submit'] {
height: 35px;
width: 45px;
background-color: white;
border: none;
border-left: 3px solid #d1d1d1;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
vertical-align: middle;
}
<p id="search-form-menu">
<input type="search" name="search-input" placeholder="Поиск">
<input type="submit" value="Go">
</p>