Vue复刻华为官网 (一)

news2025/2/24 3:19:16

1 分析

image-20221021084853428

根据华为网页的布局,我们大体上可以将其划分为7个盒子,如下,由于写一个这样的网页再加上部分动态效果,需要的时间很长,本篇博客只记录了div1、div2、div3的静态效果+轮播图的实现。

image-20221021085505157

2 顶部盒子的实现

想要实现的正是最上部那个黑色的圆框

image-20221021085728984

2.1 思路

我的思路很简单,用四个盒子,其中最大的盒子也就是整个黑色框,大盒子里面包裹着小盒子,每个小盒子对应一个字段(集团网站、选择区域/语言、登录),排版布局,则需要三个小盒子,依次向左浮动(float:left;)。或者大盒子单独采用display:flex;布局

我看了一下华为公司的代码,他是用的一个盒子,里面包裹了3个a标签,我用div习惯了,所以用的是div。

2.2 代码实现

  <div class="top_container">
        <div class="container_div1">
          集团网站
        </div>
        <div class="container_div2">
          选择区域/语言
        </div>
        <div class="container_div3">
          登录
        </div>
  </div>
.div_top {
  height: 25px;
  width: 100%;
  position: static;
  text-align: right;
  background-color: #111111;
}

.top_container {
  width: 300px;
  height: 25px;
  float: right;
  margin-right: 70px;
  display: flex;
  flex-direction: row;
  /* background-color: red; */
}

.container_div1 {
  width: 80px;
  height: 25px;
  /* background-color: aqua; */
  margin-right: 10px;
  line-height: 25px;
  font-size: 10px;
  text-align: center;
  color: #ffffff;
  cursor: pointer;
}

.container_div2 {
  width: 140px;
  height: 25px;
  /* background-color: aqua; */
  line-height: 25px;
  font-size: 10px;
  text-align: center;
  color: #ffffff;
  cursor: pointer;
}

.container_div3 {
  width: 60px;
  height: 25px;
  margin-left: 10px;
  /* background-color: aqua; */
  line-height: 25px;
  font-size: 10px;
  text-align: center;
  color: #ffffff;
  cursor: pointer;
}

3 头部盒子的实现

正是此处

image-20221021090620270

3.1 思路

首先分成了三个大盒子,分别对应左、中、右三个组件,其中每一个字段或者图标都对应一个小盒子。其中中间容器的那些小盒子都需要不同的样式,因为他有一个悬浮的效果,悬浮的时候,会有一个红色的底框,而且长度各不同。

Honeycam 2022-10-21 09-08-18

所以我为每个盒子设置了不同的宽高。

华为采用的是ul-li的形式,我本来写的是没有动态的数据,我还得自己写数组,好麻烦,还不如写div轻松。后来想想,用不着写数据,还是ul-li好用一些

3.2 代码实现

 <div class="div_header">
      <div class="header_left">
        <a class="header_logo">
          <img src="@/assets/huawei_logo.png" alt="">
        </a>
      </div>
      <div class="header_info">
        <div class="info_div1">
          <span class="info_span1">
            个人及家庭产品
          </span>
        </div>
        <div class="info_div2">
          <span class="info_span2">
            商用产品及方案
          </span>
        </div>
        <div class="info_div3">
          <span class="info_span3">
            服务支持
          </span>
        </div>
        <div class="info_div4">
          <span class="info_span4">
            合作伙伴与开发者
          </span>
        </div>
        <div class="info_div5">

          <span class="info_span5">
            关于华为
          </span>
        </div>
      </div>
      <div class="header_right">
        <div class="right_info">
          <span>在线购买</span>

        </div>
        <div class="right_logo">
          <span class="logo_span">

          </span>
        </div>
      </div>
    </div>
.div_header {
  width: 100%;
  height: 78px;
  background-color: #fff;

  border-bottom: 1px solid #e6e6e6;
  display: flex;
}

.header_left {
  width: 266px;
  height: 100%;
  margin-left: 50px;


}

.header_logo {
  width: 133px;
  height: 30px;
  cursor: pointer;
}

.header_logo img {
  width: 133px;
  height: 30px;
  margin-top: 22px;
}

.header_info {
  width: 800px;
  height: 100%;
  margin-left: 140px;
  /* background-color: red; */
}


.info_div1 {
  width: 110px;
  height: 100%;
  font-size: 0.9em;
  float: left;
  line-height: 78px;
  text-align: center;
  cursor: pointer;

}

.info_div2 {
  width: 110px;
  height: 100%;
  font-size: 0.9em;
  line-height: 78px;
  float: left;
  text-align: center;
  margin-left: 30px;
  cursor: pointer;
}

.info_div3 {
  width: 58px;
  height: 100%;
  font-size: 0.9em;
  line-height: 78px;
  float: left;
  text-align: center;
  margin-left: 30px;
  cursor: pointer;
}

