CSS入门学习笔记+案例

news2024/11/16 2:45:27

目录

一、 CSS的基础

1、快速了解

2、CSS应用方式

①在标签上

②在head标签中写style标签

 ③写到文件中

 二、CSS的选择器

1、ID选择器

2、类选择器

3、标签选择器

 4、属性选择器

5、后代选择器

 三、样式覆盖

 四、CSS的样式

1、高度和宽度

2、块级和行内标签

3、字体设置和文字对齐方式

4、浮动

 5、内边距和外边距

 6、hover

7、after 

8、border 

 五、案例(小米商城)

1、总结分析 

2、二级商城

3、导引行

4、推荐页面

5、范例


一、 CSS的基础

CSS,专门用来"美化"标签。

  • 基础CSS,写简单页面&看懂&改
  • 模块,调整和修改

1、快速了解

样式即为类似style这种修饰标签的东西

<img src="..." style = "height:100px"  />

<div style = "color:red;">中国联通</div>

2、CSS应用方式

①在标签上

<img src="..." style = "height:100px"  />

<div style = "color:red;">中国联通</div>

②在head标签中写style标签

适用于同一页面下多次出现的css样式

...
<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <style>
        .c1 {
            color: red;
        }
    </style>

</head>
<body>
    <h1 class="c1">用户注册</h1>
    ...

 ③写到文件中

适合用很多的文件

写一个common.css文件

.c1 {
	height:100px;
}
.c2 {
	color:red;
}

 调用common.css文件

...
<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <link rel="stylesheet" href="common.css" />

</head>
<body>
    <h1 class="c1">用户注册</h1>
    ...

问题:用Flask框架开发不方便

  • 每次都需要重启py文件
  • 规定有些文件必须放在特定的文件夹下
  • 新创建一个页面    函数 、HTML文件、CSS文件

有无一种方式可以让我们快速的编写前端的代码并且查看效果,最后将页面集成到Flask中。

Pycharm为我们提供了一种非常便捷开发前端页面的工具。

直接点击浏览器可以查看HTML

 二、CSS的选择器

1、ID选择器

ID的优先级比类的优先级高,ID不能重复而类可以

#c1 {
	color: red;
}

<div id='c1'></div>

2、类选择器

类选择器用的最多

.c1 {
	color: red;
}

<div class='c1'></div>

3、标签选择器

div{
	color: red;
}

<div>xxx</div>

 4、属性选择器

所有的text类型的input都会生效

<head>
    <title>Document</title>
    <link rel="stylesheet" href="/static/commons.css">
    <style>
        input[type="text"]{
        border: 1px solid red;
    }
    </style>
</head>
<input type = "text">
<input type = "password">

 xx = "456"的会显示颜色为金色

.v1[xx="456"]{
   color:gold;
}

<div class="v1" xx="123">s<div>  
<div class="v1" xx="456">d<div>  

5、后代选择器

<style>
 .yy h2{
        color: darkseagreen;
        }
</style>
<body>
<div class="yy" >
    <div>
    <h2>百度</h2>
    </div>
    <h2>谷歌</h2>
</div>
</body>

 这样操作可以让只有yy一层实现color变色

  .yy > a{
      color: darkseagreen;
         }
    <div class="yy" >
        <div>
            <a>百度</a>
        </div>
        <a>谷歌</a>
    </div>

很明显可以得知,这次操作下只有谷歌会变色

 关于选择器:

多:类选择器、标签选择器、后代选择器

少:属性选择器、ID选择器

 三、样式覆盖

当一个标签引用了多个 css 样式时,可能会遇到样式属性重复的问题

如果重名,下面的会覆盖上面的项

简单的说:CSS叠成样式表,就是一层一层样式堆叠起来的,堆在最上面的就是最新的样式。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
      .c1{
        color: red;
        border: 1px solid red;
      }
      .c2 {
        font-size: 28px;
        color: green;
      }
    </style>
</head>
<body>
<div class="c1 c2">派大星</div>
</body>
</html>

 

 如果想要下面的不覆盖上面的一项

加 ---!important

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
      .c1{
        color: red !important;
        border: 1px solid red;
      }
      .c2 {
        font-size: 28px;
        color: green;
      }
    </style>
</head>
<body>
<div class="c1 c2">派大星</div>
</body>
</html>

 四、CSS的样式

1、高度和宽度

.c1 {
        height: 300px;
        width: 500px;
    }

注意事项:

  • 宽度支持百分比
  • 行内标签: 默认无效
  • 块级标签: 默认有效(右边的剩余空白区域也会被占用)

2、块级和行内标签

CSS样式:display:inline-block 使行内标签对 height 和 width 生效

既具有块级标签又有行内标签

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
      .c1 {
        display: inline-block;
        height: 100px;
        width: 300px;
        border: 2px solid red;
      }
    </style>
</head>
<body>
<span class="c1">派大星</span>
</body>
</html>

行内标签和块级标签的特性都有 

 块级与行内标签的设置

	<div style="display: inline;">派大星</div>
    <span style="display: block;">海绵宝宝</span>

大多数使用:

  • 块级标签
  • 块级标签+行内标签

3、字体设置和文字对齐方式

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .c1 {
            color: red;                       /* 字体颜色 */
            font-size: 20px;                  /* 字体大小 */
            font-weight: 600;                 /* 字体粗细 */
            font-family: Microsoft Yahei;     /* 字体样式 */
            text-align: center;               /* 水平方向居中 */
            line-height: 50px;                /* 垂直方向居中 */
            border: 1px solid red;            /* 边框 */
        }
    </style>
</head>

4、浮动

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <span>
        左边
    </span>
    <span style="float: right">
        右边
    </span>
</div>

</body>
</html>

