从零开始写代码 2024-01-18 12:10 采纳率: 69.2%
浏览 3
已结题

html布局bug,关于flex布局的一些问题

html布局bug,为什么这个div标签始终不能放在另一个div标签里?
我试过改变标签display样式但是都没有效果,清除浮动也不行

img

源码如下

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>下拉菜单</title>
    <style>
        .menu {
            height: 400px;
            width: 1000px;
            border: 2px solid skyblue;
            margin-top: 100px;
            margin-left: auto;
            margin-right: auto;
            display: flex;
        }
        .menu .head{
            height: 100px;
        }
        .menu .title {
            height: 400px;
            width: 200px;
            background-color: gold;
        }
        .title .content{
            height: 300px;
            display: inline-block;
            background-color:#aaa;
        }
        a{
            text-decoration: none;
        }
        .clearfix:after{
        clear: both;
    }
    </style>
</head>

<body>
    <div class="menu">
        <div class="title clearfix">学习</div>
            <div class="content">
                <a href="https://nav.guidebook.top/xuexi" target="_blank">学习教育</a>
                <a href="http://muchong.com/bbs/" target="_blank">小木虫论坛</a>
                <a href="https://www.elecfans.com/" target="_blank">电子发烧友</a>
                <a href="https://www.zhihuishu.com/" target="_blank">智慧树平台</a>
                <a href="https://www.51zxw.net/" target="_blank">我要自学网</a>
                <a href="https://cet-bm.neea.edu.cn/Index" target="_blank">英语四六级报名网</a>
            </div>
        <div class="title">编程</div>
            <!-- <a href="https://www.code-nav.cn/" target="_blank">编程导航</a>
            <a href="https://cplusplus.com/reference/" target="_blank">C语言头文件官网</a>
            <a href="https://zh.cppreference.com/w/%E9%A6%96%E9%A1%B5" target="_blank">中文C语言官网</a>
            <a href="https://ac.nowcoder.com/" target="_blank">牛客竞赛网</a>
            <a href="https://leetcode.cn/" target="_blank">力扣</a>
            <a href="https://www.matiji.net/exam/" target="_blank">码蹄集</a> -->
        <div class="title">工具</div>
            <!-- <a href="http://www.hippter.com/" target="_blank">PPT模板导航</a>
            <a href="https://www.excelbbx.net/Word.htm" target="_blank">Word精灵</a>
            <a href="https://www.toolhelper.cn/Digit/FractionConvert" target="_blank">计算工具大全</a>
            <a href="https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element" target="_blank">HTML大全</a>
            <a href="https://cn.bing.com/translator/?h_text=msn_ctxt&setlang=zh-cn" target="_blank">bing翻译</a>
            <a href="https://pyecharts.org/#/zh-cn/intro" target="_blank">pyecharts图表官网</a> -->
    </div>
</body>

</html>

  • 写回答

2条回答 默认 最新

  • syksdl 2024-01-18 12:16
    关注

    你这个本来就不是父子包含关系啊,他俩是兄弟元素标签。你仔细看下。

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月26日
  • 已采纳回答 1月18日
  • 创建了问题 1月18日