P粉4781887862023-09-06 14:48:14
You can use flex instead of grid so you can do this very easily.
.outer { position: fixed; width: 100%; height: 100%; background: black; display: flex; justify-content: center; align-items: center; } .inner { padding: 30px; background: white; width: 100%; }
<div class="outer"> <div class="inner">Some content here</div> </div>
P粉0200855992023-09-06 12:43:41
Instead of using place-content
, you can use place-self
on grid items.
.outer { position: fixed; inset: 0; background: black; display: grid; } .inner { padding: 30px; background: white; width: 100%; max-width: 500px; place-self: center; }
<div class="outer"> <div class="inner">Some content here</div> </div>