div默认块级标签(霸道)。如果浮动起来效果就不一样了

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .item{
            float: left;
            width: 280px;
            height: 170px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
<div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
</div>

</body>
</html>

 如果让标签浮动的话,就会脱离文档流。

例如下面的例子中,我们给div的父标签赋予了一个蓝色的背景,但是你不会看到蓝色背景。因为他被浮动的div字标签挡住了。

<body>
<div>
    <div style="background-color: dodgerblue">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    </div>
</div>
</body>

解决办法: 在同级子标签的最下面添加 style="clear: both;"

<body>
<div>
    <div style="background-color: dodgerblue">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div style="clear: both"></div>
    </div>
</div>
</body>

 5、内边距和外边距

内边距

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    .outer{
      border: 1px solid indianred;
      height: 400px;
      width: 200px;
      padding-top: 100px;    /*内上边距*/
      padding-left: 50px;
      padding: 20px 10px 50px 10px ;   /*上右下左*/
    }
  </style>
</head>
<body>
<div class="outer">
  <div style="background-color: #ffdd00">派大星</div>
  <div>海绵宝宝</div>
</div>
</body>
</html>

 外边距

<body>
    <div style="height: 200px; background-color: red;"></div>
    <div style="height: 200px; background-color:#3de22b; margin-top: 80px;"></div>
</body>

 6、hover

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .c1 {
            color:brown;
        }
        .c1:hover {
            color: green;
            font-size: 20px;
        }

        .c2 {
            width: 300px;
            height: 300px;
            border: 3px solid red;
        }
        .c2:hover {
            border: 3px solid green;
        }

        .download {
            display: none;
        }

        .app:hover .download {
            display: block;
        }

    </style>
</head>
<body>
    <div class="c1">字体碰到鼠标变成绿色</div>
    <div class="c2">边框碰到鼠标变成绿色</div>
    <div class="app">
        <div>鼠标放我这里触发显示二维码</div>
        <div class="download">
            <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/78c30d4f259ed43ab20e810a522a6249.png" alt="">
        </div>
    </div>
</body>
</html>

7、after 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .c1:after {
            content: "海绵宝宝"
        }
    </style>
</head>
<body>
    <div class="c1">派大星</div>
</body>
</html>
after 一般都这么用
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .clearfix:after {
            content: "";
            display: block;
            clear: both;
        }

        .item {
            float: left;
        }

    </style>
</head>
<body>
    <div class="clearfix">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
    </div>
</body>
</html>

8、border 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>

        .left {
            float: left;
        }

        .c1 {
            height: 200px;
            width: 300px;
            border: 3px dotted red;
            margin: 50px;
        }

        .c2 {
            height: 200px;
            width: 300px;
            border: 3px solid red;
            border-left: 3px solid green;
            margin: 50px;
        }

        .c3 {
            height: 200px;
            width: 300px;
            margin: 50px;
            background-color: bisque;
            border-left: 2px solid transparent;  /* 透明色 */
        }

        .c3:hover {
            border-left: 2px solid rgb(35, 211, 19);
        }

    </style>
</head>
<body>
    <div class="c1 left">我是虚线~</div>
    <div class="c2 left">我是实线~左边框是绿色,上下右边框是红色</div>
    <div class="c3 left">我是透明色,鼠标碰到我边框会变色哦~</div>
    <div style="clear: both;"></div>
</body>
</html>

 五、案例(小米商城)

1、总结分析 

  • body标签,默认有一个边框,造成页面四边都有白色间隙,如何去除?
body{
   margin:0;
}
  • 内容居中

文本居中,文本会在这个区域居中。

<div style = "width:200px;text-align:center;">派大星</div>

区域居中,自己要有宽度+ margin-left:auto;margin-right:auto

.container{
      width: 980px;
      margin: 0 auto;
 }
  • 父亲没有高度或者宽度,被孩子支撑起来。
  • 如果存在float,一定记得加入 style="clear: both;"
<div style = "clear:both"></div>
  • 关于布局不知道如何下手

2、二级商城

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            margin: 0;
        }
        .sub-header {
            height: 100px;
            background-color: white;
        }
        .container{
            width: 1226px;
            margin-right: auto;
            margin-left: auto;

        }
        .header-logo{
            float: left;
            width: 234px;
            margin-top: 22px;
        }
        .menu-list{
            float: left;
            width: 600px;
        }
        .search{
            float: right;
            width: 296px;
            margin-top: 25px;

        }
        .logo-ir{
            position: relative;
            display: block;
            width: 56px;
            height: 56px;
            overflow: hidden;
        }
        .nav-list{
            position: relative;
            z-index:10 ;
            float: left;
            width: 1100px;
            height: 88px;
            margin: 0;
            padding: 12px 0 0 30px;
            list-style-type: none;
            font-size: 16px;
            display: block;
        }
        .nav-category{
            position: relative;
            float: left;
            width: 127px;
            padding-right: 15px;
        }
        .nav-item{
            float: left;
            display: block;
            padding: 26px 10px 38px;
            color: #333;
            transition: color .2s;
        }
        .search-form{
            position: relative;
            width: 296px;
            height: 50px;
            z-index: 20;
        }
        .clearfix{
            content: " ";
            display: table;
        }
        .search-text{
            position: absolute;
            top:0;
            border: 1px solid #e0e0e0;
            transition: all .2s;
            right: 51px;
            z-index: 1;
            width: 223px;
            height: 48px;
            padding: 0 10px;
            font-size: 14px;
            line-height: 48px;
        }
        .search-btn{
            position: absolute;
            right: 0;
            z-index: 2;
            width: 52px;
            height: 50px;
            font-size: 24px;
            line-height: 24px;
            background-color: #fff;
            color: #e0e0e0;
        }

    </style>
