How to make a DIV open and close slowly

Hello All,

We would like to have certain DIVs open and close slowly, when people click on the controlling DIV subject line.
So for example here:

if you click on the Subject of a question, you will see that the DIV opens suddenly. We would like it to open slowly just as the accompanying Arrow image to the right rotates Up slowly and Down slowly.

And just to be clear: the Hight of the DIV that is closed which is to Open upon click on Subject is not known, as it can vary from Question to Question. So it is very crucial that the open DIV height is not fixed.


P.S., I forgot to mention: No Jquery please. Solution should be in CSS & native JS.

Is there a particular reason that you don’t want to use jquery?

Yes, there are many reasons. I dont want to get into arguments about these reasons. Since the reasons always start a Pro Con argument. So for these reasons, we like to work with Native (Vanilla) JavaScript only. And of course CSS.

answer given. I just asked

Try searching for CSS accordion.

So I implemented the CSS accordion using the JavaScript method.
And it is working fine as you can see in above page. when it comes to opening the DIV.
But not closing the DIV.
That is when opening the DIV the JS code now is opening it with Transition time of 1 sec.
However, when closing the DIV it closes instantly.
Do you have suggestion how to fix this?
FYI, I tried setting in:

if ({ = null;
} else { = panel.scrollHeight + “px”;
} = ‘0px’

but that did not do it.



FYI. I resolved the problem with DIV closing closing instant. So now it also closes slow as with opening.
If you want to know how I did, take a look at the JavaScript code at bottom of that page.

Cheers :slight_smile:

1 Like

That looks a lot better.

I am pleased you replied with your solution for the benefit of other users who may have a similar problem.

All that’s required now is to clear the following errors:

Also try to make the page more mobile friendly:

Yes, our Site currently is not done for Mobile usage, so it lacks Responsive Design CSS. It is currently for PC users only. It is due to the fact that we are a non-profit search engine & social network operating this MASSIVE network mainly with Donations. And we have not had to date much Donations to go beyond PC based version and to support development of the Mobile version. If you want us to do the Mobile version of the Site, then make a generous Donation. Although, to be exact, given the massive size of the Site, we would need at least $500K in donations to do Mobile version of the Site. Now to put things into perspective to how much we have done with minimum resources we have, Google Facebook, search engine & social network spend $500K per Day if not per Hour. Cheers :slight_smile:

Woah. Really?

I’ll do it for $250K :slight_smile:


Your site is missing out on the benefits of being Mobile Friendly because I believe Google gives SEO preferences to validated web pages. As you may well know about 60% of traffic comes from Mobiles and Tablets!

Why restrict your exposure?

Did you take the time to read why the web-page was not Mobile Friendly? I did and noticed there was a good chance of a simple fix which would achieve the desired result.

The source script and related files were:

  1. downloaded to my Localhost then uploaded to my server

  2. a single meta head tag line was added to the web-page

  3. uploaded the modified file

  4. validation results of Google Mobile Friendly Test

  5. Results:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.