I have a grid container that has 4 items. The first 2 items and the 4th items will always take up similar space and the 3 items can be long or short and it must take up all the leftover space as shown below
function handleWidth() {
const inputValue = document.getElementById("widthInput").value;
document.getElementsByClassName("grid-container")[0].style["width"] = inputValue + '%';
}
.grid-container {
display: grid;
grid-template-columns: auto auto 1fr auto;
}
.grid-container>div {
padding-right: 10px;
}
<div class="grid-container">
<div>Jira-123</div>
<div>Icon</div>
<div>Summary - This is a summary of jira item</div>
<div>In progress</div>
</div>
<br />
<br />
<div><input type="number" value="100" id="widthInput" /></div>
<button onclick="handleWidth()">set width</button>
But if you reduce the available space in which the grid container fits (you can do so by entering a value, say 25, in the input field, in the sample given above), you’ll see that the summary/title is shown in multiline.
What I desire to do
As the space reduces, I want to remove the status("In progress" in the above example) and show the "summary/title" with an ellipsis and as the space reduces further, I want to remove the "summary/title" as well. The first grid item i.e. JIRA-123 should not wrap.
2
Answers
You can use @media query to implement responsive design.
Ex, you can hide the third and fourth grid items when the width is 600 pixels or less.