前端学习之:Vue + ElementUI 通过栅格布局排放多个走马灯,并在走马灯上同步显示文字

走马灯

  • 让走马灯组件播放图片的时候顺便播放文字
  • 多个走马灯按照栅格布局进行排放

效果展示

在这里插入图片描述

template

<!-- 首先设定一个 row -->
<el-row>
	<!-- 第一个最宽的走马灯单独占一列 el-col -->
   <el-col span="16" offset="0">
       <el-carousel indicator-position="outside" height="800px">
       		<!-- 为了让走马灯在轮播图片的同时能够在上面附带文字,将走马灯组件单独放在一个 div 里
       		并且为这个 div 单独设计 css 样式 pic_item -->
           <div class="pic_item">
               <el-carousel-item v-for="(item, index) in urls" :key="index">
               <img :src="item.url" style="width:100%; height:100%">
               <h3>Welcome to the Centre of Research Excellence in Newborn Medicine</h3>
               </el-carousel-item>
           </div>
   		</el-carousel>
   </el-col>
   
    <!-- 接着把两个小的走马灯放在一个 col 中-->
   <el-col span="8">
       <el-carousel indicator-position="inside" height="400px">
       		<!-- 每个小走马灯也要同步显示文字,因此也要放到 div 里面 -->
           <div class="smallpic_item">
               <el-carousel-item v-for="(item, index) in urls" :key="index">
               <img :src="item.url" style="width:100%; height:100%">
               <h3>Our team of talented researchers are dedicated to 
                       making discoveries to prevent and treat childhood conditions</h3>
               </el-carousel-item>
           </div>
       </el-carousel>

       <el-carousel indicator-position="outside" height="400px">
           <div class="smallpic_item">
               <el-carousel-item v-for="(item, index) in urls" :key="index">
               <img :src="item.url" style="width:100%; height:100%">
               <h3>We are a team of world renowned clinicians, researchers and students</h3>
               </el-carousel-item>
           </div>
       </el-carousel>
   </el-col>
</el-row>

script

export default {
      data() {
        return {
          urls:[
            {url:require('../assets/banner1.jpg')},
            {url:require('../assets/banner2.png')},
            {url:require('../assets/banner3.png')}
            ]
        };
    },
}

style

.pic_item {
	position: relative;
	height: 100%;
}
.pic_item:hover{
  cursor: pointer;
}

// pic_item 这个整体 div 样式的时候,其中的 h3 的标签的样式
// 也就是显示在走马灯上的字体

.pic_item h3 {
  /* position: relative; */
  /* width: 864px;
  height: 168px; */
    position: absolute;
    left: 5rem;
    bottom: 10rem;
    font-size: 50px;
    color: white;
    /* text-decoration-line: underline; */
    font-weight: 900;
    font-family:Georgia, 'Times New Roman', Times, serif;
    font-size: 48px;
    line-height: 116%;
    display: flex;
    align-items: center;
    flex: none;
    order: 1;
    align-self: stretch;
}


.smallpic_item h3{
    position: absolute;
    left: 3rem;
    bottom: 5rem;
    font-family:Georgia, 'Times New Roman', Times, serif;
    font-style: normal;
    font-weight: 700;
    font-size: 24px;
    line-height: 132%;
    display: flex;
    align-items: center;
    letter-spacing: 0.02em;
    font-feature-settings: 'liga' off;

    /* White */

    color: #FFFFFF;
}

参考网页

https://blog.csdn.net/weixin_48931875/article/details/111058475

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

暖仔会飞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值