Вы можете использовать jQuery с его простыми методами show и hide, но в vanilla JS вы можете попробовать что-то вроде этого:
<td onmouseenter="expandContent()" onmouseleave="hideContent()">
<div class="hoverable" onmouseenter="expandContent()" onmouseleave="hideContent()">
...content
</div>
</td>
function expandContent(){
const content = document.querySelector(".hoverable");
content.style.height = "300px"; //or whatever height u need to fit the content, can be set to auto too.
}
function hideContent(){
const content = document.querySelector(".hoverable");
content.style.height = "100px"; //or whatever inital height u want to have
}
и для вашего CSS:
.hoverable{
height: 100px; //your initial height
overflow: hidden; //stop content from "spilling"
}
td{
overflow: hidden //stop content from "spilling"
}
Itследует увеличить ваш тд при наведении на высоту, которую вы хотите.Дайте мне знать, если это работает для вас :)
РЕДАКТИРОВАТЬ: Я явно зашел слишком далеко вчера. Простейшее решение этой проблемы, я полагаю, заключается в добавлении свойства: hover к css.
.hoverable{
height: 5px; //your initial height
overflow: hidden; //stop content from "spilling"
}
.hoverable:hover {
height: 600px; //or height: auto then it will expand to text height
}
td{
overflow: hidden;
}
Это должно быть все, что вам нужно, без дополнительных методов JavaScript.Вы также можете добавить другие свойства при наведении, например, изменить цвет фона
background: lightblue;
Извините за путаницу:)