html - Keep Div Centered -
how make div stay in middle of page. how change size of div?
html:
<div id="text"> <p id="insidet"> hello </p> </div>
css:
#text{ position: absolute; width: 50%; font-size: 60px; text-align: center; color: black; height: 50%; display: inline-block; transform: translatey(-50%); top: 50%; margin: 0 auto; color: black; right: 320px; background: white;
use absolute positioning, , transform centre div
. dimensions not matter, until window size smaller div
.
.centred { height: 50px; left: 50%; position: absolute; top: 50%; transform: translate(-50%, -50%); width: 200px; }
<div class="centred">i in centre of page</div>
wiki
Comments
Post a Comment