Centering text in an oversized div [duplicate]
تبليغيرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.
How to easily center text in an oversized div? Currently the text is centered on the screen size, but I would like the div to be centered against the parent div. How to solve this easily in CSS without tinkering? Would using javascript be a solution?
height: 2000px;
width: 4000px;
background-color: orange;
}
.title{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 40px;
background-color: red;
}
<div id=”canvas”>
<div class=”title”>Title</div>
</div>
أضف إجابة