I have a design with a glass morphism card, behind it 2 circles are orbiting it.
Here is the ref pic from where I took the inspiration here.
So, I have somewhat achieved my result, but the main problem is those outer circles are creating scrollbars both vertically and horizontally along the way which I don't want it to create.
How do I tell the browser to not create the scrollbars. Like for example the browser cuts them whenever the circles are not visible, just like overlay:hidden;
. I've also used this method, but they still create the scrollbars.
const downloadbtn = document.querySelector(".download_btn");
downloadbtn.addEventListener("click", () => {
let time = Number(downloadbtn.dataset.time);
downloadbtn.classList.add("timer");
downloadbtn.innerHTML = `Your file will download in<b>${time}</b>seconds.`;
const initCounter = setInterval(() => {
if (time > 0) {
time--;
return (downloadbtn.innerHTML = `Your file will download in<b>${time}</b>seconds.`);
}
downloadbtn.innerHTML = `Your file is downloading...`;
clearInterval(initCounter);
setTimeout(() => {
downloadbtn.classList.remove("timer");
downloadbtn.innerHTML = `
<i ></i>
<span >Download Again!</span>`;
}, 5000);
}, 1000);
});
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
@keyframes rotate {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
position: relative;
background: rgb(128, 237, 153);
background: linear-gradient( 19deg, rgba(128, 237, 153, 1) 0%, rgba(56, 163, 165, 1) 100%);
}
.download_btn_wrapper {
background: red;
width: 365px;
height: 350px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
background: rgba(255, 255, 255, 0.3);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
border: 1px solid rgba(255, 255, 255, 0.18);
}
.download_btn {
display: block;
background: #4a98f7;
padding: 1rem 1.2rem;
color: white;
border-radius: 6px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease-in-out;
cursor: pointer;
}
.download_btn:hover {
background: #2382f6;
}
.download_btn.timer {
background: transparent;
color: black;
box-shadow: none;
transition: none;
pointer-events: none;
}
.download_btn.timer b {
color: #4a98f7;
padding: 0 8px;
}
.rotate_div {
width: 70%;
height: 360px;
border-radius: 50%;
position: absolute;
z-index: -1;
-webkit-animation: rotate 32s infinite linear;
}
.rotate_div:before,
.rotate_div:after {
content: "";
display: inline-block;
width: 160px;
height: 160px;
position: absolute;
border-radius: 50%;
filter: blur(1px);
}
.rotate_div:before {
z-index: -2;
background: black;
top: -10%;
left: -10%;
}
.rotate_div:after {
z-index: -3;
background: #9d4edd;
bottom: -10%;
right: -10%;
}
<section >
<div data-time=5>
<i ></i>
<span >Download Now</span>
</div>
</section>
<div > </div>
CodePudding user response:
For overflow: hidden
to work, that element needs a fixed
height
/width
or a max-
height
/width
. In any other case the elements width/height will be calculated to fit-content and as such not overflow.
const downloadbtn = document.querySelector(".download_btn");
downloadbtn.addEventListener("click", () => {
let time = Number(downloadbtn.dataset.time);
downloadbtn.classList.add("timer");
downloadbtn.innerHTML = `Your file will download in<b>${time}</b>seconds.`;
const initCounter = setInterval(() => {
if (time > 0) {
time--;
return (downloadbtn.innerHTML = `Your file will download in<b>${time}</b>seconds.`);
}
downloadbtn.innerHTML = `Your file is downloading...`;
clearInterval(initCounter);
setTimeout(() => {
downloadbtn.classList.remove("timer");
downloadbtn.innerHTML = `
<i ></i>
<span >Download Again!</span>`;
}, 5000);
}, 1000);
});
body {
max-width: 100vw;
max-height: 100vh;
overflow: hidden;
}
/* original css */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
@keyframes rotate {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
position: relative;
background: rgb(128, 237, 153);
background: linear-gradient( 19deg, rgba(128, 237, 153, 1) 0%, rgba(56, 163, 165, 1) 100%);
}
.download_btn_wrapper {
background: red;
width: 365px;
height: 350px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
background: rgba(255, 255, 255, 0.3);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
border: 1px solid rgba(255, 255, 255, 0.18);
}
.download_btn {
display: block;
background: #4a98f7;
padding: 1rem 1.2rem;
color: white;
border-radius: 6px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease-in-out;
cursor: pointer;
}
.download_btn:hover {
background: #2382f6;
}
.download_btn.timer {
background: transparent;
color: black;
box-shadow: none;
transition: none;
pointer-events: none;
}
.download_btn.timer b {
color: #4a98f7;
padding: 0 8px;
}
.rotate_div {
width: 70%;
height: 360px;
border-radius: 50%;
position: absolute;
z-index: -1;
-webkit-animation: rotate 32s infinite linear;
}
.rotate_div:before,
.rotate_div:after {
content: "";
display: inline-block;
width: 160px;
height: 160px;
position: absolute;
border-radius: 50%;
filter: blur(1px);
}
.rotate_div:before {
z-index: -2;
background: black;
top: -10%;
left: -10%;
}
.rotate_div:after {
z-index: -3;
background: #9d4edd;
bottom: -10%;
right: -10%;
}
<section >
<div data-time=5>
<i ></i>
<span >Download Now</span>
</div>
</section>
<div > </div>
CodePudding user response:
You can use css overflow property inside body
overflow: hidden;