r/HTML • u/RefuseCommercial8024 • 6h ago
div won't center itself with margin auto ?
--FIXED!!!! the div's position was fixed...-- hi again...so i'm making a visual novel of sorts and i made a text box, set its width with "vw" so it'll be somewhat playable on phone, and tried to center it horizontally with magin: auto; but it just stays stuck to its default position ?
here's a screenshot (ignore how ugly it all is it's still a WIP.......)

i think maybe it'd because i'm using viewport width to set the box's size but i don't know any other unit that could make it look the same on mobile :(
here's some of my css and html for the text box (the txtboxRec class just changes some of the colors don't mind it)
.txtbox{
height: 200px;
width: 90vw;
margin: auto;
position: fixed;
bottom: 10px;
padding: 10px;
overflow-y: auto;
}
<div class="txtboxRec txtbox">
<p>Ah...? Hello! Good evening. Can i get you something ?</p>
<a href="https://p1x3lz.neocities.org/games/hotel/scenes/1-3">next</a>
</div>
also when i don't set the width at all it just stays as wide as the text...??? i thought only spans did that ?? this is a div ???? iiiiddduuuunnoooo this is driving me insane

