1

I'm building a website to learn the interaction between CSS and HTML, but, I have a problem with this: "page with problem".

The div on the right would do a transition to the bottom and this translation must be a second long, but, it's a lot faster.

I don't understand the problem.

function setDescription(eventId) {
    var curEv = getEventById(eventId);

    var didascalia = document.getElementById("didascalia");
    didascalia.firstChild.data = curEv.titolo;

    var eventDescription = document.getElementById("eventDescription");
    if (eventDescription.firstChild) eventDescription.firstChild.data = curEv.descrizione;
    else eventDescription.appendChild(document.createTextNode(curEv.descrizione));

    var image = document.getElementById("imageEventImmagine");
    if (image) {
        if (image.alt === curEv.tipologia) return;
        image.src = "./resource/img/eventi/" + curEv.tipologia + ".jpg";
        image.alt = curEv.tipologia;
    } else {
        var divImmagine = document.getElementById("divImmagine");
        var img = document.createElement("img");
        img.id = "imageEventImmagine";
        img.src = "./resource/img/eventi/" + curEv.tipologia + ".jpg";
        img.alt = curEv.tipologia;
        divImmagine.appendChild(img);
    }
}
.smalldesc {
    overflow: hidden;
    transition: all .10s ease;
}

.smalldesc.expand {
    max-height:  100%;
}
<div id="expand" class="basePreventivo smalldesc">
    <h3 id="didascalia">Seleziona un'evento</h3>
    <p id="eventDescription"></p>
    <div id="divImmagine" class="fill"></div>
</div>

0

3 Answers 3

1

transition: all .10s ease;

Change .10s to 1s to make the transition longer. Also

Sign up to request clarification or add additional context in comments.

Comments

1

Transition time is given .10s in CSS, change that to 1s to make it longer.

Comments

1

Your problem is that height (or max-height) can only be transitioned if it is transitioning between two literal values (no percentage or auto).

For example:

0px to 100px - ✅
0px to 10rem - ✅
auto to 100px - 🚫
0px to auto - 🚫
0px to 100% - 🚫

Additionally, if you want your transition to take 1 second you will need to adjust your transition timing from 0.1s to 1s.

To solve your animation value issues - check out this article that discusses several approaches to achieve what you need: Using CSS Transitions on Auto Dimensions

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.