Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

<div> center of screen not text of element

I want elements of div to center of the screen but not text inside it. For example Sample size (n) should be aligned left in the code below.

.center-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
<div class='center-screen'>
<label class='input2' for='pop'><b>Population proportion (p)</b></label>
<input class='input2' type='number' step='0.01' id='pop' value='0.43'/>
<label class='input2' for='samplesize'><b>Sample size (n)</b></label>
<input class='input2' type='number' id='samplesize' value='40'/>
<input class='input2' type='button' value='Calculate' />
</div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can wrapped with a div flex container. Then you align only the child container. Afterwards remove the text-align form the child container.

.container {
  display: flex;
  justify-content: center;
}
.center-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  
}
<div class="container">
  <div class='center-screen'>
    <label class='input2' for='pop'><b>Population proportion (p)</b></label>
    <input class='input2' type='number' step='0.01' id='pop' value='0.43'/>
    <label class='input2' for='samplesize'><b>Sample size (n)</b></label>
    <input class='input2' type='number' id='samplesize' value='40'/>
    <input class='input2' type='button' value='Calculate' />
  </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading