How Can I Hide Extra Divs With An Ellipsis?
I have a tag input field and I need to show just as many as will fit into the fake 'input' div surrounding it, like this:
UPDATE
Now the input will stretch to the left in case there is no enough tags:
.btn {
width: 310px;
border: 1px solid;
display: flex;
height: 20px;
margin-bottom: 10px;
overflow: hidden;
}
input {
flex: 1;
min-width: 170px;
}
.btn > div {
position: relative;
height: 100%;
overflow: hidden;
}
.btn > div:after {
content: "...";
position: absolute;
right: 2px;
bottom: 5px;
}
.tag {
background: #fff;
position: relative;
z-index: 2;
}
<divclass="btn"><div><spanclass="tag">Tag 1</span><spanclass="tag">Tag 2</span><spanclass="tag">Tag 3</span></div><input></div><divclass="btn"><div><spanclass="tag">Tag 1</span><spanclass="tag">Tag 2</span><spanclass="tag">Tag 3</span><spanclass="tag">Tag 4</span><spanclass="tag">Tag 5</span></div><input></div><divclass="btn"><div><spanclass="tag">Tag 1</span><spanclass="tag">Tag 2</span></div><input></div><divclass="btn"><div><spanclass="tag">Tag 1</span><spanclass="tag">Tag 2</span><spanclass="tag">Tag 3</span><spanclass="tag">Tag 4</span><spanclass="tag">Tag 5</span><spanclass="tag">Tag 6</span><spanclass="tag">Tag 7</span></div><input></div><divclass="btn"><div><spanclass="tag">Tag 1</span></div><input></div><divclass="btn"><div></div><input></div>
Solution 2:
<divclass="btn btn-secondary"><divclass="tag-box"><spanclass="tag">Tag 1</span><spanclass="tag">Tag 223131</span><spanclass="tag">Tag 31231</span><spanclass="tag">Tag 4</span><spanclass="tag">Tag 5</span></div><input></div>
.tag-box {
display: block;
border: 1px solid;
max-width: 140px;
padding: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.tag-box .tag {
display: inline;
overflow: hidden;
text-overflow: ellipsis;
}
Post a Comment for "How Can I Hide Extra Divs With An Ellipsis?"