<form class="edit-filter__form">
<div class="filter-value__block">
<div class="filter-value__block-content">
<div class="filter-value__block-item">
<input onkeydown="this.style.width = ((this.value.length + 1) * 8) + 'px';" class="filter-value-title" value="Some:" name="filter-value-title">
<input onkeydown="this.style.width = ((this.value.length + 1) * 8) + 'px';" class="filter-value-text" value="Value" name="filter-value-text">
</div>
</div>
<!-- 2 filter block -->
<div class="filter-value__block-content">
<div class="filter-value__block-item">
<input class="filter-value-title" value="Other bid value:" name="filter-value-title">
<input class="filter-value-text" value="Other big value field" name="filter-value-text">
</div>
</div>
<!-- 3 filter block -->
<div class="filter-value__block-content">
<div class="filter-value__block-item">
<input class="filter-value-title" value="Random value" name="filter-value-title">
<input class="filter-value-text" value="Random value text" name="filter-value-text">
</div>
</div>
<!-- 4 filter block -->
<div class="filter-value__block-content">
<div class="filter-value__block-item">
<input class="filter-value-title" value="Last big text value" name="filter-value-title">
<input class="filter-value-text" value="Something big in text field" name="filter-value-text">
</div>
</div>
</div>
<div class="filter-save__block">
Another block
</div>
</form>
.edit-filter__form {
display: flex;
width: 100%;
}
.filter-value__block {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
align-items: flex-start;
border: 1px solid red;
}
.filter-value__block-content {
min-height: 57px;
background: transparent;
opacity: 0.66;
border-radius: 14px;
background: #fff;
border: 1px solid rgba(204, 204, 204, 0.76);
box-shadow: 2px 2px 6px rgb(0 0 0 / 16%);
padding: 8px;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.filter-value__block-item {
display: inline-flex;
flex-direction: column;
font-family: Poppins;
font-weight: normal;
font-size: 14px;
text-align: left;
color: #bc343e;
}
.filter-value__block-close {
padding: 6px;
cursor: pointer;
}
.filter-save__block {
margin-top: auto;
margin-left: auto;
}
.filter-value-title,
.filter-value-text {
display: inline;
color: #bc343e;
border: none;
background: transparent;
outline: none;
}
const form = document.querySelector(".edit-filter__form");
let inputs = form.querySelectorAll("input");
console.log(inputs);
inputs.forEach((item) => {
console.log(item.value);
item.style.width = item.value.length + "ch";
item.addEventListener("input", resizeInput);
});
function resizeInput() {
this.style.width = this.value.length + "ch";
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.