Hey I struggle using CSS Animation. I use Bootstrap 4 and am very new to website developing and also to CSS. I use Animate.css for my animaton. I want the icon button to expand to the side and show the div with the select elements ( for table filtering, for which I use datatables). Here is my reproducable script: I cant figure out how to start the animation from the icon button on (I also want the select button evenly spaced and vertical centered, but the button on the right). I could only realise this with display:flex but then float-right does not work for the button.
Here is the code: I couldnt figure out how to use animate.css in jsfiddle :/ Edit: I forgot the animate method: https://jsfiddle.net/z4yvp0gL/8/
HTML:
<div>
<div class="row button-container">
<div class="col" style="display: flex;">
<div id="sideExpand"><select>
<optgroup label="This is a group">
<option value="12" selected>This is item 1</option>
<option value="13">This is item 2</option>
<option value="14">This is item 3</option>
</optgroup>
</select><select>
<optgroup label="This is a group">
<option value="12" selected>This is item 1</option>
<option value="13">This is item 2</option>
<option value="14">This is item 3</option>
</optgroup>
</select><select>
<optgroup label="This is a group">
<option value="12" selected>This is item 1</option>
<option value="13">This is item 2</option>
<option value="14">This is item 3</option>
</optgroup>
</select></div>
<button class="btn btn btn-transparent btn-icon" id="filterToggle" onclick="SetActiveDiv('#sideExpand',this)"><i class="fa fa-filter" style="position: absolute;font-size: 150%;"></i></button>
</div>
</div>
</div>
CSS
#sideExpand {
display: none;
width: 100%;
border-radius: 35px;
background-color: rgba(31, 45, 65, 0.125);
}
select {
border: 0;
background-color: initial;
font-size: 100%;
display: block;
margin: auto;
word-wrap: normal;
}
.btn-icon {
padding: 0;
display: -webkit-inline-box;
display: inline-flex;
-webkit-box-align: center;
align-items: center;
-webkit-box-pack: center;
justify-content: center;
overflow: hidden;
border-radius: 100%;
flex-shrink: 0;
height: calc( (1rem * 1.5) + (0.5rem * 2) + (2px) ) !important;
width: calc( (1rem * 1.5) + (0.5rem * 2) + (2px) ) !important;
}
Javascript
function SetActiveDiv(ID, bt) {
var element = document.querySelector(ID);
if (element !== null) {
if (element.classList.contains("show")) {
element.classList.remove("show");
animateCSS(element, "fadeOutLeftBig", "2s")
animateCSS(bt, "fadeOutLeftBig", "2s")
return setTimeout(() => {
element.style.display = "none";
}, 2000);
} else {
element.style.display = "flex";
element.classList.add("show");
animateCSS(element, "fadeInLeftBig", "2s").then((message) => {});
return animateCSS(bt, "fadeInLeftBig", "2s").then((message) => {});
}
}
return console.log(ID, " not found!");
}