I am having some problems using elipsis property inside a div with css grid.
If I set the elipsis property directly in a grid child it works, but when used inside a div in a grid it doesn't work.
You can see here what's the problem:
body{
text-align:center;
}
.container{
width: 300px;
background-color:#ccc;
margin-left:auto;
margin-right:auto;
}
#grid{
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
#grid > div{
border:1px solid #000;
padding:5px;
}
.elipsis{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<h2>This works</h2>
<p>as selipsis class is directly in col-2 div</p>
<div class="container">
<div id="grid">
<div class="col-1">A</div>
<div class="col-2 elipsis">
B B B B B B B B B B B B B B B B B
</div>
<div class="col-3">C</div>
</div>
</div>
<h2>This doesn't worl</h2>
<p>as selipsis class is in a div inside col-2 div</p>
<div class="container">
<div id="grid">
<div class="col-1">A</div>
<div class="col-2">
<div class="elipsis">B B B B B B B B B B B B B B B B B</div>
</div>
<div class="col-3">C</div>
</div>
</div>
Thank you.
min-width: auto
. This means that an item cannot be shorter than its content. You can override this default withmin-width: 0
oroverflow
with any value other thanvisible
. jsfiddle.net/epgghwna – Cha