</head>
<body>
    </div>
    <div class="sub-header">
        <div class="container">
            <div class="header-logo">
                <a href="https://www.mi.com" >
                     <img src="https://s02.mifile.cn/assets/static/image/logo-mi2.png" alt="小米官网" class="logo-ir">
                </a>
            </div>
            <div class="menu-list">
                <ul class="nav-list">
                    <li class="nav-category"></li>
                    <li class="nav-item">
                        <span class="text" >Xiaomi手机</span>
                    </li>
                    <li class="nav-item">
                        <span class="text">Redmi手机</span>
                    </li>
                    <li class="nav-item">
                        <span class="text">电视</span>
                    </li>
                    <li class="nav-item">
                        <span class="text">笔记本</span>
                    </li>
                    <li class="nav-item">
                        <span class="text">平板</span>
                    </li>
                    <li class="nav-item">
                        <span class="text">家电</span>
                    </li>
                    <li class="nav-item">
                        <span class="text">路由器</span>
                    </li>
                    <li class="nav-item">
                        <span class="text">服务中心</span>
                    </li>
                    <li class="nav-item">
                        <span class="text">社区</span>
                    </li>
                </ul>
            </div>
            <div class="search">
                <form action="//search.mi.com/search" method="get" class="search-form clearfix">
                    <input type="search" id="search" name="keyword" autocomplete="off" class="search-text" placeholder="路由器">
                    <input type="submit" value="🔍" class="search-btn">
                </form>
            </div>
            <div style="clear: both;"></div>
        </div>
    </div>
</body>
</html>

 3、导引行

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body {
            margin: 0;
        }

        .top {
            position: relative;
            z-index: 30;
            height: 40px;
            font-size: 12px;
            color: #b0b0b0;
            background-color: #333;
        }

        .top1 {
            color: #b0b0b0;
            line-height: 40px;
            display: inline-block;
            text-decoration: none;
        }

        .sep {
            margin: 0 .3em;
            color: #424242;
            font-family: sans-serif;
        }

        .top-cart {
            position: relative;
            float: right;
            width: 120px;
            height: 40px;
            margin-left: 15px;
            -webkit-transition: all .2s;
            transition: all .2s;
            font-size: 12px;
        }

        .cart-mini {
            position: relative;
            z-index: 32;
            display: block;
            height: 40px;
            line-height: 40px;
            text-align: center;
            color: #b0b0b0;
            background: #424242;
            text-decoration: none;
        }

        .cart-full-hide {
            margin-right: 4px;
            font-size: 20px;
            line-height: 20px;
            vertical-align: -4px;
            display: none !important;
            font-style: normal;
            -webkit-font-smoothing: antialiased;
            -webkit-text-stroke-width:2px;
            text-decoration: none;
        }

        .top-nav {
            float: left;
            height: 40px;
            line-height: 40px;
        }

        .sub-header {
            height: 100px;
            background-color: white;
        }

        .container {
            width: 1226px;
            margin-right: auto;
            margin-left: auto;
        }

        .header-logo {
            float: left;
            width: 180px;
            margin-top: 22px;
        }

        .menu-list {
            float: left;
            width: 600px;
        }

        .search {
            float: right;
            width: 296px;
            margin-top: 25px;
        }

        .logo-ir {
            display: block;
            width: 56px;
            height: 56px;
            overflow: hidden;
        }

        .nav-list {
            position: relative;
            z-index: 10;
            float: left;
            width: 1100px;
            height: 88px;
            margin: 0;
            padding: 12px 0 0 30px;
            list-style-type: none;
            font-size: 16px;
            display: block;
        }

        .nav-category {
            position: relative;
            float: left;
            width: 127px;
            padding-right: 15px;
        }

        .nav-item {
            float: left;
            display: block;
            padding: 26px 10px 38px;
            color: #333;
            transition: color .2s;
        }

        .search-form {
            position: relative;
            width: 296px;
            height: 50px;
            z-index: 20;
        }

        .clearfix {
            content: " ";
            display: table;
        }

        .search-text {
            position: absolute;
            top: 0;
            border: 1px solid #e0e0e0;
            transition: all .2s;
            right: 51px;
            z-index: 1;
            width: 223px;
            height: 48px;
            padding: 0 10px;
            font-size: 14px;
            line-height: 48px;
        }

        .search-btn {
            position: absolute;
            right: 0;
            z-index: 2;
            width: 52px;
            height: 50px;
            font-size: 24px;
            line-height: 24px;
            background-color: #fff;
            color: #e0e0e0;
        }

        .top-info {
            position: relative;
            float: right;
            height: 40px;
            line-height: 40px;
        }

        .link {
            padding: 0 5px;
            text-align: center;
            float: left;
            color: #b0b0b0;
            line-height: 40px;
            display: inline-block;
            text-decoration: none;
        }

    </style>
