Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 months ago.
Improve this question
I have an animated circle (class="circle-ani") that grows and shrinks. However, it also causes the button (class="start-timer") to grow and shrink and the box (class="button-timer") that they're in to grow taller to accommodate the size change. How can I make it so just the circle changes size and not the rest?
Working example:
//---TIMER---//
var remainingTime = 30;
var isStopped = true;
const countContainer = document.getElementById('sec');
const renderTime = () => {
remainingTime -= 1;
countContainer.innerHTML = remainingTime;
if (remainingTime === 0) {
isStopped = true;
clearInterval(timer);
remainingTime = 30;
}
}
const startTimer = () => {
if (isStopped) {
isStopped = false;
countContainer.innerHTML = remainingTime;
timer = setInterval(renderTime, 1000);
}
}
document.getElementById('start').addEventListener('click', function() {
document.getElementById('circle').classList.add('animate');
});
const startButton = document.getElementById('start');
startButton.onclick = startTimer;
// const stopTimer = () => {
// isStopped = true;
// if (timer) {
// clearInterval(timer);
// }
// }
// const resetTimer = () => {
// isStopped = true;
// clearInterval(timer);
// clearInterval(animate);
// remainingTime = 30;
// countContainer.innerHTML = remainingTime;
// }
//---CARD OBJECTS---//
// const neck = ['Chin tuck', 'Neck extension', 'Neck towel', 'Side-to-side']
// let neckStretch1 = 'Chin tuck'
// let neckStretch2 = 'Neck extension'
// let neckStretch3 = 'Neck towel'
// let neckStretch4 = 'Side-to-side'
// const shoulder = ['Desk pec stretch', 'Doorway pec stretch', 'Overhead reach', 'W to Y', 'Cross body']
// let shoulderStretch1 = 'Desk pec stretch'
// let shoulderStretch2 = 'Doorway pec stretch'
// let shoulderStretch3 = 'Overhead reach'
// let shoulderStretch4 = 'W to Y'
// let shoulderStretch5 = 'Cross body'
// const hand = ['One-by-one', 'Wrist extensor', 'Wrist flexor']
// let handStretch1 = 'One-by-one'
// let handStretch2 = 'Wrist extensor'
// let handStretch3 = 'Wrist flexor'
// const lowBack = ['Low back rotation', 'Bending over', 'Seated knee to chest', 'Seated pelvic tilt']
// let lowBack1 = 'Low back rotation'
// let lowBack2 = 'Bending over'
// let lowBack3 = 'Seated knee to chest'
// let lowBack4 = 'Seated pelvic tilt'
// const hip = ['Kneeling psoas stretch', 'Standing psoas stretch', 'Seated glute stretch', 'Seated cross-body glute']
// let hipStretch1 = 'Kneeling psoas stretch'
// let hipStretch2 = 'Standing psoas stretch'
// let hipStretch3 = 'Seated glute stretch'
// let hipStretch4 = 'Seated cross-body glute'
// const leg = ['Seated hamstring stretch', 'Butterfly stretch', 'Standing quad stretch', 'Chair quad stretch', 'Seated abductor stretch']
// let legStretch1 = 'Seated hamgsting stretch'
// let legStretch2 = 'Butterfly stretch'
// let legStretch3 = 'Standing quad stretch'
// let legStretch4 = 'Chair quad stretch'
// let legStretch5 = 'Seated abductor stretch'
//---CARD DECK---//
mobiscroll.settings = {
theme: 'ios',
themeVariant: 'light'
};
mobiscroll.listview('.cardDeck', {
stages: [{
percent: -20,
action: function(event, inst) {
inst.move(event.target, 0);
return false;
}
}, {
percent: 20,
action: function(event, inst) {
inst.move(event.target, 0);
return false;
}
}],
actionable: false
});
// function dropdownFunction() {
// document.getElementById("myDropdown").classList.toggle('show')
// }
// function dropdownFunction() {
// var x = document.getElementById('dropdownClick')
// if (x.style.display === 'none') {
// x.style.display = 'block'
// }else {
// x.style.display = 'none'
// }
// }
// document.getElementById("menu").addEventListener("click", dropdownFunction());
// function dropdownFunction() {
// // var x = document.getElementById("dropdownClick").style
// const toggle = document.getElementById("myDropdown")
// const toggleList = document.getElementsByTagName("li");
// console.log(toggle.style.display)
// if (toggle.style.display !== null) {
// console.log("one")
// toggle.style.display = 'inline-block'
// toggleList.style.display = 'inline-block'
// }else {
// // x.display = 'none'
// console.log("two")
// }
// }
// ---BODY ICON ---//
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.body-image')) {
var dropdowns = document.getElementsByClassName("dropdown-list");
showEvent = 'show';
for (var i = 0; i < dropdowns.length; i++) {
var currentElement = dropdowns[i],
currentElementAsString = dropdowns[i].toString();
if (currentElementAsString.localeCompare(showEvent)) {
currentElement.classList.remove('show');
}
}
}
}
body {
font-family: 'Gentium Book Plus', serif;
font-family: 'Noto Serif', serif;
}
/* Stylings */
html {
font-size: 62.5%;
}
.body-image {
display: none;
}
h3,
button,
a {
font-size: 1rem;
}
h2 {
/* display: flex;
flex-direction: column;
justify-content: center; */
font-size: 400%;
margin-top: -25%;
z-index: 5;
}
body {
color: rgb(247, 240, 240);
background: #8ad3b8;
/* margin: 100px 250px; */
height: 100%;
width: 99%;
display: flex;
justify-content: center;
align-content: center;
}
.main {
text-align: center;
/* align-content: center; */
margin: 4% auto;
width: 57%;
height: 65%;
background: rgba(12, 134, 85, 1);
border-radius: 20px;
border: 10px solid rgba(12, 134, 85, .4);
box-shadow: 0 0 50px rgba(12, 134, 85, 1);
min-height: 450px;
}
h1 {
margin: 0;
padding: 20px 0 0 0;
font-size: 500%;
}
h3,
section,
.start-timer {
margin: 0;
padding: 10px;
display: inline-block;
border-radius: 20px;
}
h6 {
margin: 0;
padding: 0 0 20px 0;
font-size: 10px;
}
header,
section {
margin: 0px;
}
section+section {
padding: 10px;
}
button {
background: #fe483b;
/* border-radius: 10px; */
border: 2px solid #fe483b;
}
.start-timer-section {
/* margin: 140px 0 0 0; */
outline: none;
display: flex;
flex-direction: column;
margin-top: 15%;
position: relative;
}
/* List */
.dropdown-list,
li,
a {
display: inline-block;
margin: 10px 15px 10px 10px;
color: black;
text-decoration: none;
background: #8ad3b8;
border-radius: 5px;
outline: none;
}
.dropdown-list,
li {
border-radius: 40px;
}
a {
/* display: block; height: 100%; width:100%; */
text-decoration: none;
border-radius: 5px;
color: black;
font-size: 12px;
}
.dropdown-list a:hover {
background: #fe483b;
}
/* .legs{
margin: 10px 30px 0 15px;
padding: 0 20px 0 0;
} */
/* ---THE CARD--- */
.cardDeck {
display: flex;
flex-direction: row;
justify-content: space-evenly;
padding: none;
box-shadow: 0 0 20px rgba(250, 241, 241, 0.6);
margin: 0 0 15px 0;
}
.card-directions {
border: 2px solid purple;
display: flex;
flex-direction: column;
min-height: 150px;
min-width: 35%;
}
.card-picture {
border: 2px solid yellow;
visibility: none;
min-width: 35%;
}
.button-timer {
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
border: 2px solid pink;
/* min-height: 150px; */
min-width: 15%;
flex-wrap: wrap;
}
h3 {
font-size: 15px;
}
/* ---TIMER ANIMATION--- */
body {
padding: 20px;
}
/* div.circle-ani {
transition: 4s ease;
position: relative;
width: 0px;
height: 0px;
text-align: center;
background: hsl(4, 99%, 61%, .7);
color: white;
border-radius: 100%;
padding: 40px;
overflow: hidden;
margin-bottom: -35%;
}
.animate {
transform: scale(1.9);
-webkit-transform: scale(1.9);
-ms-transform: scale(1.9);
} */
.circle-ani {
position: relative;
width: 0px;
height: 0px;
text-align: center;
background: hsl(4, 99%, 61%, .7);
color: white;
border-radius: 100%;
padding: 40px;
overflow: hidden;
margin-bottom: -35%;
}
div.animate {
/* animation properties */
animation-name: my-animation;
animation-duration: 3s;
animation-direction: alternate;
animation-iteration-count: 10;
animation-timing-function: ease-in-out;
/* other properties */
/* position: relative;
width: 0px;
height: 0px;
text-align: center;
background: hsl(4, 99%, 61%, .7);
color: white;
border-radius: 100%;
padding: 40px;
overflow: hidden;
margin-bottom: -35%; */
}
#keyframes my-animation {
from {
background-color: hsl(4, 99%, 61%, .7);
padding: 40px;
}
to {
padding: 80px;
}
}
/* ---Accessibility--- */
#media screen and (max-width: 1111px) {
body {
/* background: red; */
}
main {
width: 100%;
}
h1 {
padding: none;
margin: -7% 0 0 0;
}
h6 {
display: none;
}
.body-image {
padding: -10px;
}
.cardDeck {
display: flex;
flex-direction: row;
justify-content: space-evenly;
flex-wrap: wrap;
padding: none;
margin: 0 0 15px 0;
}
.card-directions {
min-height: auto;
display: flex;
flex-direction: row;
width: 100%;
}
.card-picture {
display: flex;
flex-direction: row;
width: 43%;
visibility: none;
/* min-height: 150px;
min-width: 150px; */
}
.button-timer {
display: flex;
flex-direction: row;
width: 43%;
min-height: 50px;
min-width: 150px;
}
.start-timer {
margin: auto;
outline: none;
}
/* .dropdown-list, li, a{
display: none;
} */
/* // --- DROPDOWN MENU--- // */
.body-image {
display: flex;
max-height: 30%;
max-width: 30%;
margin: 0;
padding: 0;
z-index: 5;
background: rgba(12, 134, 85, 1);
}
a {
cursor: pointer;
}
.dropdown {
display: flex;
justify-content: center;
align-content: center;
flex-wrap: wrap;
}
.dropdown li {
letter-spacing: .5px;
display: flex;
justify-content: center;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-list {
display: none;
position: absolute;
min-width: 150px;
box-shadow: 0px 10px 16px 10px rgba(0, 0, 0, 0.5);
z-index: 1;
margin: 0;
margin-top: -35%;
padding: 0;
}
/* Links inside the dropdown */
.dropdown-list li {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: center;
margin: 0;
}
/* Change color of dropdown links on hover */
.dropdown-list a:hover {
background-color: #fe483b
}
.show {
display: block;
}
}
#media screen and (max-width: 911px) {
body {
/* background: purple; */
}
.card-picture,
.button-timer {
width: 40%;
}
}
#media screen and (max-width: 679px) {
body {
/* background: orange; */
}
.card-picture,
.button-timer {
width: 39%;
}
h1 {
font-size: 300%;
padding: 0;
}
}
#media screen and (max-width: 649px) {
body {
/* background: yellow; */
}
.card-picture,
.button-timer {
width: 36%;
}
body {
margin: 0;
}
}
#media screen and (max-width: 619px) {
body {
/* background: pink; */
}
html {
height: 60%;
margin: 0;
}
.card-picture,
.button-timer {
width: 20%;
height: 200px;
flex-direction: column;
}
.main {
width: 100%;
height: 150%;
min-height: none;
margin-left: 5px;
}
.dropdown-list {
margin: -40% 0 20% 0;
}
}
#media screen and (max-width: 430px) {
.main {
height: 155%;
}
.dropdown-list {
margin-top: -100%;
margin-bottom: 50%;
width: 40%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fetch a Stretch</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<link href="https://fonts.googleapis.com/css2?family=Gentium+Book+Plus&family=Noto+Serif&display=swap" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<main class="main">
<header>
<!-- <img id = "menu" onclick = "dropdownFunction()" class="body-image" src="body.ico" alt ="body" > -->
<a onclick="myFunction()" title="Body Parts" class="body-image body-ico"><img id="menu" class="body-image" src="body.ico"> </a>
<h1>Fetch a Stretch</h1>
</header>
<section>
<h6>Welcome to moving better!</h6>
<section class="cardDeck">
<section class="card-directions">
<h3>Stretch: Lorem ipsum dolor sit.</h3>
<h3>Explanation: Lorem ipsum, dolor sit amet consectetur adipisicing elit. Tenetur, autem? Iusto itaque quae perspiciatis illo nostrum aspernatur voluptatum, libero sit provident accusantium explicabo est harum omnis quod? Amet, maiores inventore.</h3>
</section>
<section class="card-picture">
<h3>Picture:</h3>
</section>
<section class="button-timer">
<div id="circle" class="circle-ani"></div>
<h2 id="sec">30</h2>
<div class="start-timer-section">
<button onclick="start()" id='start' class="start-timer">Start Timer</button>
</div>
</section>
</section>
<span id="dropdownClick" class="dropdown">
<ul id = "myDropdown" class="dropdown-list">
<li class="neck">Neck</li>
<li class="shoulders">Shoulders</li>
<li class="hands">Hands</li>
<li class="back">Low Back</li>
<li class="hips">Hips</li>
<li class="legs">Legs</li>
</ul>
</span>
</section>
</main>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
Provided that doesn't work as intended, here is the codepen for it (I hope that's okay, I'm still new to most of this) https://codepen.io/lgmunyon/pen/dymNbjQ
You have to accommodate for the circle's size - the parent div has to grow to contain the child div (the circle) the way you have them currently positioned. If you position the parent div - the card the circle is in - to be position: relative and the circle to be position: absolute you can then define exactly where the circle will sit within the card, and it will not stretch the card out.
In regards to the timer button, it has the flex property and is matching the width changes of the circle. You can remove the flex property to fix that alone, but if you use the positional changes that problem resolves itself.
section.button-timer {
position: relative;
}
div.circle-ani {
position: absolute;
top: 50px; /* An example of where to position the circle */
The animation itself is problematic. You are specifying:
#keyframes my-animation {
from {
background-color: hsl(4, 99%, 61%, .7);
padding: 40px;
}
to {
padding: 80px;
}
}
When the padding jumps the style you have set of padding: 40px; to padding: 80px; it will change the padding of the element, hence, adding more height. Remove this padding to solve your issue.
Side note: Using margin: -%; is not an efficient way to position elements. It will be very unresponsive if you do this. I added display: flex; to .circle-ani to fix the positioning of h2#sec.
//---TIMER---//
var remainingTime = 30;
var isStopped = true;
const countContainer = document.getElementById('sec');
const renderTime = () => {
remainingTime -= 1;
countContainer.innerHTML = remainingTime;
if (remainingTime === 0) {
isStopped = true;
clearInterval(timer);
remainingTime = 30;
}
}
const startTimer = () => {
if (isStopped) {
isStopped = false;
countContainer.innerHTML = remainingTime;
timer = setInterval(renderTime, 1000);
}
}
document.getElementById('start').addEventListener('click', function() {
document.getElementById('circle').classList.add('animate');
});
const startButton = document.getElementById('start');
startButton.onclick = startTimer;
// const stopTimer = () => {
// isStopped = true;
// if (timer) {
// clearInterval(timer);
// }
// }
// const resetTimer = () => {
// isStopped = true;
// clearInterval(timer);
// clearInterval(animate);
// remainingTime = 30;
// countContainer.innerHTML = remainingTime;
// }
//---CARD DECK---//
mobiscroll.settings = {
theme: 'ios',
themeVariant: 'light'
};
mobiscroll.listview('.cardDeck', {
stages: [{
percent: -20,
action: function(event, inst) {
inst.move(event.target, 0);
return false;
}
}, {
percent: 20,
action: function(event, inst) {
inst.move(event.target, 0);
return false;
}
}],
actionable: false
});
// ---BODY ICON ---//
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.body-image')) {
var dropdowns = document.getElementsByClassName("dropdown-list");
showEvent = 'show';
for (var i = 0; i < dropdowns.length; i++) {
var currentElement = dropdowns[i],
currentElementAsString = dropdowns[i].toString();
if (currentElementAsString.localeCompare(showEvent)) {
currentElement.classList.remove('show');
}
}
}
}
body {
font-family: 'Gentium Book Plus', serif;
font-family: 'Noto Serif', serif;
}
/* Stylings */
html {
font-size: 62.5%;
}
.body-image {
display: none;
}
h3,
button,
a {
font-size: 1rem;
}
h2 {
/* display: flex;
flex-direction: column;
justify-content: center; */
font-size: 400%;
line-height: 1;
margin: 0;
z-index: 5;
}
body {
color: rgb(247, 240, 240);
background: #8ad3b8;
/* margin: 100px 250px; */
height: 100%;
width: 99%;
display: flex;
justify-content: center;
align-content: center;
}
.main {
text-align: center;
/* align-content: center; */
margin: 4% auto;
width: 57%;
height: 65%;
background: rgba(12, 134, 85, 1);
border-radius: 20px;
border: 10px solid rgba(12, 134, 85, .4);
box-shadow: 0 0 50px rgba(12, 134, 85, 1);
min-height: 450px;
}
h1 {
margin: 0;
padding: 20px 0 0 0;
font-size: 500%;
}
h3,
section,
.start-timer {
margin: 0;
padding: 10px;
display: inline-block;
border-radius: 20px;
}
h6 {
margin: 0;
padding: 0 0 20px 0;
font-size: 10px;
}
header,
section {
margin: 0px;
}
section+section {
padding: 10px;
}
button {
background: #fe483b;
/* border-radius: 10px; */
border: 2px solid #fe483b;
}
.start-timer-section {
/* margin: 140px 0 0 0; */
outline: none;
display: flex;
flex-direction: column;
margin-top: 15%;
position: relative;
}
/* List */
.dropdown-list,
li,
a {
display: inline-block;
margin: 10px 15px 10px 10px;
color: black;
text-decoration: none;
background: #8ad3b8;
border-radius: 5px;
outline: none;
}
.dropdown-list,
li {
border-radius: 40px;
}
a {
/* display: block; height: 100%; width:100%; */
text-decoration: none;
border-radius: 5px;
color: black;
font-size: 12px;
}
.dropdown-list a:hover {
background: #fe483b;
}
/* .legs{
margin: 10px 30px 0 15px;
padding: 0 20px 0 0;
} */
/* ---THE CARD--- */
.cardDeck {
display: flex;
flex-direction: row;
justify-content: space-evenly;
padding: none;
box-shadow: 0 0 20px rgba(250, 241, 241, 0.6);
margin: 0 0 15px 0;
}
.card-directions {
border: 2px solid purple;
display: flex;
flex-direction: column;
min-height: 150px;
min-width: 35%;
}
.card-picture {
border: 2px solid yellow;
visibility: none;
min-width: 35%;
}
.button-timer {
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
border: 2px solid pink;
/* min-height: 150px; */
min-width: 15%;
flex-wrap: wrap;
}
h3 {
font-size: 15px;
}
/* ---TIMER ANIMATION--- */
body {
padding: 20px;
}
/* div.circle-ani {
transition: 4s ease;
position: relative;
width: 0px;
height: 0px;
text-align: center;
background: hsl(4, 99%, 61%, .7);
color: white;
border-radius: 100%;
padding: 40px;
overflow: hidden;
margin-bottom: -35%;
}
.animate {
transform: scale(1.9);
-webkit-transform: scale(1.9);
-ms-transform: scale(1.9);
} */
.circle-ani {
position: relative;
width: 0px;
height: 0px;
text-align: center;
background: hsl(4, 99%, 61%, .7);
color: white;
border-radius: 100%;
padding: 40px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
div.animate {
/* animation properties */
animation-name: my-animation;
animation-duration: 3s;
animation-direction: alternate;
animation-iteration-count: 10;
animation-timing-function: ease-in-out;
/* other properties */
/* position: relative;
width: 0px;
height: 0px;
text-align: center;
background: hsl(4, 99%, 61%, .7);
color: white;
border-radius: 100%;
padding: 40px;
overflow: hidden;
margin-bottom: -35%; */
}
#keyframes my-animation {
from {
background-color: hsl(4, 99%, 61%, .7);
}
to {
padding;
0;
}
}
/* ---Accessibility--- */
#media screen and (max-width: 1111px) {
body {
/* background: red; */
}
main {
width: 100%;
}
h1 {
padding: none;
margin: -7% 0 0 0;
}
h6 {
display: none;
}
.body-image {
padding: -10px;
}
.cardDeck {
display: flex;
flex-direction: row;
justify-content: space-evenly;
flex-wrap: wrap;
padding: none;
margin: 0 0 15px 0;
}
.card-directions {
min-height: auto;
display: flex;
flex-direction: row;
width: 100%;
}
.card-picture {
display: flex;
flex-direction: row;
width: 43%;
visibility: none;
/* min-height: 150px;
min-width: 150px; */
}
.button-timer {
display: flex;
flex-direction: row;
width: 43%;
min-height: 50px;
min-width: 150px;
}
.start-timer {
margin: auto;
outline: none;
}
/* .dropdown-list, li, a{
display: none;
} */
/* // --- DROPDOWN MENU--- // */
.body-image {
display: flex;
max-height: 30%;
max-width: 30%;
margin: 0;
padding: 0;
z-index: 5;
background: rgba(12, 134, 85, 1);
}
a {
cursor: pointer;
}
.dropdown {
display: flex;
justify-content: center;
align-content: center;
flex-wrap: wrap;
}
.dropdown li {
letter-spacing: .5px;
display: flex;
justify-content: center;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-list {
display: none;
position: absolute;
min-width: 150px;
box-shadow: 0px 10px 16px 10px rgba(0, 0, 0, 0.5);
z-index: 1;
margin: 0;
margin-top: -35%;
padding: 0;
}
/* Links inside the dropdown */
.dropdown-list li {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: center;
margin: 0;
}
/* Change color of dropdown links on hover */
.dropdown-list a:hover {
background-color: #fe483b
}
.show {
display: block;
}
}
#media screen and (max-width: 911px) {
body {
/* background: purple; */
}
.card-picture,
.button-timer {
width: 40%;
}
}
#media screen and (max-width: 679px) {
body {
/* background: orange; */
}
.card-picture,
.button-timer {
width: 39%;
}
h1 {
font-size: 300%;
padding: 0;
}
}
#media screen and (max-width: 649px) {
body {
/* background: yellow; */
}
.card-picture,
.button-timer {
width: 36%;
}
body {
margin: 0;
}
}
#media screen and (max-width: 619px) {
body {
/* background: pink; */
}
html {
height: 60%;
margin: 0;
}
.card-picture,
.button-timer {
width: 20%;
height: 200px;
flex-direction: column;
}
.main {
width: 100%;
height: 150%;
min-height: none;
margin-left: 5px;
}
.dropdown-list {
margin: -40% 0 20% 0;
}
}
#media screen and (max-width: 430px) {
.main {
height: 155%;
}
.dropdown-list {
margin-top: -100%;
margin-bottom: 50%;
width: 40%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fetch a Stretch</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<link href="https://fonts.googleapis.com/css2?family=Gentium+Book+Plus&family=Noto+Serif&display=swap" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<main class="main">
<header>
<!-- <img id = "menu" onclick = "dropdownFunction()" class="body-image" src="body.ico" alt ="body" > -->
<a onclick="myFunction()" title="Body Parts" class="body-image body-ico"><img id="menu" class="body-image" src="body.ico"> </a>
<h1>Fetch a Stretch</h1>
</header>
<section>
<h6>Welcome to moving better!</h6>
<section class="cardDeck">
<section class="card-directions">
<h3>Stretch: Lorem ipsum dolor sit.</h3>
<h3>Explanation: Lorem ipsum, dolor sit amet consectetur adipisicing elit. Tenetur, autem? Iusto itaque quae perspiciatis illo nostrum aspernatur voluptatum, libero sit provident accusantium explicabo est harum omnis quod? Amet, maiores inventore.</h3>
</section>
<section class="card-picture">
<h3>Picture:</h3>
</section>
<section class="button-timer">
<div id="circle" class="circle-ani">
<h2 id="sec">30</h2>
</div>
<div class="start-timer-section">
<button onclick="start()" id='start' class="start-timer">Start Timer</button>
</div>
</section>
</section>
<span id="dropdownClick" class="dropdown">
<ul id = "myDropdown" class="dropdown-list">
<li class="neck">Neck</li>
<li class="shoulders">Shoulders</li>
<li class="hands">Hands</li>
<li class="back">Low Back</li>
<li class="hips">Hips</li>
<li class="legs">Legs</li>
</ul>
</span>
</section>
</main>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
Just learning React!
I need help with why this menu overlaps like this image show:
The red ring, images go under the Menu and there's a horizontal scrollbars but there should not be one.
See CodeSandbox
This is the wrapper for the left Menu and the right MasonryGrid.
import React from 'react'
import '../Styles//Components/Wrapper-style.scss'
import Menu from './Menu'
const Wrapper = (props) => {
return (
<div className="wrapper">
<div className="menu-container">
<Menu />
</div>
<div className="children-container">
{props.children}
</div>
</div>
)
}
export default Wrapper
And this is the SCSS for the Wrapper
.wrapper{
display: flex;
flex-direction: column;
color: white;
width: 100vw;
height: 100vh;
background-color: rgba(255, 255, 255, 0.479);
.menu-container{
width: 100%;
height: 10%;
}
.children-container{
position: relative;
height: 85%;
.content-container{
&.page-enter {
opacity: 0;
}
&.page-enter-active {
position: absolute;
left: 0;
top: 0;
width: 100%;
opacity: 1;
transition: opacity 600ms ease-in-out;
}
&.page-exit {
opacity: 1;
}
&.page-exit-active {
opacity: 0;
transition: opacity 600ms ease-in-out;
position: absolute;
left: 0;
top: 0;
width: 100%;
}
}
}
}
#media(min-width:576px){
.wrapper {
flex-direction: row;
width: 96vw;
height: 96vh;
border-radius: 5px;
.menu-container {
height: 100%;
padding: 0;
min-width: 20%;
max-width: 20%;
}
.children-container {
height: 100%;
min-width: 80%;
max-width: 80%;
}
}
}
Any ides why dies happened would be grate?
If you want to remove the horizontal scrollbar, this will help.
Please add the marked line in AlbumPage-style.scss file.
.album.content-container .album-photos-container
{
position: relative;
display: flex;
flex-flow: wrap;
justify-content: center;
overflow-x: hidden; <-------
}
I have a React Login screen with black background set using CSS Styling. The login screen is quite elementary at this point which comprises of 3 input tag username, password and submit respectively.
All i am trying to do right now is change the background of the login screen with slide down effect (height 0 to height $loginScreenHeight) whenever the mouse moves.
I got it working as expected but with a slight side-effect. The side-effect is whenever the mouse moves the initial background goes away momentarily and the new background starts sliding down.
I want the new background to start sliding on top of the old background and cover it up. Can some Css expert please throw a light on what i am missing here?
Following is my code.
import React from "react";
import axios from "axios";
import { connect } from "react-redux";
import { userlogin } from "./../action/userLogin";
class Login extends React.Component {
state = {
email: "",
passwd: "",
loginStatus: "",
mouseOverLogin: false
};
enteruname = e => this.setState({ email: e.target.value });
enterpasswd = e => this.setState({ passwd: e.target.value });
submitCredentials = e => e.preventDefault();
render() {
return (
<div
className="login"
onMouseMove={() => this.setState({ mouseOverLogin: true })}
>
<form
onSubmit={this.submitCredentials}
className={
this.state.mouseOverLogin ? "loginForm animateLogin" : "loginForm"
}
>
<p>Login</p>
<hr />
<input
className="uname"
placeholder="Enter Username"
type="email"
name="email"
value={this.state.email}
onChange={this.enteruname}
/>
<input
className="passwd"
placeholder="Enter Password"
type="password"
name="passwd"
value={this.state.passwd}
onChange={this.enterpasswd}
/>
<button className="loginBtn">Login</button>
</form>
</div>
);
}
}
export default connect()(Login);
CSS File:-
.login {
width: 100vw;
height: 100vh;
overflow: hidden;
position: absolute;
top: 0vh;
left: 0vw;
}
.loginForm {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
top: 25vh;
left: 38vw;
width: 27vw;
height: 54vh;
background: rgba(0, 0, 0, 0.7);
position: relative;
z-index: 1000;
border-radius: 20px;
}
.login form input {
margin: 0 auto;
width: 24vw;
height: 6vh;
border-radius: 20px;
outline: none;
background: rgba(42, 27, 61, 0.6);
color: white;
text-align: center;
font-size: 1.2rem;
}
.uname {
position: absolute;
top: 18vh;
}
.uname:focus,
.passwd:focus {
background: rgba(42, 27, 61, 0.6);
}
.passwd {
position: absolute;
top: 28vh;
}
.loginBtn {
position: absolute;
width: 50%;
height: 5vh;
left: 25%;
text-decoration: none;
outline: none;
top: 38vh;
border-radius: 20px;
background: rgba(42, 27, 61, 0.6);
color: white;
}
.login form input::placeholder {
color: white;
text-align: center;
font-size: 1.2rem;
}
.login form p {
color: white;
font-size: 25px;
width: 24vw;
position: absolute;
top: 5vh;
left: 2vw;
}
.animateLogin {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 25vh;
left: 38vw;
width: 27vw;
animation: slideDown 2s 1 forwards ease-in-out;
z-index: 0;
// transition: all 280ms ease-in-out;
}
#keyframes slideDown {
from {
height: 0;
background: rgba(0, 0, 0, 0.7);
}
to {
background: $navlink;
height: 54vh;
}
}
hr {
position: absolute;
top: 12vh;
width: 24vw;
height: 1px;
background: white;
}
the height change to 0 is a problem because the "old background" is set on the element with 0 height.
I wrote 2 POC that can help you:
.a,
.b {
margin: 10px;
padding: 10px;
height: 30px;
text-align: center;
border: solid 1px blue;
background: green;
position: relative;
}
.a:hover {
animation: slidebg 2s;
box-shadow: inset 0 50px 0 0 blue;
}
#keyframes slidebg {
0% {
box-shadow: inset 0 0 0 0 blue;
}
100% {
box-shadow: inset 0 50px 0 0 blue;
}
}
.b-bg {
position: absolute;
height: 0;
top: 0;
left: 0;
background: blue;
width: 100%;
}
.b span {
position: relative;
z-index: 10;
}
.b:hover .b-bg {
animation: slidebg2 2s;
height: 100%;
}
#keyframes slidebg2 {
0% {
height: 0;
}
100% {
height: 100%;
}
}
<div class="a">link</div>
<div class="b">
<div class="b-bg"></div>
<span>link</span>
</div>
I am simply trying to make this gauge smaller. When I try and do that (modify the container class) it warps the whole gauge element. I change the position to relative and the edge of the gauge seems to break. Any ideas on how to scale this without breaking the gauge? I eventually will nest this inside of a column in bootstrap and just trying to get this working on a basic level. Any advice on this css issue would be helpful
const Gauge = Vue.extend({
template: `
<div class="container">
<div class="gauge-bg"></div>
<div class="gauge-middle"></div>
<div class="gauge-overlay" :style="{ transform: rotate }"></div>
<div class="gauge-data">
<span>{{ percentage }}%</span>
</div>
</div>
`,
props: ['percentage'],
computed: {
rotate() {
const v = this.percentage * 180 / 100;
return `rotate(${v}deg)`;
} } });
new Vue({
el: '#app',
components: {
Gauge
}
});
body {
background-color: #4d4d4d;
}
.container {
width: 400px;
height: 200px;
position: absolute;
top: 0;
overflow: hidden;
}
.gauge-bg {
z-index: 1;
width: 400px;
height: 200px;
position: absolute;
background-color: #a3f6ba;
border-radius: 250px 250px 0 0;
}
.gauge-middle {
z-index: 3;
position: absolute;
background-color: #4d4d4d;
width: 250px;
height: calc(250px / 2);
top: 75px;
margin-left: 75px;
margin-right: auto;
border-radius: 250px 250px 0 0;
}
.gauge-overlay {
z-index: 2;
position: absolute;
background-color: #5df086;
width: 400px;
height: 200px;
top: 200px;
border-radius: 0 0 200px 200px;
transform-origin: center top;
}
.gauge-data {
z-index: 4;
color: #5df086;
position: absolute;
width: 400px;
bottom: 0;
text-align: center;
font-size: 24px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<gauge percentage="33"></gauge>
</div>
The quick and dirty solution is to use transform: scale():
.container {
transform: scale(.5) translateY(-100%);
transform-origin: 0 100%;
}
combined with a font-size increase (optional).
Vue.config.devtools = false;
Vue.config.productionTip = false;
const Gauge = Vue.extend({
template: `
<div class="container">
<div class="gauge-bg"></div>
<div class="gauge-middle"></div>
<div class="gauge-overlay" :style="{ transform: rotate }"></div>
<div class="gauge-data">
<span>{{ percentage }}%</span>
</div>
</div>
`,
props: ['percentage'],
computed: {
rotate() {
const v = this.percentage * 180 / 100;
return `rotate(${v}deg)`;
} } });
new Vue({
el: '#app',
components: {
Gauge
}
});
body {
background-color: #4d4d4d;
}
.container {
width: 400px;
height: 200px;
position: absolute;
top: 0;
overflow: hidden;
transform: scale(.5) translateY(-100%);
transform-origin: 0 100%;
}
.gauge-bg {
z-index: 1;
width: 400px;
height: 200px;
position: absolute;
background-color: #a3f6ba;
border-radius: 250px 250px 0 0;
}
.gauge-middle {
z-index: 3;
position: absolute;
background-color: #4d4d4d;
width: 250px;
height: calc(250px / 2);
top: 75px;
margin-left: 75px;
margin-right: auto;
border-radius: 250px 250px 0 0;
}
.gauge-overlay {
z-index: 2;
position: absolute;
background-color: #5df086;
width: 400px;
height: 200px;
top: 200px;
border-radius: 0 0 200px 200px;
transform-origin: center top;
}
.gauge-data {
z-index: 4;
color: #5df086;
position: absolute;
width: 400px;
bottom: 0;
text-align: center;
font-size: 48px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<gauge percentage="33"></gauge>
</div>
The proper solution would be to rewrite its CSS so that it takes a variable ($gaugeWidth !?) and factors in all its hard-coded sizes so it scales correctly (what the original dev should have done in the first place).
I have this menu (this happens also with the website text)
<div id="container" class='container'>
<div class='meta-background'></div>
<section class='meta-container'>
<div class="meta-menu meta-menu-top">
<ul>
<li>testsas</li>
<li>fdadasdasdas</li>
<li>dsdasdsadasdsa</li>
</ul>
<span class="meta-title">WEBSITE</span>
</div>
<div class="meta-menu meta-menu-bottom"></div>
</section>
</div>
css:
/* contaner */
/* * { padding:0; margin:0; box-sizing: border-box;} */
.container {
max-width: 2380px;
margin-left: auto;
margin-right: auto;
}
.meta-container {
display: flex;
/* -webkit-box-pack: center; */
/* -ms-flex-pack: center; */
justify-content: center;
}
.meta-background {
position: fixed;
margin-left: auto;
margin-right: auto;
z-index: -1;
background-size: cover;
background-repeat: no-repeat;
-webkit-filter: blur(10px);
filter: blur(10px);
top: 0;
right: 0;
bottom: 0;
left: 0;
/* background-image: url('./assets/img/3.jpg'); */
}
.meta-title {
color: white;
position: absolute;
bottom: 10px;
display: block;
}
/* menus */
.meta-menu-top {
background: #252422;
color: #959595;
border-radius: 0px 0px 10px 10px;
/* top: 0px; */
position: absolute;
height: 48%;
width: 360px;
opacity: 0.7;
display: flex;
justify-content: center;
}
.meta-menu-top ul {
padding: 0;
margin-top: 30%;
}
.meta-menu-top li {
list-style-type: none;
display: block;
}
.meta-menu-bottom {
background: #eef1f5;
color: white;
border-radius: 10px 10px 0px 0px;
/* bottom: 0px; */
position: absolute;
height: 48%;
width: 360px;
}
and the JS to hide/show the menu
let menutop = $('.meta-menu-top'),
menubottom = $('.meta-menu-bottom');
//set cookie for future preference
//
//
//get cookie if first run or not
//
//
let upDown = 0,
duration = 1;
let tlshow = new TimelineMax({ paused: true });
tlshow.fromTo(menutop, duration, {top: '-40%' } ,{ top: 0, ease: Power3.easeInOut })
.fromTo(menubottom, duration, { bottom: '-40%' },{ bottom: 0, ease: Power3.easeInOut }, '-=' + duration);
let tlhide = new TimelineMax({ paused: true });
tlhide.fromTo(menutop, duration, { top: 0 } ,{ top: "-40%", ease: Power3.easeInOut })
.fromTo(menubottom, duration, { bottom: 0 },{ bottom: "-40%", ease: Power3.easeInOut }, '-=' + duration);
menutop.on("click",function(){
console.log("CLICKED MENUTOP");
if(upDown == 0) {
tlhide.restart();
upDown = 1;
}
else {
tlshow.restart();
upDown = 0;
}
});
codepen here: https://codepen.io/giventofly/pen/RxMRMR
on chrome works okay, on firefox the meta-menu-top/bottom are pushed to the left and rearranged to center again.
tried with the webkit/moz prefix and even using normalize.css with no results.
what could be?
Since you use position: absolute for top and bottom menus, you have no need to use display: flex for the parent element. Below is an example of working code (a little simplified).
var metaContainer = document.querySelector('.meta-container');
var menuTop = document.querySelector('.meta-menu-top');
menuTop.onclick = close;
function close() {
metaContainer.classList.toggle('closed');
}
body {
overflow: hidden;
}
.meta-menu {
left: 50%;
transform: translateX(-50%);
}
.meta-menu-bottom,
.meta-menu-top {
height: 48%;
position: absolute;
width: 360px;
transition: 300ms;
}
.meta-menu-top {
align-items: center;
background: #252422;
color: #959595;
display: flex;
border-radius: 0px 0px 10px 10px;
justify-content: center;
opacity: 0.7;
text-align: center;
top: 0;
}
.meta-menu-top ul {
padding: 0;
margin-bottom: 30px;
}
.meta-menu-top li {
list-style-type: none;
}
.meta-title {
color: white;
bottom: 10px;
left: 0;
position: absolute;
width: 100%;
}
.meta-menu-bottom {
background: #eef1f5;
bottom: 0;
border-radius: 10px 10px 0px 0px;
color: white;
}
.closed .meta-menu-top {
top: -48%;
margin-top: 35px;
}
.closed .meta-menu-bottom {
bottom: -48%;
margin-bottom: 30px;
}
<div id="container" class='container'>
<div class='meta-background'></div>
<section class='meta-container'>
<div class="meta-menu meta-menu-top">
<ul>
<li>testsas</li>
<li>fdadasdasdas</li>
<li>dsdasdsadasdsa</li>
</ul>
<div class="meta-title">WEBSITE</div>
</div>
<div class="meta-menu meta-menu-bottom"></div>
</section>
</div>
It seems that there is a Firefox-specifc bug TweenMax
The way that the elements are centered in your page is by the use of the flex display, which is totally fine. However, Firefox rendering has major issues when the left style being unspecified. This is what causes both animated elements to randomly move.
A simple way to overcome this issue is to specify a left value for your element; i.e. add the css below. Or alternatively, you can avoid the use of display flex, unless it is important for you.
.meta-menu-top {
left: calc(50% - 180px);
}
.meta-menu-bottom {
left: calc(50% - 180px);
}
Here is an updated CodePen