Below is a simplified version of a restaurant menu i've created. When you hover over the dish, a description of the dish shows up, and i created a transition to make it smoother.
The next dish, the menu item below, gets pushed down when the description of the upper menu item is shown. I would like to create a transition so that the text below moves further down on the page more smoothly instead of it changing from one place to another instantly, since that looks rather glitchy on the page (if that makes any sense).
I would also like to make the opacity transition work both ways - right now, works when i hover over the item, but when i take the mouse off it, it goes away instantly, so the transition doesn't work both ways at the moment. i've tried using the not hover function with no luck.
Here's my code:
HTML:
<html>
<body>
<h4 class="navn"> Pizza </h4>
<div class="beskrivelse">
<p> ingredients: cheese, ham, pepperoni </p>
</div>
<h4 class="navn"> Hamburger </h4>
<div class="beskrivelse">
<p> Comes with salad and fries </p>
</div>
</body>
</html>
CSS:
h4:hover + .beskrivelse {
opacity: 1;
height: auto;
}
h4:hover {
color: red;
}
.beskrivelse {
height: 0;
opacity: 0;
overflow: hidden;
transition: opacity 3s ease-out;
}