I'm using styled-components.
If the title of a table has more characters than 400px... I've applied text-overflow: ellipsis; to the td, but it's not working.
I don't know how to solve this problem.
How can I apply text-overflow to td in table tags?
import styled from "styled-components";
export default function App() {
const lists = [
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"october",
"A"
];
return (
<div className="App">
<Table>
<tr>
<td>title</td>
<td>date</td>
<td>type</td>
</tr>
<tbody>
<tr>
{lists.map((list) => (
<td>{list}</td>
))}
</tr>
</tbody>
</Table>
</div>
);
}
const Table = styled.table`
width: 100%;
td {
min-width: 50px;
padding: 1rem;
}
tbody {
tr {
box-sizing: border-box;
td {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 400px;
&:first-child {
color: red;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
width: 400px;
}
}
}
}
`;