It has never been for me before. I tried text-align: center
in all places and all of them do not work. They work vertically, but they do not work horizontally. I am trying to make it work both horizontally and vertically for each window.
This is my code:
.boxes { height:100%; } .box { width: 33%; height: 20%; display: -webkit-flex; } .box p { display: flex; align-items: center; } .box1 { background: magenta; } .box2 { background: cyan; } .box3 { background: yellow; } .box4 { background: orange; } .box5 { background: purple; } * { margin:0; padding:0; } html, body { height: 100%; }
<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="tabletest.css" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div class="boxes"> <div class="box box1"><p>Box 1</p></div> <div class="box box2"><p>Box 2</p></div> <div class="box box3"><p>Box 3</p></div> <div class="box box4"><p>Box 4</p></div> <div class="box box5"><p>Box 5</p></div> </div> </body> </html>
I also try to stick to a percentage in order to have a responsive design.
EDIT: this might seem like a duplicate for another post, but my question here is how to get the text aligned right in the center (both vertically and horizontally) while maintaining the order of the boxes.
source share