Home > Software engineering >  How do I center a text above a section in flex display mode
How do I center a text above a section in flex display mode

Time:07-10

I trying to center the text "Game Over" above the 3*4 grid

the website image

css code

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Lato', sans-serif;
  height: 100vh;
  display: flex;
  align-items: center;
  background-image: linear-gradient(to right top, #9200ff, #8c1cf8, #8729f0, #8232e8, #7e39e0);
}

.memory-game {
  width: 640px;
  height: 640px;
  margin: auto;
  display: flex;
  flex-wrap: wrap;
  perspective: 1000px;
}

(stack overflow is giving me not enough description so this is some lorem ipsum)

CodePudding user response:

As you have given display: flex to body, try to change the flex direction for body. For example -

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Lato', sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-image: linear-gradient(to right top, #9200ff, #8c1cf8, #8729f0, #8232e8, #7e39e0);
}

.memory-game {
  width: 640px;
  height: 640px;
  margin: auto;
  display: flex;
  flex-wrap: wrap;
  perspective: 1000px;
}
  • Related