会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133943个问题
Python 全系列/第一阶段:AI驱动的Python编程/函数和内存分析 28096楼
WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 28098楼
Python 全系列/第七阶段:网页编程基础/小米官网项目 28099楼

bug.png

bug2.png

bug3.png

高老师,我实在找不到是哪里的问题,为什么还是找不到路径呢?

JAVA 全系列/第一阶段:AI驱动的JAVA编程/飞机大战小项目训练 28100楼
JAVA 全系列/第六阶段:JavaWeb开发/JSP技术详解(旧) 28103楼

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>响应式布局实操</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

         body{
            background-color: #f1f1f1;
         }

        .nav {
            width: 100%;
            height: 50px;
            background-color: #555;
            overflow: hidden;
            clear: both;
            line-height: 50px;
        }
        .list{
            width: 80%;
            margin: 0 auto;
            /* list让内容往中间显示 */
        }
        .nav ul{
            overflow: hidden;
            clear: both;
            float: left;
        }

        .container .nav ul li {
            list-style: none;
            float: left;
            padding: 0 20px;
        }

        .container .nav ul li a {
            text-decoration: none;
            color: white;
            font-size: 16px;
        }
        .container .nav ul li.select {
            background-color: orange;
        }

         .nav .search {
            float: right;
            /* position: relative; */
        }

        .container .nav .search input {
            height: 30px;
            width: 200px;
            border: none;
            padding-left: 10px;
            border-radius: 50px;
            display: inline-block;
            /* position: absolute;
            top: 10px;
            right: 100px; */

        }

        .container .nav .search button {
            height: 30px;
            width: 60px;
            border: none;
            border-radius: 50px;
            margin-left: 20px;
            background-color: orange;
            color: white;
            font-size: 16px;
            display: inline-block;
            /* position: absolute;
            top: 10px;
            right: 20px; */
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="nav">
            <div class="list">
                <ul>
                    <li class="select"><a href="#">首页</a></li>
                    <li><a href="#">关于</a></li>
                    <li><a href="#">服务</a></li>
                    <li><a href="#">联系</a></li>
                </ul>
                <div class="search">
                    <input type="text" placeholder="搜索...">
                    <button>搜索</button>
                </div>
            </div>
        </div>
    </div>
    </div>
</body>

</html>

老师,我在搜索框后面加了button按钮,但是搜索框input和button不在一条水平线上,是因为浮动的影响吗?还是我别的地方写错了?我上述代码中注释掉的部分是给父元素search添加了position,然后分别给子元素input搜索框和button添加了绝对定位,解决了这个问题,请问这样做对吗?还有没有其他解决办法使他们的高度齐平image.png

WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 28104楼
JAVA 全系列/第六阶段:JavaWeb开发/Servlet技术详解(旧) 28106楼
Python 全系列/第二十三阶段:人工智能基础_机器学习理论和实战(旧)/XGBoost算法 28109楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637