<div class="alert alert-info">This is an alert!</div>
Use Flexbox to perfectly center elements both vertically and horizontally.
.center {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
background: #eef;
border: 1px dashed #99c;
}
This example increases a counter only when you resize the window, but thanks to debounce()
, it wonβt trigger too fast.
function debounce(fn, delay) {
let timer;
return function(...args) {
clearTimeout(timer);
timer = setTimeout(() => fn.apply(this, args), delay);
};
}
Resize Counter: 0
10
<button onclick="document.getElementById('targetSection').scrollIntoView({ behavior: 'smooth' })">Go to Section</button>
Move your mouse...