Css3 in the middle. Transform failed?

<div class="header">
    <span class="something"></span>
</div>
.header {
    margin-top: 40px;
    width: 100%;
    height: 62px;
    position: relative;
    overflow: hidden;

    & > .something {
        font-size: 20px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }

}

before absolute positioning is not used:


:

how can I achieve my goal? Thank you.

Mar.29,2021

because you set left: 50% , the default div width is only 50%.
and the content happens to be all in Chinese, and there can be line breaks in the middle of each character, so the line breaks are done by default.
set css not to allow line breaks.


display:block;
text-align:center

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36a83-2c029.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36a83-2c029.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?