</head>
<body>
<div class="top">
    <div class="container">
        <div class="top-nav">
            <a class="top1" href="//www.mi.com/">小米官网</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">小米商城</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">MIUI</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">loT</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">云服务</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">天星数科</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">有品</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">小爱开放平台</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">企业团购</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">资质证照</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">协议规则</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">下载app</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">Selection Location</a>
            <span class="sep">|</span>
        </div>
        <div class="top-cart">
            <a class="cart-mini" href="//www.mi.com/shop/buy/cart">
                <em class="cart-full-hide"></em>
                购物车(0)
            </a>
        </div>
        <div class="top-info">
            <a class="link"
               href="https://account.xiaomi.com/fe/service/login/password?_qrsize=180&sid=mi_eshop&qs=%253Fcallback%253Dhttp%25253A%25252F%25252Forder.mi.com%25252Flogin%25252Fcallback%25253Ffollowup%25253Dhttps%2525253A%2525252F%2525252Fwww.mi.com%2525252Fshop%252526sign%25253DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%25252C%25252C%2526sid%253Dmi_eshop%2526_qrsize%253D180&callback=http%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252Fshop%26sign%3DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%2C%2C&_sign=yBTYxCh0uB6YSglhQfg4uoP%2BRz4%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=&_locale=zh_CN">登录</a>
            <span class="sep">|</span>
            <a class="link"
               href="https://account.xiaomi.com/fe/service/login/password?_qrsize=180&sid=mi_eshop&qs=%253Fcallback%253Dhttp%25253A%25252F%25252Forder.mi.com%25252Flogin%25252Fcallback%25253Ffollowup%25253Dhttps%2525253A%2525252F%2525252Fwww.mi.com%2525252Fshop%252526sign%25253DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%25252C%25252C%2526sid%253Dmi_eshop%2526_qrsize%253D180&callback=http%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252Fshop%26sign%3DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%2C%2C&_sign=yBTYxCh0uB6YSglhQfg4uoP%2BRz4%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=&_locale=zh_CN">注册</a>
            <span class="sep">|</span>
            <a class="link"
               href="https://account.xiaomi.com/fe/service/login/password?_qrsize=180&sid=mi_eshop&qs=%253Fcallback%253Dhttp%25253A%25252F%25252Forder.mi.com%25252Flogin%25252Fcallback%25253Ffollowup%25253Dhttps%2525253A%2525252F%2525252Fwww.mi.com%2525252Fshop%252526sign%25253DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%25252C%25252C%2526sid%253Dmi_eshop%2526_qrsize%253D180&callback=http%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252Fshop%26sign%3DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%2C%2C&_sign=yBTYxCh0uB6YSglhQfg4uoP%2BRz4%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=&_locale=zh_CN">消息通知</a>
            <span class="sep">|</span>
        </div>
    </div>
</div>
<div class="sub-header">
    <div class="container">
        <div class="header-logo">
            <a href="https://www.mi.com">
                <img alt="小米官网" class="logo-ir" src="https://s02.mifile.cn/assets/static/image/logo-mi2.png">
            </a>
        </div>
        <div class="menu-list">
            <ul class="nav-list">
                <li class="nav-category"></li>
                <li class="nav-item">
                    <span class="text">Xiaomi手机</span>
                </li>
                <li class="nav-item">
                    <span class="text">Redmi手机</span>
                </li>
                <li class="nav-item">
                    <span class="text">电视</span>
                </li>
                <li class="nav-item">
                    <span class="text">笔记本</span>
                </li>
                <li class="nav-item">
                    <span class="text">平板</span>
                </li>
                <li class="nav-item">
                    <span class="text">家电</span>
                </li>
                <li class="nav-item">
                    <span class="text">路由器</span>
                </li>
                <li class="nav-item">
                    <span class="text">服务中心</span>
                </li>
                <li class="nav-item">
                    <span class="text">社区</span>
                </li>
            </ul>
        </div>
        <div class="search">
            <form action="//search.mi.com/search" class="search-form clearfix" method="get">
                <input autocomplete="off" class="search-text" id="search" name="keyword" placeholder="路由器"
                       type="search">
                <input class="search-btn" type="submit" value="🔍">
            </form>
        </div>
        <div style="clear: both;"></div>
    </div>
</div>
</body>
</html>

 4、推荐页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body {
            margin: 0;
        }

        .top {
            position: relative;
            z-index: 30;
            height: 40px;
            font-size: 12px;
            color: #b0b0b0;
            background-color: #333;
        }

        .top1 {
            color: #b0b0b0;
            line-height: 40px;
            display: inline-block;
            text-decoration: none;
        }

        .sep {
            margin: 0 .3em;
            color: #424242;
            font-family: sans-serif;
        }

        .top-cart {
            position: relative;
            float: right;
            width: 120px;
            height: 40px;
            margin-left: 15px;
            -webkit-transition: all .2s;
            transition: all .2s;
            font-size: 12px;
        }

        .cart-mini {
            position: relative;
            z-index: 32;
            display: block;
            height: 40px;
            line-height: 40px;
            text-align: center;
            color: #b0b0b0;
            background: #424242;
            text-decoration: none;
        }

        .cart-full-hide {
            margin-right: 4px;
            font-size: 20px;
            line-height: 20px;
            vertical-align: -4px;
            display: none !important;
            font-style: normal;
            -webkit-font-smoothing: antialiased;
            -webkit-text-stroke-width: 2px;
            text-decoration: none;
        }

        .top-nav {
            float: left;
            height: 40px;
            line-height: 40px;
        }

        .sub-header {
            height: 100px;
            background-color: white;
        }

        .container {
            width: 1226px;
            margin-right: auto;
            margin-left: auto;
        }

        .header-logo {
            float: left;
            width: 180px;
            margin-top: 22px;
        }

        .menu-list {
            float: left;
            width: 600px;
        }

        .search {
            float: right;
            width: 296px;
            margin-top: 25px;
        }

        .logo-ir {
            display: block;
            width: 56px;
            height: 56px;
            overflow: hidden;
        }

        .nav-list {
            position: relative;
            z-index: 10;
            float: left;
            width: 1100px;
            height: 88px;
            margin: 0;
            padding: 12px 0 0 30px;
            list-style-type: none;
            font-size: 16px;
            display: block;
        }

        .nav-category {
            position: relative;
            float: left;
            width: 127px;
            padding-right: 15px;
        }

        .nav-item {
            float: left;
            display: block;
            padding: 26px 10px 38px;
            color: #333;
            transition: color .2s;
        }

        .search-form {
            position: relative;
            width: 296px;
            height: 50px;
            z-index: 20;
        }

        .clearfix {
            content: " ";
            display: table;
        }

        .search-text {
            position: absolute;
            top: 0;
            border: 1px solid #e0e0e0;
            transition: all .2s;
            right: 51px;
            z-index: 1;
            width: 223px;
            height: 48px;
            padding: 0 10px;
            font-size: 14px;
            line-height: 48px;
        }

        .search-btn {
            position: absolute;
            right: 0;
            z-index: 2;
            width: 52px;
            height: 50px;
            font-size: 24px;
            line-height: 24px;
            background-color: #fff;
            color: #e0e0e0;
        }

        .top-info {
            position: relative;
            float: right;
            height: 40px;
            line-height: 40px;
        }

        .link {
            padding: 0 5px;
            text-align: center;
            float: left;
            color: #b0b0b0;
            line-height: 40px;
            display: inline-block;
            text-decoration: none;
        }

        .home-hero-container {
            position: relative;
            z-index: 10;
            width: 1226px;
            margin-right: auto;
            margin-left: auto;
        }

        .home-hero {
            position: relative;
            margin-bottom: 26px;
        }

        .news {
            margin-top: 14px;
        }

        .news .channel {
            width: 228px;
            height: 164px;
            background-color: #5f5750;
            padding: 3px;
        }

        .news .channel .item {
            width: 76px;
            height: 82px;
            float: left;
            text-align: center;
        }

        .news .channel .item img {
            width: 24px;
            height: 24px;
            display: block; /* 让图片自已占一整行 */
            margin: 0 auto; /* 让图片垂直居中 */
            margin-bottom: 4px; /* 设置图片与下方字体的间距 */
        }

        .news .channel .item a {
            display: inline-block;
            font-size: 12px; /* 设置字体大小 */
            text-decoration: none; /* a标签去掉下划线 */
            padding-top: 18px;
            color: #fff; /* 设置字体为白色 */
            opacity: 0.7; /* 设置透明度 */
        }

        .news .channel .item a:hover {
            opacity: 1; /* 设置透明度 */
        }


        .news .list-item {
            width: 316px;
            height: 170px;
        }

        .margin_left {
            margin-left: 14.5px;
        }

        .left {
            float: left;
        }

    </style>
