I have wanted to make a button that is aligned horizontally underneath the text that says "Bubbles". I have tried flex already and in the snippet I try it with transform but regardless of what I try I wont get the desired outcome. So please Help!
section {
width: 100%;
height: 100vh;
overflow: hidden;
background: #1F69FA;
display: flex;
justify-content: center;
align-items: center;
}
section container {
height: 200px;
position: relative;
border: 3px solid green;
}
section center {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
<section>
<div >
<div >
<button type="button" onclick="next()"> Next </button>
</div>
</div>
</section>
CodePudding user response:
Since you've got the container class but aren't actually using it, we can just make it a flex column and put both elements inside of it
function Seifenblasen_blasen() {
const section = document.querySelector('section')
const createElement = document.createElement('spawn')
var size = Math.random() * 60;
createElement.style.width = 30 size 'px';
createElement.style.height = 30 size 'px';
createElement.style.left = Math.random() * innerWidth "px";
section.appendChild(createElement);
setTimeout(() => {
createElement.remove()
}, 8000)
}
const Blaseninterval = setInterval(Seifenblasen_blasen, 100)
{
margin: 0;
padding: 0;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
section {
width: 100%;
height: 100vh;
overflow: hidden;
background: #1F69FA;
display: flex;
justify-content: center;
align-items: center;
}
section h2 {
font-size: 10em;
color: #333;
margin: 0 auto;
text-align: center;
font-family: consolas;
}
section spawn {
position: absolute;
bottom: -80px;
background: transparent;
border-radius: 50%;
pointer-events: none;
box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5);
animation: animate 4s linear infinite;
}
section spawn:before {
content: '';
position: absolute;
width: 100%;
height: 100%;
transform: scale(0.25) translate(-70%, -70%);
background: radial-gradient(#fff, transparent);
opacity: 0.6;
border-radius: 50%;
}
@keyframes animate {
0% {
transform: translateY(0%);
opacity: 1;
}
99% {
opacity: 1;
}
100% {
transform: translateY(-2000%);
opacity: 0;
}
section span {
margin-top: 700px;
font-size: 1em;
color: #333;
margin: 0 auto;
font-family: consolas;
background-color: #1F69FA;
border: none;
position: absolute;
}
section container {
height: 200px;
position: relative;
border: 3px solid green;
}
section center {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
<section>
<div >
<h2> Bubbles </h2>
<button type="button" onclick="next()"> Next </button>
</div>
</section>