<section id="relative-positioning" class="animate-things-wrapper">
<button id="trigger">Trigger</button>
<div id="box" class="box">
Hi there
</div>
</section>
<script src="../../js/components/relative-positioning.js"></script>
<section id="relative-positioning" class="animate-things-wrapper">
<button id="trigger">Trigger</button>
<div id="box" class="box">
Hi there
</div>
</section>
<script src="{{ path '/js/components/relative-positioning.js' }}"></script>
/* No context defined. */
(function () {
document.addEventListener('DOMContentLoaded', function () {
console.log("relative-positioning active");
const button = document.querySelector('#trigger');
const box = document.querySelector('#box');
button.addEventListener('click', function() {
box.classList.toggle('active');
})
});
})();
#relative-positioning {
.box {
position: relative;
left: 0;
transition: left 0.5s ease-in-out;
&.active {
left: -100px;
}
}
}
No notes defined.