How can I position an element that is NOT a text, since for these I can user text-align: center
, but for an element such as a div, its width will modify the 50%
of the position, I already know how to do with javascript, but I would like to do it with CSS, how would this work? Is it possible? I would need to get the size of the div and body from CSS and do operations on it, but ... is this possible?
#elemento {
width: 500px; height: 200px; border: 2px solid purple;
position: absolute;
}
<h6 style="text-align: center;">buaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</h6>
<div id=elemento></div>