I am a beginner-ish front end Developer, and I have done something with my css stylesheet that whatever I do I cant seem to get my buttons on the page to be aligned as if it was a calculator? I know many of you would know this so, thank you for your help forward.
.mainContent button {
font-family: inherit;
padding: 1em 2em;
border: 3px solid black;
width: 2em;
background-color: #edf2fb;
color: black;
border-radius: 0.35em;
font-size: 1.2em;
margin: 0.1em auto;
display: flex;
justify-content: center;
}
<section class="mainContent">
<button id="result">Result</button>
<button id="clear">C</button>
<button id="one">1</button>
<button id="two">2</button>
<button id="three">3</button>
<button id="four">4</button>
<button id="five">5</button>
<button id="six">6</button>
<button id="seven">7</button>
<button id="eight">8</button>
<button id="nine">9</button>
<button id="zero">0</button>
<button id="plus">+</button>
<button id="minus">-</button>
<button id="multiply">*</button>
<button id="divide">/</button>
<button id="equal">=</button>
<button id="comma">,</button>
<input type="text" placeholder="Your calculations">
</section>
How do you do this? They are just lined up in the center one by one going down!
I tried all this justify content, text align, grid but I cant seem to get any to work
3
Answers
Try This
You can use
display:grid;
andgrid-template-columns
attribute tomainContent
class not to.mainContent button
class for aligning the buttons properly. Additionally i put theinput
element in to the different div which hascalculation
class and i gave it inline css values. Finally addeddisplay:flex;
andjustify-content:center;
attributes for aligning theinput
element (.calculation class) to the center. I hope it works for you.