My article class = "stage"
in the following code doesn't align with the centre of the document. I have other sections and divs which do align, but not this one. Can aynone help me? tysm
I have this HTML code:
:root {
--main-font: "Inter", sans-serif;
--clock-font: "alarm clock", sans-serif;
--font-size: 15px;
--white-1: #eee;
--black-1: #00040a;
--blue-1: #1653b4;
--blue-2: #c4cfdd;
--container-width: 1200px;
}
html {
box-sizing: border-box;
color: var(--black-1);
font-family: var(--main-font);
font-size: var(--font-size);
scroll-behavior: smooth;
background-color: var(--blue-2);
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
overflow-x: hidden;
}
.section {
padding: 10rem;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: var(--container-width);
min-height: 100vh;
text-align: center;
justify-content: center;
align-items: center;
}
.stage {
font-size: 50px;
font-family: var(--clock-font);
background-color: var(--white-1);
text-align: center;
display: flex;
align-items: center;
justify-content: center;
margin-right: auto;
height: 50vh;
width: 67vw;
border-radius: 25px;
border: 0;
z-index: 97;
box-shadow: inset 0px 0px 10px 5px rgb(196, 207, 221, 0.5);
}
.ball {
width: 50px;
height: 50px;
border-radius: 50rem;
background-color: var(--blue-1);
box-shadow: 0px 0px 10px 5px rgba(151, 182, 221, 0.5);
transition: transform 0.2s ease-out;
z-index: 97;
}
<section id="seccion2" class="section">
<h2>Eventos del teclado</h2>
<article class="stage">
<div class="ball"></div>
</article>
</section>
I've tried playing with the margins of the "stage" and the justify-content of the section, but I couldn't come up with a solution.
You had given margin and padding to the section that's why it was not aligning in center
:root {
--main-font: "Inter", sans-serif;
--clock-font: "alarm clock", sans-serif;
--font-size: 15px;
--white-1: #eee;
--black-1: #00040a;
--blue-1: #1653b4;
--blue-2: #c4cfdd;
--container-width: 1200px;
}
html {
box-sizing: border-box;
color: var(--black-1);
font-family: var(--main-font);
font-size: var(--font-size);
scroll-behavior: smooth;
background-color: var(--blue-2);
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
overflow-x: hidden;
}
.section {
padding: 10rem 0;
width: 100%;
min-height: 100vh;
text-align: center;
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
}
.stage {
font-size: 50px;
font-family: var(--clock-font);
background-color: var(--white-1);
text-align: center;
display: flex;
align-items: center;
justify-content: center;
height: 50vh;
width: 67vw;
border-radius: 25px;
border: 0;
z-index: 97;
box-shadow: inset 0px 0px 10px 5px rgb(196, 207, 221, 0.5);
}
.ball {
width: 50px;
height: 50px;
border-radius: 50rem;
background-color: var(--blue-1);
box-shadow: 0px 0px 10px 5px rgba(151, 182, 221, 0.5);
transition: transform 0.2s ease-out;
z-index: 97;
}
<section id="seccion2" class="section">
<h2>Eventos del teclado</h2>
<article class="stage">
<div class="ball"></div>
</article>
</section>