会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133958个问题
Python全系列/第十一阶段:Flask百战电商后台项目/Flask百战电商后台项目 31楼
Python全系列/第六阶段:数据库与AI协同技术实战/MySQL数据库的使用 32楼

<!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新特性 33楼
WEB前端全系列/第二十三阶段:uni-app框架/uni-app全局配置 34楼
WEB前端全系列/第十四阶段:微信小程序/小程序API 35楼
WEB前端全系列/第十四阶段:微信小程序/小程序API 36楼
Python全系列/第十六阶段:Python 爬虫开发/Python爬虫基础与应用 37楼
Python全系列/第二阶段:Python 深入与提高/Python项目环境管理 39楼
WEB前端全系列/第四阶段:BootStrap框架模块/BootStrap入门 41楼
Python全系列/预科阶段:职业规划/学习方法/Python 技术体系介绍 42楼

image.png

人工智能/第三阶段:人工智能基础-Python科学计算和可视化/Numpy 处理多维数组的工具 43楼
Python全系列/第六阶段:数据库与AI协同技术实战/python操作mysql 44楼
Python全系列/第二十四阶段:人工智能基础_机器学习理论与实战/线性回归与梯度下降法 45楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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