</head>
<body>
<div class="top">
    <div class="container">
        <div class="top-nav">
            <a class="top1" href="//www.mi.com/">小米官网</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">小米商城</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">MIUI</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">loT</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">云服务</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">天星数科</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">有品</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">小爱开放平台</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">企业团购</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">资质证照</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">协议规则</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">下载app</a>
            <span class="sep">|</span>
            <a class="top1" href="//www.mi.com/">Selection Location</a>
            <span class="sep">|</span>
        </div>
        <div class="top-cart">
            <a class="cart-mini" href="//www.mi.com/shop/buy/cart">
                <em class="cart-full-hide"></em>
                购物车(0)
            </a>
        </div>
        <div class="top-info">
            <a class="link"
               href="https://account.xiaomi.com/fe/service/login/password?_qrsize=180&sid=mi_eshop&qs=%253Fcallback%253Dhttp%25253A%25252F%25252Forder.mi.com%25252Flogin%25252Fcallback%25253Ffollowup%25253Dhttps%2525253A%2525252F%2525252Fwww.mi.com%2525252Fshop%252526sign%25253DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%25252C%25252C%2526sid%253Dmi_eshop%2526_qrsize%253D180&callback=http%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252Fshop%26sign%3DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%2C%2C&_sign=yBTYxCh0uB6YSglhQfg4uoP%2BRz4%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=&_locale=zh_CN">登录</a>
            <span class="sep">|</span>
            <a class="link"
               href="https://account.xiaomi.com/fe/service/login/password?_qrsize=180&sid=mi_eshop&qs=%253Fcallback%253Dhttp%25253A%25252F%25252Forder.mi.com%25252Flogin%25252Fcallback%25253Ffollowup%25253Dhttps%2525253A%2525252F%2525252Fwww.mi.com%2525252Fshop%252526sign%25253DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%25252C%25252C%2526sid%253Dmi_eshop%2526_qrsize%253D180&callback=http%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252Fshop%26sign%3DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%2C%2C&_sign=yBTYxCh0uB6YSglhQfg4uoP%2BRz4%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=&_locale=zh_CN">注册</a>
            <span class="sep">|</span>
            <a class="link"
               href="https://account.xiaomi.com/fe/service/login/password?_qrsize=180&sid=mi_eshop&qs=%253Fcallback%253Dhttp%25253A%25252F%25252Forder.mi.com%25252Flogin%25252Fcallback%25253Ffollowup%25253Dhttps%2525253A%2525252F%2525252Fwww.mi.com%2525252Fshop%252526sign%25253DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%25252C%25252C%2526sid%253Dmi_eshop%2526_qrsize%253D180&callback=http%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252Fshop%26sign%3DODA5NjU3ZjZkYjkxMWE3ZjVkYTE5M2MxMDNlYmJkYzJhZGFjNzBhYg%2C%2C&_sign=yBTYxCh0uB6YSglhQfg4uoP%2BRz4%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=&_locale=zh_CN">消息通知</a>
            <span class="sep">|</span>
        </div>
    </div>
