1

CSS Code

.table {
  display: grid;
  grid-template-columns: 170px 300px;
  border: 1px solid black;
}
.tr {
  display: contents;
}
.td {
  border-left: 1px solid black;
  overflow: hidden;
  text-overflow: ellipsis;
}

JSX code

import "./styles.css";

export default function App() {
  return (
    <div className="table">
      <div className="tr">
        <div className="td">
          abcsfsaffadsfsdfsafsdsfsadfdasdfasfasdffasfasfasdfsd
        </div>
        <div className="td">abcsfs</div>
      </div>
    </div>
  );
}

You can see the code at Codesandbox

You can see that we have first column overflow, but second column not enter image description here

When hover I hope to display a boxes for overflow column only to show full text, like the following enter image description here

The problem is how to detect whether a div column is overflow for showing the box?

william007
  • 15,661
  • 20
  • 90
  • 161

0 Answers0