.info_div4 {
  width: 116px;
  height: 100%;
  font-size: 0.9em;
  line-height: 78px;
  float: left;
  text-align: center;
  margin-left: 30px;
  cursor: pointer;
}

.info_div5 {
  width: 58px;
  height: 100%;
  font-size: 0.9em;
  line-height: 78px;
  float: left;
  text-align: center;
  margin-left: 30px;
  cursor: pointer;
}

.info_div1:hover {

  border-bottom: 1px solid red;

}

.info_div2:hover {
  border-bottom: 1px solid red;
}

.info_div3:hover {
  border-bottom: 1px solid red;
}

.info_div4:hover {
  border-bottom: 1px solid red;
}

.info_div5:hover {
  border-bottom: 1px solid red;
}

.header_right {
  margin-left: 10px;
  width: 220px;
  /* background-color: aqua; */
}

.right_info {
  float: left;
  width: 120px;
  height: 100%;
  font-size: 17px;
  line-height: 78px;
  text-align: center;
  cursor: pointer;
  /* background-color: #111111; */
}

.right_logo {
  width: 80px;
  height: 100%;
  float: left;
  line-height: 78px;

}

.logo_span {
  content: "\e62f";
}

3.3 效果图

在这里插入图片描述

4 轮播图的实现

image-20221021091458647

4.1 思路

这里颇费了一些周章,轮播图还算好实现的,毕竟可以直接使用Swiper。

但是这里还是有一些特别的点,主要如下:

  • 鼠标的移入移出,前进后退的显示与隐藏
  • 了解更多按钮的镶嵌
  • 轮播图分页器形式的改变(由点变成了狭长的长方形)

我们各个击破

4.1.1 使用轮播图

轮播图的教程网站

首先需要引入,在终端输入

npm install swiper

image-20221021092141577

然后再使用的地方import

import "swiper/swiper-bundle.min.css";  // 所有 Swiper 样式,包括所有模块样式(如导航、分页等)
import Swiper, { Navigation, Pagination, Scrollbar, Autoplay } from "swiper"; // 导入您需要的模块

只需要在mounted的时候,写下如下代码便可使用

 mounted() {
        new Swiper(".swiper", {
            speed: 500,//播放的速度
            // spaceBetween: 2000,// 轮播图之间的间距
            loop: true,//是否循环播放
            autoplay: {
                delay: 2000,//自动播放的间隔
            },
            modules: [Navigation, Pagination, Scrollbar, Autoplay],
            navigation: {
                nextEl: ".swiper-button-next",//前一个按钮
                prevEl: ".swiper-button-prev",//后一个按钮
            },
            scrollbar: {
                el: ".swiper-scrollbar",
                draggable: true,
            },
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
                bulletClass : 'my-bullet',//需设置.my-bullet样式
                bulletActiveClass: 'my-bullet-active',
            },
        });
    <div class="div_swiper">
        <div class="swiper" @mousemove="showSwiperButton()" @mouseout="hiddenSwiperButton()">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <img class="slide_img" src="@/assets/huawei-cloud-discount-pc.jpg" />
                    <button class="img_btn">了解更多</button>
                </div>
                <div class="swiper-slide">
                    <img class="slide_img" src="@/assets/vmall-mate50-series-3.jpg" />
                    <button class="img_btn">了解更多</button>
                </div>

            </div>
            <div class="swiper-button-prev" id="prev"></div>
            <!--左箭头。如果放置在swiper外面,需要自定义样式。-->
            <div class="swiper-button-next" id="next"></div>
            <!--右箭头。如果放置在swiper外面,需要自定义样式。-->
            <div class="swiper-pagination"></div>
            <!--分页器。如果放置在swiper外面,需要自定义样式。-->
        </div>
    </div>

4.1.2 前进后退的隐藏与显示

这里很显然用到鼠标事件,当鼠标移入的时候,设置一个方法,让前进后退按钮显示出来,当鼠标移出的时候,将前进后退设置为隐藏,当然前进后退初始是隐藏的。

methods:
{
       showSwiperButton() {
       let d1 = document.getElementById('prev');
       d1.style.cssText = "display:block;"
       let d2 = document.getElementById('next');
       d2.style.cssText = "display:block;"
},
		hiddenSwiperButton() {
	    let d1 = document.getElementById('prev');
        d1.style.cssText = "display:none;"
        let d2 = document.getElementById('next');
        d2.style.cssText = "display:none;"
        }
    }

同时绑定Swiper盒子,当鼠标移入Swiper盒子的时候显示,移出Swiper盒子的时候隐藏

<div class="swiper" @mousemove="showSwiperButton()" @mouseout="hiddenSwiperButton()"></div>

4.1.3 了解更多按钮的实现

image-20221021095946673

看到这个图的时候,我就清楚,显然是要在了解更多的position上下功夫,让图片的盒子沾满父盒子的空间,而了解更多按钮则采用absolute定位,让其相对父组件定位。

4.1.4 轮播图分页器样式

image-20221021100227939