</div>
<div class="sub-header">
    <div class="container">
        <div class="header-logo">
            <a href="https://www.mi.com">
                <img alt="小米官网" class="logo-ir" src="https://s02.mifile.cn/assets/static/image/logo-mi2.png">
            </a>
        </div>
        <div class="menu-list">
            <ul class="nav-list">
                <li class="nav-category"></li>
                <li class="nav-item">
                    <span class="text">Xiaomi手机</span>
                </li>
                <li class="nav-item">
                    <span class="text">Redmi手机</span>
                </li>
                <li class="nav-item">
                    <span class="text">电视</span>
                </li>
                <li class="nav-item">
                    <span class="text">笔记本</span>
                </li>
                <li class="nav-item">
                    <span class="text">平板</span>
                </li>
                <li class="nav-item">
                    <span class="text">家电</span>
                </li>
                <li class="nav-item">
                    <span class="text">路由器</span>
                </li>
                <li class="nav-item">
                    <span class="text">服务中心</span>
                </li>
                <li class="nav-item">
                    <span class="text">社区</span>
                </li>
            </ul>
        </div>
        <div class="search">
            <form action="//search.mi.com/search" class="search-form clearfix" method="get">
                <input autocomplete="off" class="search-text" id="search" name="keyword" placeholder="路由器"
                       type="search">
                <input class="search-btn" type="submit" value="🔍">
            </form>
        </div>
        <div style="clear: both;"></div>
    </div>
</div>
<div class="home-hero-container">
    <div class="home-hero">
        <img alt="推荐图片" height="670" src="static/1.jpg" width="1226">
    </div>
    <div class="news">
        <div class="container">
            <div class="channel left">
                <div class="item">
                    <a href="https://www.mi.com">
                        <img alt=""
                             src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/82abdba456e8caaea5848a0cddce03db.png?w=48&h=48">
                        <div>保障服务</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img alt=""
                             src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/806f2dfb2d27978e33fe3815d3851fa3.png?w=48&h=48">
                        <div>企业团购</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img alt=""
                             src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/eded6fa3b897a058163e2485532c4f10.png?w=48&h=48">
                        <div>F码通道</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img alt=""
                             src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/43a3195efa6a3cc7662efed8e7abe8bf.png?w=48&h=48">
                        <div>米粉卡</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img alt=""
                             src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/f4846bca6010a0deb9f85464409862af.png?w=48&h=48">
                        <div>以旧换新</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img alt=""
                             src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/9a76d7636b08e0988efb4fc384ae497b.png?w=48&h=48">
                        <div>话费充值</div>
                    </a>
                </div>
                <div style="clear: both;"></div>
            </div>
            <div class="list-item left margin_left">
                <img alt=""
                     src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/d0c515086acb3c3a3e976ad20901aac5.jpg?w=632&h=340"width="316px" height="170px">
            </div>
            <div class="list-item left margin_left">
                <img alt=""
                     src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/254c711cc71facf156ac955b8719dffa.jpg?w=632&h=340"width="316px" height="170px">
            </div>
            <div class="list-item left margin_left">
                <img alt=""
                     src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2b120c0dddc056dcb36e847269fb92cd.jpg?w=632&h=340" width="316px" height="170px">
            </div>
            <div style="clear: both;"></div>
        </div>
    </div>
</div>
</body>
</html>

 自己代码有很大的问题。

下面是老师的范例:

5、范例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>小米商城</title>
    <style>
        /* 去掉body的边距 */
        body {
            margin: 0;
        }

        img {
            width: 100%;
            height: 100%;
        }

        .left {
            float: left;
        }

        .margin_left {
            margin-left: 14.5px;
        }

        .header {
            background-color: #333;
        }

        /* 让中间内容居中 */
        .container {
            width: 1226px;
            margin: 0 auto;     /* 上下为0, 左右为auto */
        }

        /* header class 下的标签 a 自动应用这个样式 */
        .header a {
            color: #b0b0b0;
            line-height: 40px;
            display: inline-block;
            font-size: 12px;
        }

        .header .menu {
            float: left;
            color: white;
        }

        .header a {
            text-decoration: none;
        }

        .header a:hover {
            color: white;
        }

        .header .account {
            float: right;
            color: white;
        }

        .sub-header {
            height: 100px;
        }

        .sub-header .hw {
            width: 234px;
            height: 100px;
        }

        .sub-header .logo {
            float: left;
        }

        /* a标签是行内标签,默认不支持设置高度与边距 因此设置padding是不起作用的,因此可以加上 inline-block */
        .sub-header .logo a {
            padding-top: 22px;
            padding-bottom: 22px;
            display: inline-block;
        }

        /* 设置logo的图片像素大小 */
        .sub-header .logo img {
            height: 56px;
            width: 56px;
        }

        .sub-header .menu {
            width: 400px;
            float:left;
            line-height: 100px;     /* 与行高度保持一致 */
        }

        .sub-header .menu a {
            text-decoration: none;  /* 去掉 a 标签的下划线 */
            color: #333;
            font-size: 16px;
            padding: 0 10px;        /* 设置字体的左右外边距 */
            display: inline-block;
        }

        /* 鼠标放到字体时,使字体变红 */
        .sub-header .menu a:hover {
            color: #ff6700;
        }

        .sub-header .search {
            float: right;
        }

        .slider {
            height: 460px;
        }

        .news{
            margin-top: 14px;
        }

        .news .channel {
            width: 228px;
            height: 164px;
            background-color: #5f5750;
            padding: 3px;
        }

        .news .channel .item {
            width: 76px;
            height: 82px;
            float: left;
            text-align: center;
        }

        .news .channel .item img {
            width: 24px;
            height: 24px;
            display: block;         /* 让图片自已占一整行 */
            margin: 0 auto;         /* 让图片垂直居中 */
            margin-bottom: 4px;     /* 设置图片与下方字体的间距 */
        }

        .news .channel .item a {
            display: inline-block;
            font-size: 12px;        /* 设置字体大小 */
            text-decoration: none;  /* a标签去掉下划线 */
            padding-top: 18px;  
            color: #fff;          /* 设置字体为白色 */
            opacity: 0.7;           /* 设置透明度 */
        }

        .news .channel .item a:hover {
            opacity: 1;           /* 设置透明度 */
        }


        .news .list-item {
            width: 316px;
            height: 170px;
        }



    </style>

