onepic 2020-05-29 18:41 采纳率: 88.9%
浏览 493
已采纳

关于HTML中块中块的居中方法

这是我的代码:我想吧块里面的块居中,可试了很多方法不行,求大佬解答

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style>
            .fl{
                width: 80px;
                height: 50px;
                background-color: royalblue;
                float: left;
                margin-right: 5px;
                text-align: center;
                line-height: 50px;
                color: white;
            }
            .fe{
                width:1500px;
                height: 50px;
                background-color: skyblue;
            }
        </style>
    </head>
    <body>
        <div class="fe">
            <div class="fl">首页</div>
            <div class="fl">简介</div>
            <div class="fl">活动</div>
            <div class="fl">商品</div>
            <div class="fl">男士</div>
            <div class="fl">女士</div>
            <div class="fl" style="background-color: orange; color: black;">儿童</div>
        </div>
    </body>
</html>

图片说明

  • 写回答

5条回答 默认 最新

  • fffffff_d 2020-06-12 14:34
    关注

    这个样式复制过去看一下,应该可以满足你的需求

    .fl{
            width: 80px;
            height: 50px;
            background-color: royalblue;
            margin-right: 5px;
            text-align: center;
            line-height: 50px;
            color: white;
            display: inline-block;
        }
        .fe{
            width:1500px;
            height: 50px;
            background-color: skyblue;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?