I want to center align content inside a grid item, centered horizontally but not vertically. Check it out on JSfiddle: http://jsfiddle.net/6zs8ydhf/
.container { display: grid; grid-template-columns: 200px auto; grid-template-rows: 400px 200px; } .item { border: 1px solid #111; } .item2 h1 { display: flex; align-items: center; justify-content: center; }
<div class="container"> <div class="item item1"> <h1>1</h1> </div> <div class="item item2"> <h1>2 应该居中</h1> </div> <div class="item item3"> <h1>3</h1> </div> </div>
Here's what you need to do: