-2

Hey guys I am making a directory on my site and want to make the text be in the very middle not center and at not at the top I want it to be in the very middle of the document

<center>
  <button href="#">Download!</button>
</center>
VXp
  • 11,598
  • 6
  • 31
  • 46
Skilliam
  • 3
  • 3

2 Answers2

0

You could use the following:

.box {
  width: var(--box-size);
  height: var(--box-size);
  line-height: var(--box-size);
  background: red;
  color: white;
  text-align: center;
}

:root {
  --box-size: 100px;
}
<div class="box">
  Center
</div>

Or as suggested with flexbox:

.box {
  width: var(--box-size);
  height: var(--box-size);
  background: red;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
}

:root {
  --box-size: 100px;
}
<div class="box">
  Center
</div>
SuperDJ
  • 7,488
  • 11
  • 40
  • 74
  • Looks like it didnt work for me I added the div tags at the start and ended it of all my headers and paragraphs and it just went down word by word on the left – Skilliam Sep 01 '18 at 19:24
  • If you want a real solution add your code to the question and with CSS of what you have already tried – SuperDJ Sep 01 '18 at 19:25
0

Give css style to your DOM

.wrapper {
    display: table;
    margin: 0 auto;
}

.box {
  background-color: blue;
  color: white;
  text-align: center;
  vertical-align: middle;
  width: 100px;
  height: 100px;
  display: table-cell;
}
<div class="wrapper">
   <div class="box">
       Center
   </div>
</div>
seunggabi
  • 1,699
  • 12
  • 12