Fix the two-line case for show more/less
I made two mistakes here! One is that you need to round up subpixel line heights, and the other is that `clientHeight` is what I want, I shouldn't include the margin!
This commit is contained in:
parent
4c809a5f5f
commit
68578aa929
1 changed files with 2 additions and 2 deletions
|
@ -19,9 +19,9 @@ try {
|
|||
const tradeSections = document.querySelectorAll("#trade-hangers p");
|
||||
for (const section of tradeSections) {
|
||||
const oneLine = parseFloat(getComputedStyle(section)['line-height']);
|
||||
const maxHeight = oneLine * 2;
|
||||
const maxHeight = Math.ceil(oneLine * 2);
|
||||
|
||||
if (section.offsetHeight > maxHeight) {
|
||||
if (section.clientHeight > maxHeight) {
|
||||
section.style.maxHeight = `${maxHeight}px`;
|
||||
section.setAttribute("data-overflows", "");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue