JSFiddle - React, Tailwind, and code Playground

by c_vilander

HTML

<div id="menu" onclick="toggleDiv()"><p class="title">Red More ...</p> <p>And here is some more text that you can show and hide with just a click!</div>

CSS

body {
    font-family: Arial, Helvetica, sans-serif;
    color: #fff;
}

.title {
    text-align: center;
    margin: 0;
    padding: 2px 0 0 0;
}

.title:hover {
    color: #dfdfdf;
}

#menu {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 190px;
    height: 20px;
    margin: 0;
    padding: 10px;
    display: block;
    background: #393939;
    cursor: pointer;
    -webkit-transition: 0.5s ease-in-out;
            transition: 0.5s ease-in-out;
}

JavaScript

function toggleDiv() {
    "use strict";
    var x = document.getElementById('menu');
    if (x.style.height === "200px") {
        x.style.height = "20px";
    } else {
        x.style.height = "200px";
    }
}