I am trying to make my h1
be inline within my box like this. Currently my H1 text is stacked on top of each other and looks like this. I want this to be inline rather than stacked on top of one and other, I have tried adding display: inline-block;
and display: inline;
to my H1 neither working. What do I need to add or remove from my H1 or box div to be able to achieve my H1 being inline!
HTML
<body>
<div class="box">
<h1>Centered Text</h1>
</div>
</body>
CSS
*{
margin: 0;
padding: 0;
}
body{
background-color: teal;
font-family: sans-serif;
}
.box{
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
text-align: center;
width: 500px;
height: 100px;
background-color: red;
}
h1{
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
text-align: center;
font-size: 50px;
font-weight: lighter;
color: white;
}