轮播图的分页器一般都是圆点样式,如上。如何修改轮播图分页器的样式呢?我参考了Swiper的文档,发现可以修改分页器的类名,进而可以修改它的样式。

image-20221021100357755

这里要注意的一点是,再修改的时候,尽量在原有的基础上修改,就是先看看他默认的样式是什么样的,然后在此基础上增加我自己的样式,这样的话,不会影响分页器的排版。

.my-bullet{
 
    width: var(--swiper-pagination-bullet-width,var(--swiper-pagination-bullet-size,100px));
    height: var(--swiper-pagination-bullet-height,var(--swiper-pagination-bullet-size,3px));
    display: inline-block;
    background: var(--swiper-pagination-bullet-inactive-color,#000);
    opacity: var(--swiper-pagination-bullet-inactive-opacity, .2);
    margin: 0 7px;
    cursor: pointer;
    border: 0;
}

修改正在加载的样式

.my-bullet-active{
    background: #ffffff;
    opacity: 1;
}

同时要在mounted里面,修改一下

  pagination: {
                el: '.swiper-pagination',
                clickable: true,
                bulletClass : 'my-bullet',//需设置.my-bullet样式
                bulletActiveClass: 'my-bullet-active',
            },

4.2 代码实现

我把轮播图单独写成了一个组件

Home.vue

<template>
    <div class="div_swiper">
        <div class="swiper" @mousemove="showSwiperButton()" @mouseout="hiddenSwiperButton()">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <img class="slide_img" src="@/assets/huawei-cloud-discount-pc.jpg" />
                    <button class="img_btn">了解更多</button>
                </div>
                <div class="swiper-slide">
                    <img class="slide_img" src="@/assets/vmall-mate50-series-3.jpg" />
                    <button class="img_btn">了解更多</button>
                </div>

            </div>
            <div class="swiper-button-prev" id="prev"></div>
            <!--左箭头。如果放置在swiper外面,需要自定义样式。-->
            <div class="swiper-button-next" id="next"></div>
            <!--右箭头。如果放置在swiper外面,需要自定义样式。-->
            <div class="swiper-pagination"></div>
            <!--分页器。如果放置在swiper外面,需要自定义样式。-->
        </div>
    </div>
</template>

<script>
import "swiper/swiper-bundle.min.css";  // 所有 Swiper 样式,包括所有模块样式(如导航、分页等)
import Swiper, { Navigation, Pagination, Scrollbar, Autoplay } from "swiper"; // 导入您需要的模块
export default {
    name: 'MySwiper',
    methods:
    {
        showSwiperButton() {
            let d1 = document.getElementById('prev');
            d1.style.cssText = "display:block;"
            let d2 = document.getElementById('next');
            d2.style.cssText = "display:block;"
        },
        hiddenSwiperButton() {
            let d1 = document.getElementById('prev');
            d1.style.cssText = "display:none;"
            let d2 = document.getElementById('next');
            d2.style.cssText = "display:none;"
        }
    },
    mounted() {
        new Swiper(".swiper", {
            speed: 500,//播放的速度
            // spaceBetween: 2000,// 轮播图之间的间距
            loop: true,//是否循环播放
            autoplay: {
                delay: 2000,//自动播放的间隔
            },
            modules: [Navigation, Pagination, Scrollbar, Autoplay],
            navigation: {
                nextEl: ".swiper-button-next",//前一个按钮
                prevEl: ".swiper-button-prev",//后一个按钮
            },
            scrollbar: {
                el: ".swiper-scrollbar",
                draggable: true,
            },
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
                bulletClass : 'my-bullet',//需设置.my-bullet样式
                bulletActiveClass: 'my-bullet-active',
            },
        });

    },

}
</script>

<style>
.div_swiper {
    width: 100%;
    height: 100%;
}

.swiper {
    height: 100%;
    width: 100%;
}

.swiper-wrapper {
    width: 100%;
    height: 100%;

}

.swiper-slide {
    width: 100%;
    height: 100%;
    margin-right: 0px;
    position: relative;
}

.slide_img {
    width: 100%;
}

.img_btn {
    z-index: 100;
    width: 170px;
    height: 42px;
    position: absolute;
    border: 1px solid #111111;
    left: 296px;
    top: 315px;
    color: #111111;
    cursor: pointer;
    /* background-color: red; */
}

.img_btn:hover {
    background-color: rgb(199, 0, 11);
    border: 0px;
    color: #fff;
}

.swiper-button-prev {

    display: none;
}

.swiper-button-next {

    display: none;
}
 
.my-bullet{
 
    width: var(--swiper-pagination-bullet-width,var(--swiper-pagination-bullet-size,100px));
    height: var(--swiper-pagination-bullet-height,var(--swiper-pagination-bullet-size,3px));
    display: inline-block;
    background: var(--swiper-pagination-bullet-inactive-color,#000);
    opacity: var(--swiper-pagination-bullet-inactive-opacity, .2);
    margin: 0 7px;
    cursor: pointer;
    border: 0;
}

.my-bullet-active{
    background: #ffffff;
    opacity: 1;
}
</style>

4.3 效果图

4.3.1 前进后退按钮效果

在这里插入图片描述

4.3.2 切换效果

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-89X5kjAq-1666319157704)(../../桌面文件/1012/Honeycam 2022-10-21 10-15-41.webp)]

