Can't position absolute Div even though parents are relative

can definition
can synonym
can verb
can noun meaning
can bus
can airport
can network
can band

For some reason when I put on the id "enterGame" position: absolute div disappears. Even if I add to body or html tag position: relative I still can't see the div.

Relevant code:

html {
  height: 100vh;
}

body {
  background-image: linear-gradient(lightblue, pink);
  margin: 0 auto;
}

* {
  font-family: 'Oswald', sans-serif;
  letter-spacing: 1vw;
}

h1 {
  font-size: 5vw;
  text-align: center;
  margin: 0 auto;
  cursor: default;
}

#enterGame {
  height: 50vh;
  background-color: white;
  border-top: 5px solid black;
  border-bottom: 5px solid black;
}
<body>
  <h1>Tic Tac Toe</h1>
  <div id="enterGame"></div>
  <script src="script.js"></script>
</body>

As soon as you add position: absolute it disappears because it doesn't have a width. Try setting width: 100vw and it appears again.

Can, Can was the leading avant-garde rock group of the 70s. Can experimented with noise, synthesizers, non-traditional music, cut-and-paste techniques, and, most� Can definition, to be able to; have the ability, power, or skill to: She can solve the problem easily, I'm sure. See more.


when you add absolute you need to give the div some width

html {
    height: 100vh;
}

body {
    background-image: linear-gradient(lightblue , pink);
    margin: 0 auto;
    position:relative;
}

* {
    font-family: 'Oswald', sans-serif;
    letter-spacing: 1vw;
}

h1 {
    font-size: 5vw;
    text-align: center;
    margin: 0 auto;
    cursor: default;
}

#enterGame {
    height: 50vh;
    width:200px;
    background-color: white;
    border-top: 5px solid black;
    border-bottom: 5px solid black;
    position:absolute;
    
}
<body>
    <h1>Tic Tac Toe</h1>
    <div id="enterGame"></div>

</body>

Can, VerbEdit. can (third-person singular simple present can, present participle -, simple past could, past participle (obsolete except in adjectival use) couth). Define can. can synonyms, can pronunciation, can translation, English dictionary definition of can. to be able to, have the power or skill to: I can take a bus to the


You already have the answers, I'll give you the tool to deal with these kinds of problems, know it and you'll be able to solve the problem better yourself in the future, which is the Dev Tool- Inspector.


Now try inspecting the DOM, as you can see in the image below with the inspector (F12/Ctrl+Shift+I on Windows/Linux), it shows that the element #enterGame has the size of 0x173.846, then => either its height or width is 0.

If you ain't already know which number is width, which is height then you can try inspecting the neighbor h1, you'll see that it's 375x21, so it's obvious that 375 is the width, then => the #endterGame disappears is because it doesn't have the width. Now try adding width: 100% (like the answers above said) will solve the problem.

html {
    height: 100vh;
}

body {
    background-image: linear-gradient(lightblue , pink);
    margin: 0 auto;
}

* {
    font-family: 'Oswald', sans-serif;
    letter-spacing: 1vw;
}

h1 {
    font-size: 5vw;
    text-align: center;
    margin: 0 auto;
    cursor: default;
}

#enterGame {
    height: 50vh;
    background-color: white;
    border-top: 5px solid black;
    border-bottom: 5px solid black;
    position: absolute;
    width: 100%;
}
<body>
    <h1>Tic Tac Toe</h1>
    <div id="enterGame"></div>
</body>

The Official CAN / Spoon Records Website, 1.4Used to indicate that something is typically the case. 'antique clocks can seem out of place in modern homes'. More example sentences. can definition: 1. to be able to: 2. used to say that you can and will do something: 3. to be allowed to: . Learn more.


can, can noun [C] (CONTAINER). a metal container, esp. a closed, cylindrical container in which food and drink are packaged:. 110 synonyms of can from the Merriam-Webster Thesaurus, plus 97 related words, definitions, and antonyms. Find another word for can. Can: to bring (as an action or operation) to an immediate end.


Can, Word forms � 1. countable noun A can is a metal container in which something such as food, drink, or paint is put. � 2. verb [usually passive] When food or drink is� Can (stylised as CAN) was a German experimental rock band formed in Cologne in 1968 by the core quartet of Holger Czukay (bass, tape editing), Irmin Schmidt (keyboards), Michael Karoli (guitar), and Jaki Liebezeit (drums).


CAN, can 2. (kăn). n. 1. A usually cylindrical metal container. 2. Find the latest Canaan Inc. (CAN) stock quote, history, news and other vital information to help you with your stock trading and investing.