会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133936个问题

<!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新特性 1楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 3楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 4楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/表单 6楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/表单 7楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/表单 8楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/前端入门与基础知识 9楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/前端入门与基础知识 10楼

image.png

WEB前端全系列/第一阶段:HTML5+CSS3模块/前端入门与基础知识 11楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1{
            width: 200px;
            height: 100px;
            background-color: green;
            transform: translate(10px,10px);
            margin: 50px;
        }
        .box2{
            width: 200px;
            height: 100px;
            background-color: red;
            margin: 50px;
            transform: rotate(30deg);
        }
        .box3{
            width: 200px;
            height: 100px;
            background-color: yellow;
            margin: 50px;
            transform: scale(1.2,1.5);
        }
        .text{
            /* transform: scale(0.5); */
            font-size: smaller;
        }
    </style>
</head><!--  -->
<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>

    <p class="text">我是6PX字号</p>
    <p>我是默认12PX字号</p>
</body>
</html>

image.png

老师,默认最小字体不是12px吗,我这里直接修改字号也能修改,不用transform:scale(0.5)来缩放,是和我Chrome浏览器的版本有关吗

WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 13楼

8c603338652291c85e40849fb9f3648a.png

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: red;
            padding: 50px;
            border: 20px solid green;
            margin: 50px;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>

为什么浏览器盒子模型里面的border老和我设置的border有一点差距,设置20px,但是浏览器里显示19.512


WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS盒子模型 14楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/表单 15楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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