4.3.3 了解更多

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yCBL09iy-1666319157705)(../../桌面文件/1012/Honeycam 2022-10-21 10-18-45.webp)]

5 代码汇总

<template>
  <div class="big_div1">
    <div class="div_top">
      <div class="top_container">
        <div class="container_div1">
          集团网站
        </div>
        <div class="container_div2">
          选择区域/语言
        </div>
        <div class="container_div3">
          登录
        </div>
      </div>
    </div>
    <div class="div_header">
      <div class="header_left">
        <a class="header_logo">
          <img src="@/assets/huawei_logo.png" alt="">
        </a>
      </div>
      <div class="header_info">
        <div class="info_div1">
          <span class="info_span1">
            个人及家庭产品
          </span>
        </div>
        <div class="info_div2">
          <span class="info_span2">
            商用产品及方案
          </span>
        </div>
        <div class="info_div3">
          <span class="info_span3">
            服务支持
          </span>
        </div>
        <div class="info_div4">
          <span class="info_span4">
            合作伙伴与开发者
          </span>
        </div>
        <div class="info_div5">

          <span class="info_span5">
            关于华为
          </span>
        </div>
      </div>
      <div class="header_right">
        <div class="right_info">
          <span>在线购买</span>

        </div>
        <div class="right_logo">
          <span class="logo_span">

          </span>
        </div>
      </div>
    </div>
    <div class="div_swiper">
      <MySwiper></MySwiper>
    </div>
    <div class="div_container">
      <div class="div_title">
        <h2 class="title_h2">推荐信息</h2>
      </div>
      <div class="container_imgs">
        <div class="div_row1">
          <div class="row1_col1">
            <a href="" class="col1_a1">
              <div class="a_div1">
                <div class="mask"></div>
                <img src="@/assets/matebook-x-pro2.jpg" alt="" class="a1_img1">
              </div>
              <div class="a_div2">
                <div class="div2_title">
                  产品
                </div>
                <div class="div2_info">
                  HUAWEI MateBook X Pro
                </div>
                <div class="div2_info2">
                  入目惊鸿
                </div>
                <div class="div2_hidden">
                  了解更多
                </div>
              </div>
            </a>
          </div>
          <div class="row1_col2">
            <a href="" class="col1_a1">
              <div class="a_div1">
                <div class="mask"></div>
                <img src="@/assets/2.jpg" alt="" class="a1_img1">
              </div>
              <div class="a_div2">
                <div class="div2_title">
                  产品
                </div>
                <div class="div2_info">
                  HUAWEI MateBook X Pro
                </div>
                <div class="div2_info2">
                  入目惊鸿
                </div>
                <div class="div2_hidden">
                  了解更多
                </div>
              </div>
            </a>
          </div>
        </div>
        <div class="div_row1">
          <div class="row1_col2 ">
            <a href="" class="col1_a1">
              <div class="a_div1">
                <div class="mask"></div>
                <img src="@/assets/3.jpg" alt="" class="a1_img1">

              </div>
              <div class="a_div2">
                <div class="div2_title">
                  产品
                </div>
                <div class="div2_info">
                  HUAWEI MateBook X Pro
                </div>
                <div class="div2_info2">
                  入目惊鸿
                </div>
                <div class="div2_hidden">
                  了解更多
                </div>
              </div>
            </a>
          </div>
          <div class="row1_col3">
            <a href="" class="col1_a1">
              <div class="a_div1">
                <div class="mask"></div>
                <img src="@/assets/4.jpg" alt="" class="a1_img1">
              </div>
              <div class="a_div2">
                <div class="div2_title">
                  产品
                </div>
                <div class="div2_info">
                  HUAWEI MateBook X Pro
                </div>
                <div class="div2_info2">
                  入目惊鸿
                </div>
                <div class="div2_hidden">
                  了解更多
                </div>
              </div>
            </a>
          </div>
        </div>
        <div class="div_row3">
          <div class="row1_col2 ">
            <a href="" class="col1_a1">
              <div class="a_div1">
                <div class="mask"></div>
                <img src="@/assets/5.jpg" alt="" class="a1_img1">
              </div>
              <div class="a_div2">
                <div class="div2_title">
                  产品
                </div>
                <div class="div2_info">
                  HUAWEI MateBook X Pro
                </div>
                <div class="div2_info2">
                  入目惊鸿
                </div>
                <div class="div2_hidden">
                  了解更多
                </div>
              </div>
            </a>
          </div>
          <div class="row1_col2 col2_displacement">
            <a href="" class="col1_a1">
              <div class="a_div1">
                <div class="mask"></div>
                <img src="@/assets/6.jpg" alt="" class="a1_img1">
              </div>
              <div class="a_div2">
                <div class="div2_title">
                  产品
                </div>
                <div class="div2_info">
                  HUAWEI MateBook X Pro
                </div>
                <div class="div2_info2">
                  入目惊鸿
                </div>
                <div class="div2_hidden">
                  了解更多
                </div>
              </div>
            </a>
          </div>
          <div class="row1_col2 col2_displacement">
            <a href="" class="col1_a1">
              <div class="a_div1">
                <div class="mask"></div>
                <img src="@/assets/7.jpg" alt="" class="a1_img1">
              </div>
              <div class="a_div2">
                <div class="div2_title">
                  产品
                </div>
                <div class="div2_info">
                  HUAWEI MateBook X Pro
                </div>
                <div class="div2_info2">
                  入目惊鸿
                </div>
                <div class="div2_hidden">
                  了解更多
                </div>
              </div>
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import MySwiper from "@/components/MySwiper.vue"
export default {
  name: 'Home',
  components: { MySwiper },
  methods: {
    showDiv1() {
      var d1 = document.getElementById('div_main');
      d1.style.cssText = 'visibility: visible;'
    },
    hideDiv1() {
      var d1 = document.getElementById('div_main');
      d1.style.cssText = 'animation-name:example; animation-duration:0.1s;animation-fill-mode: forwards;';
    }
  }
}
</script>
<style>
@keyframes example {
  from {
    visibility: visible;

  }

  to {
    visibility: hidden;
  }
}

