简体   繁体   中英

how to use css to center page title?

I have a hamburger menu that when clicked, it expands in both directions, I also have a page title that I would like to have centered on the page, but it doesn't want to work. The most luck I've had thus far is with adding a margin, but then the title moves when I click the hamburger menu. I tried several options before resorting to asking, but they all seem to break the code or do nothing. Below are images and code corresponding to the current images.

#top {
            display:flex;
            background-color:black;
            width:100%;
            height: 200px;
            padding:5px;
        }
        #top #menu {
            width:30px;
            height:30px;
            border: 2px solid white;
        }
        #top h1{
            display:flex;
            flex-direction:row;
            color:red;
            justify-content:center;
        }

菜单折叠

菜单已展开

Try text-align: center; instead of justify-content: center;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM