• CSS自适应页面


    资源

    链接:https://pan.baidu.com/s/1WLAI5ceQlgAYel9oxLFpyQ 
    提取码:5htf 

    index.html

    页面包含导航栏、视频、轮播图、菜单栏

    1. html>
    2. <html>
    3. <head>
    4. <meta charset="utf-8" />
    5. <meta name="viewport" content="user-scalable=no,width=device-width,initial-scale=1.0,maximun-scale=1.0"/>
    6. <link rel="stylesheet" type="text/css" href="css/index.css"/>
    7. <link rel="stylesheet" type="text/css" href="css/media.css"/>
    8. <link rel="stylesheet" href="css/daohang.css">
    9. <title>title>
    10. head>
    11. <body>
    12. <ul>
    13. <li><a href="#">主页a>li>
    14. <li><a href="#">订餐a>li>
    15. <li><a href="#">联系方式a>li>
    16. <li style="float:right"><a href="#" class="active">关于a>li>
    17. ul>
    18. <div class="container">
    19. <div class="inner">
    20. <div>
    21. <video
    22. src="image/999.mp4"
    23. autoplay="autoplay"
    24. loop="loop"
    25. muted="muted"
    26. controls="controls"
    27. controlsList="nodownload"
    28. height="100%" width="100%">
    29. video>
    30. div>
    31. <div class="demo">
    32. <div class="demo1">
    33. <img src="image/1.jpg" alt="">
    34. <img src="image/2.jpg" alt="">
    35. <img src="image/3.jpg" alt="">
    36. <img src="image/4.jpg" alt="">
    37. <img src="image/5.jpg" alt="">
    38. <img src="image/6.jpg" alt="">
    39. div>
    40. div>
    41. <div class="inner_hd">
    42. <h2>
    43. <img class="hd_left" src="image/box_hd_left.png" alt="" />
    44. 汉堡王套餐
    45. <img class="hd_right" src="image/box_hd_right.png" alt="" />
    46. h2>
    47. div>
    48. <div class="box">
    49. <ul class="item">
    50. <li>
    51. <a>
    52. <div class="img_box">
    53. <img src="image/11.jpg" alt="" />
    54. div>
    55. <h2>热咖啡(10.00 元/杯)h2>
    56. <div class="bottom_box">
    57. <span>饮料span>
    58. <p>55人购买p>
    59. div>
    60. a>
    61. li>
    62. <li>
    63. <a>
    64. <div class="img_box">
    65. <img src="image/22.jpg" alt="" />
    66. div>
    67. <h2>臻选豆浆(8.00 元/杯)h2>
    68. <div class="bottom_box">
    69. <span>饮料span>
    70. <p>32人购买p>
    71. div>
    72. a>
    73. li>
    74. <li>
    75. <a>
    76. <div class="img_box">
    77. <img src="image/33.jpg" alt="" />
    78. div>
    79. <h2>法式培根蛋包芝士堡(14.00 元/份)h2>
    80. <div class="bottom_box">
    81. <span>汉堡span>
    82. <p>27人购买p>
    83. div>
    84. a>
    85. li>
    86. <li>
    87. <a>
    88. <div class="img_box">
    89. <img src="image/44.jpg" alt="" />
    90. div>
    91. <h2>火烤猪肉蛋包芝士堡(10.00 元/份)h2>
    92. <div class="bottom_box">
    93. <span>汉堡span>
    94. <p>46人购买p>
    95. div>
    96. a>
    97. li>
    98. <li>
    99. <a>
    100. <div class="img_box">
    101. <img src="image/55.jpg" alt="" />
    102. div>
    103. <h2>火炬香草冰淇淋(3.00 元/份)h2>
    104. <div class="bottom_box">
    105. <span>甜品span>
    106. <p>34人购买p>
    107. div>
    108. a>
    109. li>
    110. <li>
    111. <a>
    112. <div class="img_box">
    113. <img src="image/66.jpg" alt="" />
    114. div>
    115. <h2>新地巧克力/草莓(8.00 元/份)h2>
    116. <div class="bottom_box">
    117. <span>甜品span>
    118. <p>43人购买p>
    119. div>
    120. a>
    121. li>
    122. <li>
    123. <a>
    124. <div class="img_box">
    125. <img src="image/77.jpg" alt="" />
    126. div>
    127. <h2>美式脆鸡堡套餐(19.00 元/份)h2>
    128. <div class="bottom_box">
    129. <span>套餐span>
    130. <p>54人购买p>
    131. div>
    132. a>
    133. li>
    134. <li>
    135. <a>
    136. <div class="img_box">
    137. <img src="image/88.jpg" alt="" />
    138. div>
    139. <h2>薯你风情套餐(15.00 元/份)h2>
    140. <div class="bottom_box">
    141. <span>套餐span>
    142. <p>36人购买p>
    143. div>
    144. a>
    145. li>
    146. <li>
    147. <a>
    148. <div class="img_box">
    149. <img src="image/99.jpg" alt="" />
    150. div>
    151. <h2>霸王鸡盒(33.00 元/份)h2>
    152. <div class="bottom_box">
    153. <span>小食span>
    154. <p>99人购买p>
    155. div>
    156. a>
    157. li>
    158. <li>
    159. <a>
    160. <div class="img_box">
    161. <img src="image/100.jpg" alt="" />
    162. div>
    163. <h2>芝士肉酱薯霸王(16.00 元/份)h2>
    164. <div class="bottom_box">
    165. <span>小食span>
    166. <p>101人购买p>
    167. div>
    168. a>
    169. li>
    170. ul>
    171. div>
    172. div>
    173. div>
    174. body>
    175. html>

    index.css

    视频和轮播图设置

    1. *{
    2. padding: 0;
    3. margin: 0;
    4. box-sizing: border-box;
    5. }
    6. ul li{
    7. list-style: none;
    8. }
    9. a{
    10. text-decoration: none;
    11. outline: none;
    12. color: #333;
    13. }
    14. h1,h2,h3,h4,h5,h6{
    15. font-weight: normal;
    16. }
    17. .container{
    18. background-color: #f9faff;
    19. }
    20. .inner{
    21. margin: 0 auto;
    22. }
    23. .demo{
    24. width:100%;
    25. height:400px;
    26. margin:0px auto;/*轮播图居中*/
    27. /* background-color:aquamarine; */
    28. overflow: hidden;/*用于隐藏超出展示容器的内容部分*/
    29. }
    30. .demo1{
    31. width:6000px;
    32. height:400px;
    33. margin:0px auto;
    34. animation:text 30s infinite linear;
    35. font-size:0px;/*消除图片间隔*/
    36. }
    37. @keyframes text { /*0%-20%是播放下一个图片,0%-10%是图片暂停的时间*/
    38. 0%,10%{
    39. margin-left:0px;
    40. }
    41. 20%,30%{
    42. margin-left:-1200px;
    43. }
    44. 40%,50%{
    45. margin-left:-2400px;
    46. }
    47. 60%,70%{
    48. margin-left:-3600px;
    49. }
    50. 80%,90%{
    51. margin-left:-4800px;
    52. }
    53. }
    54. .demo1 img{
    55. width:1200px;
    56. height:400px;
    57. float:left;/*开启浮动*/
    58. }
    59. .inner_hd{
    60. width: 100%;
    61. text-align: center;
    62. padding: 40px 0 20px 0;
    63. }
    64. .inner_hd h2{
    65. font-size: 36px;
    66. color: #313131;
    67. font-weight: bold;
    68. display: inline-block;
    69. position: relative;
    70. }
    71. h2 img{
    72. position: absolute;
    73. }
    74. h2 .hd_left{
    75. left: -20px;
    76. top: 16px;
    77. }
    78. h2 .hd_right{
    79. right: -20px;
    80. top: 2px;
    81. }
    82. .box{
    83. padding: 30px 0;
    84. }
    85. .item{
    86. width: 100%;
    87. display: flex;
    88. flex-direction: row;
    89. justify-content: start;
    90. flex-wrap: wrap;
    91. }
    92. .item li{
    93. width: 20%;
    94. overflow: hidden;
    95. border-radius: 10px;
    96. padding: 0 10px 30px 10px;
    97. }
    98. .item li .img_box{
    99. height: auto;
    100. border-radius: 10px;
    101. overflow: hidden;
    102. }
    103. .img_box img{
    104. width: 100%;
    105. max-height: 100%;
    106. }
    107. .item li h2{
    108. font-size: 15px;
    109. color: #f9faff;
    110. line-height: 24px;
    111. margin: 10px 0;
    112. padding: 0 10px;
    113. overflow: hidden;
    114. text-overflow: ellipsis;
    115. display: -webkit-box;
    116. -webkit-box-orient: vertical;
    117. -webkit-line-clamp: 2;
    118. height: 45px;
    119. }
    120. .item li .bottom_box{
    121. padding: 0 10px;
    122. }
    123. .item li .bottom_box span{
    124. width: 42px;
    125. color: #f9faff;
    126. }
    127. .item li .bottom_box p{
    128. width: auto;
    129. float: right;
    130. background: url(../img/icon.jpg)no-repeat left center;
    131. padding-left: 20px;
    132. color: #f9faff;
    133. }

    daohang.css

    导航栏设置

    1. ul {
    2. padding: 0px;
    3. margin: 0px;
    4. list-style-type: none;
    5. background-color: #333;
    6. /*border: 1px solid black;*/
    7. overflow: hidden;
    8. }
    9. li {
    10. float: left;
    11. /*border: 1px solid black;*/
    12. }
    13. a {
    14. color: white;
    15. display: block;
    16. padding: 14px 16px;
    17. text-decoration: none;
    18. }
    19. a:hover:not(.active) {
    20. background-color: #111;
    21. }
    22. .active {
    23. background-color: #4CAF50;
    24. }
    25. li {
    26. border-right: 1px solid #bbb;
    27. }
    28. li:last-child {
    29. border-right: none;
    30. }

    media.css

    菜单栏设置

    /*超大屏幕大于等于1200px*/

    @media  screen and (max-width:575px){

        .inner{

            width: 100%;

        }

        .inner_hd{

            padding: 30px 0;

        }

        .item li {

            width: 50%;

        }

        .inner_hd h2{

            font-size: 26px;

        }

    }

    /*大屏幕大于等于992px*/

    @media screen and (min-width:576px){

        .inner{

            width: 540px;

        }

        .item li{

            width: 50%;

        }

        .inner_hd h2{

            font-size: 30px;

        }

    }

    /*中等屏幕大于等于768*/

    @media screen and (min-width:768px){

        .inner{

            width: 720px;

        }

        .item li{

            width: 33.3%;

        }

    }

    /*小屏幕大于等于576*/

    @media screen and (min-width:992px){

        .inner{

            width: 960px;

        }

        .item li{

            width: 25%;

        }

    }

    /*超小屏幕小于576*/

    @media screen and (min-width:1200px){

        .inner{

            width: 1200px;

        }

        .item li{

            width: 20%;

        }

    }

  • 相关阅读:
    一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
    2021年研究生数模B题论文记录
    云计算与ai人工智能对高防cdn的发展
    Jetpack Compose Effect 的作用
    进程通信——共享内存
    看了 4K 经典中视频,我才知道 30 多年前的艺术家有多牛
    学生宿舍管理系统(前端java+后端Vue)实现-含前端与后端程序
    在RHEL/CentOS 7上设置用于多个Linux发行版安装的“PXE网络启动服务器“
    搭建nacos集群,并通过nginx实现负载均衡
    pyspark常用功能记录
  • 原文地址:https://blog.csdn.net/lyshark_lyshark/article/details/126799877