@font-face {
  font-family: 'YaHei';
  src: url('@/assets/font/微软雅黑繁简完全版.ttf');

}

@font-face {
  font-family: 'Huawei';
  src: url('@/assets/font/Helvetica\ Neue-Roman.ttf');

}
</style>
<style scoped>
* {
  font-family: Microsoft YaHei, Arial, Helvetica, sans-serif !important;
}

/* 顶部 */
.div_top {
  height: 25px;
  width: 100%;
  position: static;
  text-align: right;
  background-color: #111111;
}

.top_container {
  width: 300px;
  height: 25px;
  float: right;
  margin-right: 70px;
  display: flex;
  flex-direction: row;
  /* background-color: red; */
}

.container_div1 {
  width: 80px;
  height: 25px;
  /* background-color: aqua; */
  margin-right: 10px;
  line-height: 25px;
  font-size: 10px;
  text-align: center;
  color: #ffffff;
  cursor: pointer;
}

.container_div2 {
  width: 140px;
  height: 25px;
  /* background-color: aqua; */
  line-height: 25px;
  font-size: 10px;
  text-align: center;
  color: #ffffff;
  cursor: pointer;
}

.container_div3 {
  width: 60px;
  height: 25px;
  margin-left: 10px;
  /* background-color: aqua; */
  line-height: 25px;
  font-size: 10px;
  text-align: center;
  color: #ffffff;
  cursor: pointer;
}

/* ~顶部 */


/* 头部 */
.div_header {
  width: 100%;
  height: 78px;
  background-color: #fff;

  border-bottom: 1px solid #e6e6e6;
  display: flex;
}

.header_left {
  width: 266px;
  height: 100%;
  margin-left: 50px;


}

.header_logo {
  width: 133px;
  height: 30px;
  cursor: pointer;
}

.header_logo img {
  width: 133px;
  height: 30px;
  margin-top: 22px;
}

.header_info {
  width: 800px;
  height: 100%;
  margin-left: 140px;
  /* background-color: red; */
}


.info_div1 {
  width: 110px;
  height: 100%;
  font-size: 0.9em;
  float: left;
  line-height: 78px;
  text-align: center;
  cursor: pointer;

}

.info_div2 {
  width: 110px;
  height: 100%;
  font-size: 0.9em;
  line-height: 78px;
  float: left;
  text-align: center;
  margin-left: 30px;
  cursor: pointer;
}

.info_div3 {
  width: 58px;
  height: 100%;
  font-size: 0.9em;
  line-height: 78px;
  float: left;
  text-align: center;
  margin-left: 30px;
  cursor: pointer;
}

.info_div4 {
  width: 116px;
  height: 100%;
  font-size: 0.9em;
  line-height: 78px;
  float: left;
  text-align: center;
  margin-left: 30px;
  cursor: pointer;
}

.info_div5 {
  width: 58px;
  height: 100%;
  font-size: 0.9em;
  line-height: 78px;
  float: left;
  text-align: center;
  margin-left: 30px;
  cursor: pointer;
}

.info_div1:hover {

  border-bottom: 1px solid red;

}

.info_div2:hover {
  border-bottom: 1px solid red;
}

.info_div3:hover {
  border-bottom: 1px solid red;
}

.info_div4:hover {
  border-bottom: 1px solid red;
}

.info_div5:hover {
  border-bottom: 1px solid red;
}

.header_right {
  margin-left: 10px;
  width: 220px;
  /* background-color: aqua; */
}

.right_info {
  float: left;
  width: 120px;
  height: 100%;
  font-size: 17px;
  line-height: 78px;
  text-align: center;
  cursor: pointer;
  /* background-color: #111111; */
}

.right_logo {
  width: 80px;
  height: 100%;
  float: left;
  line-height: 78px;

}

.logo_span {
  content: "\e62f";
}

/* ~头部 */

/* 轮播图 */
.div_swiper {
  width: 100%;
  height: 512px;
  margin-bottom: 70px !important;
}

/* ~轮播图 */

/* 容器组件 */
.div_container {
  width: 85.652%;
  /* border: 1px solid; */
  margin: 0 auto;
  text-align: center;
}

.div_title {
  width: 100%;
  height: 100%;
  margin-bottom: 5%;
}

.title_h2 {
  width: 10%;
  height: 90%;
  padding-bottom: 8px;
  font-size: 30px;
  margin: 0 auto;
  position: relative;
}

.title_h2::after {

  position: absolute;
  content: '';
  height: 2px;
  width: 47%;
  top: 100%;
  left: 27%;
  background-color: #c7000b;

}

.container_imgs {
  height: auto;
  width: 100%;

}

.div_row1 {
  height: auto;
  width: 100%;
  display: flex;
  margin-bottom: 30px !important;

}

.div_row3 {
  height: auto;
  width: 100%;
  display: flex;
  margin-bottom: 30px !important;

}

.row1_col1 {
  width: 836.98px;
  height: auto;
  position: relative;
  margin-right: 30px;
}

.row1_col3 {
  width: 836.98px;
  height: auto;
  position: relative;
  margin-left: 30px;
}

.col1_a1 {
  width: 100%;
  height: auto;
 
}

.a1_img1 {
  width: 100%;
  height: 100%;

}

.a_div1 {
  width: 100%;
  height: 100%;
}

.mask {
  position: absolute;
  top: 30%;
  width: 100%;
  height: 70%;
  opacity: 1;
  background: linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 70%);
}

.row1_col2 {
  width: 403.24px;
  height: auto;
  position: relative;
}

.col2_displacement {
  margin-left: 30px;
}

.a_div2 {
  width: 400px;
  height: auto;
  bottom: 20px;
  position: absolute;
  left: 30px;
  text-align: left;

}
.div2_title{
  font-size: 1em;
  line-height: 1.0em;
  margin-bottom:10px;
  color: white;
}
.div2_info{
  font-size: 1.3em;
  line-height: 1.4em;
  font-weight: 600;
  margin-bottom:10px;
  color: white;
}
.div2_info2{
  font-size: 1em;
  line-height: 1.0em;
  margin-bottom: 20px;
  color: rgb(198, 199, 199);
}
.div2_hidden{
  color: white;
  color: 1.0em;
  height: 0;
  display: none;
  line-height: 0em;
  margin-bottom: 10px;

}
/* 容器组件 */
</style>

MySwiper.vue

<template>
    <div class="div_swiper">
        <div class="swiper" @mousemove="showSwiperButton()" @mouseout="hiddenSwiperButton()">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <img class="slide_img" src="@/assets/huawei-cloud-discount-pc.jpg" />
                    <button class="img_btn">了解更多</button>
                </div>
                <div class="swiper-slide">
                    <img class="slide_img" src="@/assets/vmall-mate50-series-3.jpg" />
                    <button class="img_btn">了解更多</button>
                </div>

            </div>
            <div class="swiper-button-prev" id="prev"></div>
            <!--左箭头。如果放置在swiper外面,需要自定义样式。-->
            <div class="swiper-button-next" id="next"></div>
            <!--右箭头。如果放置在swiper外面,需要自定义样式。-->
            <div class="swiper-pagination"></div>
            <!--分页器。如果放置在swiper外面,需要自定义样式。-->
        </div>
    </div>
</template>

<script>
import "swiper/swiper-bundle.min.css";  // 所有 Swiper 样式,包括所有模块样式(如导航、分页等)
import Swiper, { Navigation, Pagination, Scrollbar, Autoplay } from "swiper"; // 导入您需要的模块
export default {
    name: 'MySwiper',
    methods:
    {
        showSwiperButton() {
            let d1 = document.getElementById('prev');
            d1.style.cssText = "display:block;"
            let d2 = document.getElementById('next');
            d2.style.cssText = "display:block;"
        },
        hiddenSwiperButton() {
            let d1 = document.getElementById('prev');
            d1.style.cssText = "display:none;"
            let d2 = document.getElementById('next');
            d2.style.cssText = "display:none;"
        }
    },
    mounted() {
        new Swiper(".swiper", {
            speed: 500,//播放的速度
            // spaceBetween: 2000,// 轮播图之间的间距
            loop: true,//是否循环播放
            autoplay: {
                delay: 2000,//自动播放的间隔
            },
            modules: [Navigation, Pagination, Scrollbar, Autoplay],
            navigation: {
                nextEl: ".swiper-button-next",//前一个按钮
                prevEl: ".swiper-button-prev",//后一个按钮
            },
            scrollbar: {
                el: ".swiper-scrollbar",
                draggable: true,
            },
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
                bulletClass : 'my-bullet',//需设置.my-bullet样式
                bulletActiveClass: 'my-bullet-active',
            },
        });

    },

}
</script>