</head>
<body>
    <div class="header">
        <div class="container">
            <div class="menu">
                <a href="https://www.mi.com">小米商城</a>
                <a href="https://www.mi.com">MIUI</a>
                <a href="https://www.mi.com">云平台</a>
                <a href="https://www.mi.com">有品</a>
                <a href="https://www.mi.com">小爱开放平台</a>
            </div>
            <div class="account">
                <a href="https://www.mi.com">登录</a>
                <a href="https://www.mi.com">注册</a>
                <a href="https://www.mi.com">消息通知</a>
            </div>'
            <div style="clear: both;"></div>
        </div>
    </div>
    <div class="sub-header">
        <div class="container">
            <div class="hw logo">
                <a href="https://www.mi.com">
                    <img src="https://s02.mifile.cn/assets/static/image/logo-mi2.png" alt="小米官网">
                </a>
            </div>
            <div class="hw menu">
                <a href="https://www.mi.com">Xiaomi手机</a>
                <a href="https://www.mi.com">Redmi手机</a>
                <a href="https://www.mi.com">电视</a>
                <a href="https://www.mi.com">笔记本</a>
                <a href="https://www.mi.com">平板</a>
            </div>
            <div class="hw search"></div>
            <div style="clear: both;"></div>
        </div>
    </div>
    <div class="slider">
        <div class="container">
            <div>
                <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/454c1da2c5b64a3f2c07c5a4c01aa9c4.jpg?thumb=1&w=1533&h=575&f=webp&q=90" alt="推荐商品">
            </div>
        </div>
    </div>
    <div class="news">
        <div class="container">
            <div class="channel left">
                <div class="item">
                    <a href="https://www.mi.com">
                        <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/82abdba456e8caaea5848a0cddce03db.png?w=48&h=48" alt="">
                        <div>保障服务</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/806f2dfb2d27978e33fe3815d3851fa3.png?w=48&h=48" alt="">
                        <div>企业团购</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/eded6fa3b897a058163e2485532c4f10.png?w=48&h=48" alt="">
                        <div>F码通道</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/43a3195efa6a3cc7662efed8e7abe8bf.png?w=48&h=48" alt="">
                        <div>米粉卡</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/f4846bca6010a0deb9f85464409862af.png?w=48&h=48" alt="">
                        <div>以旧换新</div>
                    </a>
                </div>
                <div class="item">
                    <a href="https://www.mi.com">
                        <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/9a76d7636b08e0988efb4fc384ae497b.png?w=48&h=48" alt="">
                        <div>话费充值</div>
                    </a>
                </div>
                <div style="clear: both;"></div>
            </div>
            <div class="list-item left margin_left">
                <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/d0c515086acb3c3a3e976ad20901aac5.jpg?w=632&h=340" alt="">
            </div>
            <div class="list-item left margin_left">
                <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/254c711cc71facf156ac955b8719dffa.jpg?w=632&h=340" alt="">
            </div>
            <div class="list-item left margin_left">
                <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2b120c0dddc056dcb36e847269fb92cd.jpg?w=632&h=340" alt="">
            </div>
            <div style="clear: both;"></div>
        </div>
    </div>
</body>
</html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/175293.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

七大排序---详细介绍

插入排序从第二个数&#xff0c;往前面进行插入&#xff0c;默认第一个数字有序&#xff0c;插入第二个&#xff0c;则前两个都有序了&#xff0c;一个一个往后选择数字&#xff0c;不断向前进行插入直接插入排序时间复杂度&#xff1a;最好情况&#xff1a;全部有序&#xff0…

决策树应用

使用Python中的sklearn中自带的决策树分类器DecisionTreeClassifier import sklearn clf sklearn.tree.DecisionTreeClassifier(criterionentropy)sklearn中只实现了ID3与CART决策树&#xff0c;所以我们暂时只能使用这两种决策树&#xff0c;在构造DecisionTreeClassifier类…

计算机视觉OpenCv学习系列:第六部分、图像操作-2

第六部分、图像操作-2第一节、图像几何形状绘制1.几何形状2.填充、绘制与着色3.代码练习与测试第二节、多边形填充与绘制1.多边形绘制函数2.绘制与填充3.代码练习与测试第三节、图像像素类型转换与归一化1.归一化方法与支持2.归一化函数3.代码练习与测试第四节、图像几何变换1.…

小智学长嵌入式入门学习路线_1 C语言基础

原课程链接&#xff1a; 嵌入式开发系统学习路线 从基础到项目 精品教程 单片机工程师必备课程 物联网开发 c语言 2022追更 前言 在学习过程中&#xff0c;老师提到了一个很重要的思想&#xff1a;主要从学习嵌入式的角度学习各项技能。比如c语言&#xff0c;语法有很多&…

【Java|golang】1807. 替换字符串中的括号内容

给你一个字符串 s &#xff0c;它包含一些括号对&#xff0c;每个括号中包含一个 非空 的键。 比方说&#xff0c;字符串 “(name)is(age)yearsold” 中&#xff0c;有 两个 括号对&#xff0c;分别包含键 “name” 和 “age” 。 你知道许多键对应的值&#xff0c;这些关系由…

Linux基本功系列之chmod命令实战

文章目录一. chmod命令介绍二. 语法格式及常用选项三. 参考案例3.1 对全部用户增加写的权限3.2 所有用户减去读的权限3.3 给文件的所有者和所有组加上读写权限3.4 设置所有用户为读写执行的权限3.5 文件拥有着为rwx&#xff0c;所属组为rw&#xff0c;其它为r3.6 去掉所有者的r…

高级Spring之ApplicationContext功能

