会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133322个问题
Python 全系列/第一阶段:Python入门/面向对象 25291楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>小米首页</title>
    <link rel="icon" href="image/favicon.ico">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/index.css">
</head>
<body>
<!--头部-->
<div class="header">
    <img src="image/bb3c06a430689ba2357dd7d1fbfa6bab.jpg" alt="">
</div>
<!--黑色导航条-->
<div class="header-wrapper">
    <div class="topbar-wrapper">
        <ul class="topbar-nav">
            <li><a href="#">小米商城</a></li>
            <li><a href="#">MUI</a></li>
            <li><a href="#">LOT</a></li>
            <li><a href="#">云服务</a></li>
            <li><a href="#">天星科技</a></li>
            <li><a href="#">有品</a></li>
            <li><a href="#">小爱开放平台</a></li>
            <li><a href="#">企业团购</a></li>
            <li><a href="#">资质证照</a></li>
            <li><a href="#">协议规则</a></li>
            <li><a href="#">下载app</a></li>
            <li><a href="#">智能生活</a></li>
            <li><a href="#">Select Location</a></li>
        </ul>
        <ul class="inf">
            <li><a href="#">登录</a></li>
            <li><a href="#">注册</a></li>
            <li><a href="#">消息通知</a></li>
        </ul>

    </div>
</div>
</body>
</html>


/*头部样式*/
.header{
    width:100%;
    height:120px;
    background-color:red;
    overflow:hidden;
    position:relative;
}
.header img{
    height:120px;
    position: absolute;
    left:50%;
    transform:translateX(-50%);
}
/*黑色导航条*/
.header-wrapper{
    width:100%;
    height:40px;
    background-color: #333333;
}
.topbar-wrapper{
    margin:0 auto;
}
.top-bar{
    width:794.13px;
    height:40px;
    background-color: #cc0000;
    float:left;
}
.topbar-nav li {
    float: left;
}
.topbar-nav a{
    color:#b0b0b0;
    font-size:12px ;
    line-height:40px;
    margin:10px;
}
.inf{
    width:142.48px;
    height:40px;
    background-color: blue;
    float:left;
}
.inf li{
    float:left;
}
.inf a{
    color:#b0b0b0;
    font-size:12px ;
    line-height:40px;

}

截图

图片.png


两个ul是兄弟元素,给他们设置浮动后应该水平排列,这里蓝色部分为什么是这样能呢?




WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 25292楼
Python 全系列/第六阶段:数据库与AI协同技术实战/mysql的使用 25294楼
人工智能/第六阶段:机器学习-线性分类/逻辑回归 25296楼

老师,通过比较器实现比较规则这个显示下面这一行

Map<Student,String> treeMap = new TreeMap<>(new StudentComparator());

出了问题,能帮我看一下是什么问题吗?

package 双例集合;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * 元素自身实现比较规则   TreeMap可以对键进行排序
 */
public class TreeMapTest {
    public static void main(String[] args) {
        //实例化TreeMap
        Map<Users,String> map = new TreeMap<>();
        //创建User对象
        Users u1 = new Users("liu",18);
        Users u2 = new Users("admin",20);
        Users u3 = new Users("sxt",20);
        map.put(u1,"liu");
        map.put(u2,"admin");
        map.put(u3,"sxt");
        Set<Users> keys = map.keySet();
        for (Users key:keys){
            System.out.println(key+" "+map.get(key));
        }
        System.out.println("-----通过比较器实现比较规则-------");
        //java.lang.ClassCastException: 双例集合.Student cannot be cast to java.lang.Comparable
        //创建StudentComparator对象,然后交给TreeMap的构造方法中
        Map<Student,String> treeMap = new TreeMap<>(new StudentComparator());
        Student s1 = new Student("liu",18);
        Student s2 = new Student("admin",20);
        Student s3 = new Student("sxt",20);
        treeMap.put(s1,"liu");
        treeMap.put(s2,"admin");
        treeMap.put(s3,"sxt");
        Set<Student> keys2 = treeMap.keySet();
        for (Student key:keys2){
            System.out.println(key+" "+treeMap.get(key));
        }

    }
}

blob.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 25298楼
JAVA 全系列/第十四阶段:分布式文件存储与数据缓存/MongoDB 25300楼

老师,为什么“技术·共享·娱乐”这张图片的高度变高了呢?


图片.png

<!--第一块开始-->
<div class="one box">
    <video src="images/201702241034284066.mp4" autoplay loop muted>
        您的浏览器不支持视频,请升级!
    </video>
    <div class="text">
        <img src="images/video_txt.png" alt="">
        <a href="#">下载迅雷产品</a>
        <i class="iconfont">&#xe60c;</i>
    </div>
</div>
<!--第一块结束-->


/*第一块样式开始*/
.one{
    /*垂直方向溢出部分隐藏 不出现滚动条*/
    overflow: hidden;
    position: relative;
}
.one>video{
    width: 100%;
}
.text{
    width: 716px;
    height: 193px;
    position: absolute;
    /*相对于父元素one往下走50%*/
    top: 50%;
    /*相对于父元素one往右走50%*/
    left: 50%;
    /*往左上走自己宽高的一半*/
    transform: translate(-50%,-50%);
}
.text>img{
    width: 100%;
}
.text>a{
    width: 180px;
    height: 50px;
    margin: 30px auto 20px;
    color: #fff;
    /*z转换为块级元素 样式才会生效*/
    display: block;
    border: 1px solid #fff;
    /*水平居中 行高等于高*/
    line-height: 50px;
}
.text>a:hover{
    background-color: rgba(255,255,255,.5);
}
.text>i{
    font-size: 40px;
    color: #fff;
    animation: updown 1s linear infinite;
    /*转换为块级元素 实现动画*/
    display: block;
}
@keyframes updown{
    0%{
        transform: translateY(0);
    }
    33%{
        transform: translateY(-3px);
    }
    66%{
        transform: translateY(0);
    }
    100%{
        transform: translateY(3px);
    }
}
/*第一块样式结束*/


WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS应用技巧 25303楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>post请求</title>
    <style>
        .sp {width: 80px;height: 35px;line-height: 35px;display: inline-block;}
    </style>
</head>
<body>
    <label for="">
        <span class="sp">用户名:</span><input type="text" class="username">
    </label><br>
    <label for="">
        <span class="sp">密码:</span><input type="password" class="password">
    </label>
    <button>登录</button>

    <script>
        var iun=document.querySelector('.username').value;
        var ipw=document.querySelector('.password').value;
        var btn=document.querySelector('button');

        btn.onclick=function() {
            var xhr=new XMLHttpRequest();
            xhr.onreadystatechange=function() {
                if(xhr.readyState==4) {
                    if(xhr.states==200) {
                        console.log(JSON.parse(xhr.responseText));
                    } 
                }
            }
            xhr.open('post','前台post请求.php',true);
            var datas=new FormData();
            datas.append('usern',iun);
            datas.append('passw',ipw);
            xhr.send(datas);
        }
    </script>
</body>
</html>
<?php

$success=array('msg'=>'ok','info'=>$_POST);
echo json_encode($success);

?>

老师你看

WEB前端全系列/第六阶段:Http服务与Ajax模块(旧)/Http服务与Ajax编程 25304楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 25305楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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