0

as the title states, I have two divs in a container and am trying to center one div and have the other one on the right-hand side of the container. I have tried using a bunch of different things but run into one issue or another. My main concern is having a responsive web design as when my page gets smaller the site should be able to maintain its structure and not mesh together.

here is my HTML.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="stylepoints.css">
    <script src="magic.js" defer></script>
    <title>Words Per Minute Test</title>    
</head>
<body>
    <div class="topcontainer">
        <h1 class="titlebar" id="title-bar">Words Per Minute Test </h1>
        <div class="highscore" id="high-score">High Score: 20 </div>
    </div>
    <div class="timer" id="timer">60</div>
    <div class="container">
        <div class="word" id="word">top</div>
    </div>
    <textarea class="input" id="input" autofocus></textarea>
</body>
</html>

and here is my CSS

*{
    box-sizing: border-box;
     border-style: solid; 
     border-color: white;
}

body {
   /* display:flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; */
    margin: 0;
    background-color: #121250;
}

body, .input {
    font-family: 'Gill Sans', 'Gill Sans MT', 'Calibri', 'Trebuchet MS','sans-serif';
}

.container {
    position: relative;
    margin: 10em auto;
    background-color: #123150 ;
    padding:1em;
    border-radius: .5em;
    width: 20em;
}

.word
{
    position: relative;
    text-align: center;
    font-size: 1.8em;
    color: white;
}

.timer{
    font-size: 2.7em;
    position: relative;
    display: flex;
    justify-content: center;
    margin-top: 3.5em;
    color: aliceblue;
    
}

h1{
    position: relative;
    display: flex;
    justify-content: center;
    color: white;
    margin: auto;
    

}

.topcontainer{
    display: flex;
    position: absolute;
    background-color: #123150;
    width: 100%;
    height: 7em;  
}

.highscore{
    position: relative;
    font-size: 2em;
    color: #19a642;
    justify-content: center;
    margin: auto;
}
  • is it the textarea what you're trying to float right? You don't mention which thing you want to be centered and which div you want on the right. I see a lot of centering css though. – Lucretius May 24 '22 at 14:28

0 Answers0