第一步&#xff0c;我们先来看这个接口的内部结构&#xff0c;了解别人的内部&#xff0c;知己知彼&#xff0c;百战不殆&#xff1a; 这个接口的扩展功能主要体现在它继承的四个接口上&#xff1a; MessageSource&#xff1a;国际化功能 ResourcePatternResolver: 资源访问功…

第23章_Tomcat和JavaEE入门

一、JavaEE简介什么是JavaEEJavaEE&#xff08;Java Enterprise Edition&#xff09;&#xff0c;Java企业版&#xff0c;是一个用于企业级web开发平台。最早由Sun公司定制并发布&#xff0c;后由Oracle负责维护。JavaEE平台规范了在开发企业级web应用中的技术标准.在JavaEE平台…

Acwing——第 87 场周赛

题目链接 4797. 移动棋子 4798. 打怪兽 4799. 最远距离 题目描述 4797. 移动棋子 给定一个 5 行 5 列的方格矩阵&#xff0c;其中一个方格中有一个棋子。 现在&#xff0c;我们希望将棋子移动至矩阵的最中心方格中&#xff0c;即将其移动至矩阵的第 3行第 3列方格中。 每次…

8种时间序列分类方法总结

对时间序列进行分类是应用机器和深度学习模型的常见任务之一。本篇文章将涵盖 8 种类型的时间序列分类方法。这包括从简单的基于距离或间隔的方法到使用深度神经网络的方法。这篇文章旨在作为所有时间序列分类算法的参考文章。 时间序列定义 在涵盖各种类型的时间序列 (TS) 分…

分布式锁与实现(一)-为什么需要分布式锁

1 在开发中的锁是什么 在计算机科学中&#xff0c;锁是在执行多线程时用于强行限制资源访问的同步机制&#xff0c;即用于在并发控制中保证对互斥要求的满足。 在java中我们有两种资源控制方式Synchronized与AQS 1.2 基于Synchronized实现的锁控制 Synchronized是java提供的一…

JDK 8新特性之Lambda表达式

目录 一&#xff1a;使用匿名内部类存在的问题 Lambda表达式写法,代码如下&#xff1a; 二&#xff1a;Lambda的标准格式 三&#xff1a;Lambda的实现原理 四&#xff1a;Lambda省略格式 五&#xff1a;Lambda的前提条件 六&#xff1a;函数式接口 七&#xff1a;Lambd…

05回溯法

文章目录装载问题回溯算法优化算法构造最优解0-1背包问题批处理作业调度问题图的M着色问题N皇后问题最大团问题回溯算法实际上一个类似枚举的搜索尝试过程&#xff0c;主要是在搜索尝试过程中寻找问题的解&#xff0c;当发现已不满足求解条件时&#xff0c;就“回溯”返回&…

12. 字典dict类型详解

1. 基础知识 (1) 字典(dictionary)是Python中另一个非常有用的内置数据类型。 (2) 列表是有序的对象集合&#xff0c;字典是无序的对象集合。两者之间的区别在于&#xff1a;字典当中的元素是通过键来存取的&#xff0c;而不是通过偏移存取。 (3) 字典是一种映射类型&#xff…

Flowable进阶学习(三)流程、流程实例挂起与激活;启动、处理、结束流程的原理以及相关表结构与变动

文章目录流程挂起与激活流程实例挂起与激活启动、处理、结束流程的原理一、启动流程的原理启动一个流程实例时涉及到的表及表结构:ACT_RU_EXECUTION 运行时流程执行实例ACT_RU_IDENTITYLINK 运行时用户关系信息ACT_RU_TASK 运行时任务表ACT_RU_VARIABLE 运行时变量表二、处理流…

过滤器Filter总结

过滤器Filter1. 简介2. 快速入门3. 执行流程4. 使用细节4.1 拦截路径4.2 过滤器链5. 案例5.1 需求5.2 LoginFilter1. 简介 过滤器是JavaWeb三大组件之一&#xff08;Servlet、Filter&#xff0c;Listner&#xff09;&#xff1b; 作用&#xff1a; 把对资源&#xff08;servl…

Ubuntu22.04 安装 ssh

文章目录Ubuntu22.04 安装 ssh一、 环境配置二、 启动远程连接三、 开放端口四、 远程连接Ubuntu22.04 安装 ssh 一、 环境配置 安装 Ubuntu 系统后&#xff0c;我们首先需要配置管理员 root 用户&#xff1a; sudo passwd root然后&#xff0c;进行软件源的更换&#xff1a…

14 Java集合(Map集合+HashMap+泛型使用+集合面试题)

集合14.11 Map集合14.11.1 Map集合特点14.11.2 Map集合体系结构14.12 HashMap14.12.1 HashMap基本使用14.12.2 HashMap实际应用14.12.3 HashMap练习14.12.4 HashMap底层实现原理14.12.5 put的过程原码14.12.6 resize过程原码14.12.7 get的过程原码14.13 HashTable14.14 泛型高级…

5-1中央处理器-CPU的功能和基本结构

文章目录一.CPU的功能二.CPU的基本结构&#xff08;一&#xff09;运算器1.运算器的基本组成2.专用数据通路方式3.CPU内部单总线方式&#xff08;二&#xff09;控制器1.基本组成2.实现过程&#xff08;三&#xff09;寄存器一.CPU的功能 中央处理器&#xff08;CPU&#xff0…

并查集的入门与应用

目录 一、前言 二、并查集概念 1、并查集的初始化 2、并查集的合并 3、并查集的查找 4、初始化、查找、合并代码 5、复杂度 二、路径压缩 三、例题 1、蓝桥幼儿园&#xff08;lanqiaoOJ题号1135&#xff09; 2、合根植物&#xff08;2017年决赛&#xff0c;lanqiaoO…