<style>
.div_swiper {
    width: 100%;
    height: 100%;
}

.swiper {
    height: 100%;
    width: 100%;
}

.swiper-wrapper {
    width: 100%;
    height: 100%;

}

.swiper-slide {
    width: 100%;
    height: 100%;
    margin-right: 0px;
    position: relative;
}

.slide_img {
    width: 100%;
}

.img_btn {
    z-index: 100;
    width: 170px;
    height: 42px;
    position: absolute;
    border: 1px solid #111111;
    left: 296px;
    top: 315px;
    color: #111111;
    cursor: pointer;
    /* background-color: red; */
}

.img_btn:hover {
    background-color: rgb(199, 0, 11);
    border: 0px;
    color: #fff;
}

.swiper-button-prev {

    display: none;
}

.swiper-button-next {

    display: none;
}
 
.my-bullet{
 
    width: var(--swiper-pagination-bullet-width,var(--swiper-pagination-bullet-size,100px));
    height: var(--swiper-pagination-bullet-height,var(--swiper-pagination-bullet-size,3px));
    display: inline-block;
    background: var(--swiper-pagination-bullet-inactive-color,#000);
    opacity: var(--swiper-pagination-bullet-inactive-opacity, .2);
    margin: 0 7px;
    cursor: pointer;
    border: 0;
}

.my-bullet-active{
    background: #ffffff;
    opacity: 1;
}
</style>

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

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

相关文章

【C++AVL树】4种旋转详讲

目录 引子&#xff1a;AVL树是因为什么出现的&#xff1f; 1.AVl树的的特性 2.AVl树的框架 3.AVL树的插入 3.1四种旋转&#xff08;左单旋、右单旋、左右双旋、右左双旋&#xff09; 3.1.1左单旋 3.1.2右单旋 3.1.3左右双旋 3.1.4右左双旋 总结 引子&#xff1a;AVL树是因…

【单片机】单片机的核心思想

&#x1f4ac;推荐一款模拟面试、刷题神器 、从基础到大厂面试题&#xff1a;&#x1f449;点击跳转刷题网站进行注册学习 目录 一、单片机的核心思想 二、单片机核心图 三、上拉电路及应用 排阻的优势 四、单片机的输入输出模式 1、接收外部电压信号 2、向外输出电压信…

0089 时间复杂度,冒泡排序

/* * 排序也称排序算法&#xff08;Sort Algorithm&#xff09; * 排序是将一组数据&#xff0c;依指定的顺序进行排列的过程。 * * 排序分类 * 1.内部排序&#xff1a;将需要处理的所有数据都加载到内存存储器中进行排序&#xff08;使用内存&#xff09; * 插…

彻底搞懂WeakMap和Map

一 、Map Map是一种叫做字典的数据结构&#xff0c;Map 对象保存不重复键值对&#xff0c;并且能够记住键的原始插入顺序 Map的属性和方法* 属性&#xff1a; size&#xff1a; 返回所包含的键值对长度* 操作方法&#xff1a;* set(key,val): 添加新键值对* get(key): 通过传…

Linux--信号signal、父子进程、SIGCHLD信号相关命令

目录 1.概念&#xff1a; 2.信号的存储位置&#xff1a; 3.常见的信号的值以及对应的功能说明&#xff1a; 4.信号的值在系统源码中的定义&#xff1a; 5.响应方式&#xff1a; 6.改变信号的相应方式&#xff1a; (1)设置信号的响应方式: (2)默认:SIG_DFL;忽略:SIG_IGN…

Android Studio 新版本 Logcat 的使用

前言 最近&#xff0c;Android Studio 自动更新了自带的 Logcat 工具&#xff0c;整体外观和使用方法变得和之前完全不同了。一开始我以为是自己按到什么不该按的按钮&#xff0c;把 Logcat 弄坏了&#xff0c;后来才知道是版本更新导致的。新版本的 Logcat 用命令来过滤信息&…

jmeter变量函数以及抓包用法

抓包 代理服务器&#xff1a; 自己启动一个代理服务器 本地&#xff0c;要使用代理服务器的ip和端口&#xff0c;使用自己启动的代理服务器 操作步骤 添加线程组测试计划 > 非测试元件 > http代理服务器一定要修改 修改为** 测试计划>线程 ip就是你自己电脑的ip&…

Activity

Activity生命周期图 官网的 Activity 的生命周期图&#xff1a; 在官方文档中给出了说明&#xff0c;不允许在 onPause() 方法中执行耗时操作&#xff0c;因为这会影响到新 Activity 的启动。 常见情况下Activity生命周期的回调 &#xff08;A 与 B 表示不同的 Activity &a…

(硬件设计)老工程师的经验之道

系列文章目录 1.元件基础 2.电路设计 3.PCB设计 4.元件焊接 5.板子调试 6.程序设计 7.算法学习 8.编写exe 9.检测标准 10.项目举例 11.职业规划 文章目录前言1、用蜡烛油固定电位器2、电路板接插件用彩色接插件前言 送给大学毕业后找不到奋斗方向的你&#xff08;每周不定时…

Python----科学计数法、同时给多个变量赋值、eval函数、math库函数、复数(complex())、内置的数值运算函数、内置的数值运算操作符

科学计数法使用字母"e"或者“E”作为幂的符号&#xff0c;以10为基数&#xff0c;科学计数法的含义如下&#xff1a; 96e4&#xff1a;96乘10的4次幂 4.3e-3&#xff1a;4.3乘10的负三次幂 aeb&#xff1a;a*10*b 同时给多个变量赋值格式: 变量1&#xff0c;变量2表…

基于Python的电影推荐系统

电影推荐系统 目录 电影推荐系统 1 数据描述 1变量说明 1程序介绍 2 本次课程作业在 small-movielens 数据集的基础上&#xff0c;对用户、电影、评分数据进行了处理&#xff0c;然后根据 Pearson 相关系数计算出用户与其他用户之间的相似度&#xff0c;根据相似度进行推荐和…

用Python来表白,把情书写进她的照片里

前言 这不已经十一月了&#xff0c;22年马上就过完了&#xff0c;各位兄弟有对象了吗&#xff0c;现在就是缺钱还缺对象 退一步来说&#xff0c;有心仪的人吗啊&#xff0c;如果有的话&#xff0c;看看这篇 程序员的表白小妙招吧 实现步骤 想要实现把情书写在像素中&#xf…

【Web-HTML基础】颜色赋值、背景图片、文本和字体相关样式、元素的显示方式display、盒子模型、部分标签自带外边距或内边距

目录 颜色赋值 背景图片 文本和字体相关样式 元素的显示方式display 盒子模型 盒子模型之content内容 盒子模型之margin外边距 盒子模型之border边框 盒子模型之padding内边距 部分标签自带外边距或内边距 综合代码实现 颜色赋值 三原色: 红绿蓝 RGB RedGreenBlue …

【2022秋招面经】——深度学习

文章目录请写出常用的损失函数&#xff0c;平方损失、交叉熵损失、softmax损失函数和hinge1. 0-1 损失函数2. 绝对值损失函数3. 平方损失函数4. log 对数损失函数5. 指数损失函数&#xff08;exponential loss&#xff09;6. Hinge 损失函数7. 感知损失(preceptron loss)函数8.…

网课查题接口系统使用教程

网课查题接口系统使用教程 本平台优点&#xff1a;免费查题接口搭建 多题库查题、独立后台、响应速度快、全网平台可查、功能最全&#xff01; 1.想要给自己的公众号获得查题接口&#xff0c;只需要两步&#xff01; 2.题库&#xff1a;题库后台http://daili.jueguangzhe.cn/…

使用微服务实现多设备自动调度

在实现app自动化过程中&#xff0c;有时候我们需要将多个手机中的任务&#xff0c;按照某种规则进行调度&#xff0c;这时仅仅使用移动端的脚本就无法完成了&#xff0c;需要配合使用微服务来完成。下面就举个例子来实际说明如何使用。 需求 假设我们有100台手机做任务&#…

计算机毕业设计(附源码)python疫情下的学生出入管理系统

项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等等。 环境需要 1.运行环境&#xff1a;最好是python3.7.7&#xff0c;…

云IDE产品介绍

前言 CSDN开发云官网发布了最新产品【云IDE】产品&#xff01;【云IDE】将提供一键秒级构建云开发环境&#xff0c;是专为开发者打造的一款低代码开发产品&#xff0c;云端预制了常见的开发环境&#xff0c;无需下载安装&#xff0c;一键创建项目&#xff0c;灵活配置代码仓和云…

【数据库05】玩转SQL的高阶特性

前 言 &#x1f349; 作者简介&#xff1a;半旧518&#xff0c;长跑型选手&#xff0c;立志坚持写10年博客&#xff0c;专注于java后端 ☕专栏简介&#xff1a;相当硬核&#xff0c;黑皮书《数据库系统概念》读书笔记&#xff0c;讲解&#xff1a; 1.数据库系统的基本概念(数据…

22.10.31补卡 22CCPC桂林C题

Problem - C - Codeforces 这题题解是请教了学长之后才做出来的, 若是想看题解请看http://t.csdn.cn/unAyg 本篇文章只作为做题记录 写了一天半...感觉自己是不太适合写区域赛的题了, 还是多学学算法和数论好了 ---------------------------------------------------------…