国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

(Carousel)解決:Element-ui 中 Carousel 走馬燈的樣式的修改問題

這篇具有很好參考價值的文章主要介紹了(Carousel)解決:Element-ui 中 Carousel 走馬燈的樣式的修改問題。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

Ⅰ、Element-ui 提供的組件與想要目標(biāo)情況的對比:

1、Element-ui 提供組件情況:

其一、Element-ui 自提供的代碼情況為(示例的代碼,例子如下):
el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

// Element-ui 自提供的代碼:
<template>
  <el-carousel :interval="5000" arrow="always">
    <el-carousel-item v-for="item in 4" :key="item">
      <h3>{{ item }}</h3>
    </el-carousel-item>
  </el-carousel>
</template>

<style>
  .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
  }
  
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
</style>

代碼地址:https://element.eleme.cn/#/zh-CN/component/carousel

其二、頁面的顯示情況為:

el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

Ⅱ、實現(xiàn) Carousel 走馬燈樣式變化的過程:

1、 Carousel 自提供的代碼的實踐:

其一、代碼為:

<template>
    <div>
        <div style="font-weight:bolder; font-size:20px">走馬燈的使用:</div>
        <div>
            <div style="margin:20px 0;">方法一:原本樣式</div>
            <div class="block" style="width:50%;">
                <el-carousel :interval="5000" arrow="always">
                    <el-carousel-item v-for="item in arrayList" :key="item">
                    <h3>{{ item }}</h3>
                    </el-carousel-item>
                </el-carousel>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            arrayList:['王二','張三','李四','麻五']
        }
    }
}
</script>

<style lang="scss" scoped>
.block {
  .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 100px;
    margin: 0;
  }
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  // 此時是:設(shè)置 carousel 走馬燈的高度為:100px;
  /deep/.el-carousel__container {  
    height: 100px;
  }
}
</style>

其二、頁面展示為:

el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

2、 Carousel 代碼相關(guān)屬性的使用:

其一、indicator-position(指示器) 屬性的使用:

A、代碼:

indicator-position="none"     //此時的指示器就不顯示了;

indicator-position="outside"  //表示指示器在外面顯示;
// 而默認(rèn)不設(shè)置的指示器是在里面的;

B、狀態(tài)顯示:

//顯示器不顯示的情況:
el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

//顯示器在內(nèi)部的情況:
el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

//顯示器在外部的情況:
el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

其二、arrow(箭頭) 屬性的使用:

A、代碼:

arrow="always"     //此時是:箭頭一直顯示;

arrow="never"     //此時是:箭頭不再顯示;

// 默認(rèn)是 hover 時箭頭才顯示(即:不設(shè)置 arrow 屬性時)

B、狀態(tài)顯示:

//箭頭一直顯示的情況:

el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

//箭頭不顯示的情況:
el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

//箭頭 hover 時顯示的情況(即:此時僅 hover 時才顯示箭頭):

el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

其三、direction(方向) 屬性的使用:

A、代碼:

direction="vertical"  //此時表示:讓走馬燈在垂直方向上顯示;

 //而默認(rèn)是:走馬燈在水平方向上顯示;

B、狀態(tài)顯示:

// 走馬燈在水平方向上顯示為:

el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

// 走馬燈在垂直方向上顯示為:

el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

其四、autoplay(是否自動播放) 屬性的使用:

:autoplay="false"   //此時表示是:非自動播放;

//而默認(rèn)是:自動播放;

3、 Carousel 代碼相關(guān)樣式修改的過程:

其一、走馬燈高度設(shè)置:

  /deep/.el-carousel__container {
      height: 60px;  
    }

其二、設(shè)置 item 背景色:

/deep/.el-carousel {
    .el-carousel__item {
      background-color: #ccc;  //設(shè)置每一個 item 待切換頁面的背景色;
      margin-top: 0px;
    }
  }

其三、調(diào)整箭頭大?。?/strong>

 /deep/.el-carousel__arrow{
    font-size: 20px;
  }

其四、調(diào)整箭頭的位置:

/deep/.el-carousel__arrow--left,
  /deep/.el-carousel__arrow--right{
    background-color: transparent !important; // 此時是將其外面的圓框變成透明(即:徹底消失);
    position: relative;
    top: 7px;
  }
  /deep/.el-carousel__arrow--left {
      left: 20px;
  }
  /deep/.el-carousel__arrow--right {
      left: 80px;
  }

3、 Carousel 代碼相關(guān)樣式修改的整體代碼為:

其一、代碼為:

<template>
    <div>
        <div>
            <div style="margin:20px 0;">方式二:修改后的樣式</div><!-- 可以通過該 div 調(diào)整走馬燈的位置; -->
            <div class="project" style="width:80%;margin-top:20px;"><!-- 通過外層的 project 類來調(diào)整走馬燈的位置; -->
                <el-carousel :interval="5000" arrow="none" indicator-position="none" style="margin-top:20px;">
                  <!-- 也可以通過 el-carousel 的設(shè)置 style 屬性來調(diào)整走馬燈的位置; -->
                    <el-carousel-item v-for="item in arrayList" :key="item">
                    <h3>{{ item }}</h3>
                    </el-carousel-item>
                </el-carousel>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            arrayList:['王二','張三','李四','麻五']
        }
    }
}
</script>

<style lang="scss" scoped>
.project {
  //下面代碼:此時是調(diào)整 arrayList 值的大小和位置;
  .el-carousel__item h3 {
    line-height: 60px;   //此時是調(diào)整 arrayList 的值上下位置;
    text-align: center;  //此時是使 arrayList 的值居中;
    font-size: 18px;
    opacity: 0.75;
  }

  //下面代碼:此時是調(diào)整走馬燈的高度,但設(shè)置不了盒子上面的距離(暫時沒找到合適的 css 位置);
  /deep/.el-carousel__container {
      height: 60px;  
    }

  /deep/.el-carousel {
    .el-carousel__item {
      background-color: #ccc;  //設(shè)置每一個 item 待切換頁面的背景色;
      margin-top: 0px;
    }
  }

  //下面代碼:此時是調(diào)整箭頭的大小;
  /deep/.el-carousel__arrow{
    font-size: 20px;
  }

  //下面代碼:此時是調(diào)整箭頭的位置; 
  /deep/.el-carousel__arrow--left,
  /deep/.el-carousel__arrow--right{
    background-color: transparent !important; // 此時是將其外面的圓框變成透明(即:徹底消失);
    position: relative;
    top: 7px;
  }
  /deep/.el-carousel__arrow--left {
    left: 20px;
  }
  /deep/.el-carousel__arrow--right {
    left: 80px;
  }
}
</style>

其二、頁面顯示為:

el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

Ⅲ、實現(xiàn) Carousel 走馬燈樣式的整體代碼與顯示結(jié)果:

1、整體代碼為:

<template>
    <div>
        <div style="font-weight:bolder; font-size:20px">走馬燈的使用:</div>
        <div>
            <div style="margin:20px 0;">方法一:原本樣式</div>
            <div class="block" style="width:50%;">
                <el-carousel :interval="5000" arrow="always">
                    <el-carousel-item v-for="item in arrayList" :key="item">
                    <h3>{{ item }}</h3>
                    </el-carousel-item>
                </el-carousel>
            </div>
        </div>
        <div>
            <div style="margin:20px 0;">方式二:修改后的樣式</div><!-- 可以通過該 div 調(diào)整走馬燈的位置; -->
            <div class="project" style="width:80%;margin-top:20px;"><!-- 通過外層的 project 類來調(diào)整走馬燈的位置; -->
                <el-carousel :interval="5000" arrow="none" indicator-position="none" style="margin-top:20px;">
                  <!-- 也可以通過 el-carousel 的設(shè)置 style 屬性來調(diào)整走馬燈的位置; -->
                    <el-carousel-item v-for="item in arrayList" :key="item">
                    <h3>{{ item }}</h3>
                    </el-carousel-item>
                </el-carousel>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            arrayList:['王二','張三','李四','麻五']
        }
    }
}
</script>

<style lang="scss" scoped>
.block {
  .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 100px;
    margin: 0;
  }
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  /deep/.el-carousel__container {
    height: 100px;
  }
}
.project {
  //備用代碼: 可能需要的 hover 狀態(tài);
  // &:hover {
    // /deep/.el-carousel__arrow--left,
    // /deep/.el-carousel__arrow--right{
    //     background-color: transparent !important;
    //     position: relative;
    //     top: 7px;
    // }
    // /deep/.el-carousel__arrow--left {
    //   left: -67px;
    // }
    // /deep/.el-carousel__arrow--right {
    //   right: -67px;
    // }
  // }

  //下面代碼:此時是調(diào)整 arrayList 值的大小和位置;
  .el-carousel__item h3 {
    line-height: 60px;   //此時是調(diào)整 arrayList 的值上下位置;
    text-align: center;  //此時是使 arrayList 的值居中;
    font-size: 18px;
    opacity: 0.75;
  }

  //下面代碼:此時是調(diào)整走馬燈的高度,但設(shè)置不了盒子上面的距離(暫時沒找到合適的 css 位置);
  /deep/.el-carousel__container {
      height: 60px;  
    }

  /deep/.el-carousel {
    .el-carousel__item {
      background-color: #ccc;  //設(shè)置每一個 item 待切換頁面的背景色;
      margin-top: 0px;
    }
  }

  //下面代碼:此時是調(diào)整箭頭的大小;
  /deep/.el-carousel__arrow{
    font-size: 20px;
  }

  //下面代碼:此時是調(diào)整箭頭的位置; 
  /deep/.el-carousel__arrow--left,
  /deep/.el-carousel__arrow--right{
    background-color: transparent !important; // 此時是將其外面的圓框變成透明(即:徹底消失);
    position: relative;
    top: 7px;
  }
  /deep/.el-carousel__arrow--left {
    left: 20px;
  }
  /deep/.el-carousel__arrow--right {
    left: 80px;
  }
}

</style>

2、顯示結(jié)果為:

el-carousel,# Element-ui 專欄,vue.js,element-ui,經(jīng)驗分享,carousel,樣式修改

Ⅳ、小結(jié):

其一、哪里有不對或不合適的地方,還請大佬們多多指點和交流!
其二、有興趣的話,可以多多關(guān)注這個專欄(Vue(Vue2+Vue3)面試必備專欄):https://blog.csdn.net/weixin_43405300/category_11525646.html?spm=1001.2014.3001.5482文章來源地址http://www.zghlxwxcb.cn/news/detail-822374.html

到了這里,關(guān)于(Carousel)解決:Element-ui 中 Carousel 走馬燈的樣式的修改問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 自定義element-ui走馬燈(輪播)樣式

    自定義element-ui走馬燈(輪播)樣式

    自定義el-carousel-item指示器樣式 把指示器變成圓點 效果圖: ?

    2024年02月13日
    瀏覽(30)
  • Element UI 走馬燈的使用

    Element UI 走馬燈的使用

    目錄 走馬燈是什么 原生js實現(xiàn) Element UI的走馬燈使用 el-carousel Carousel Events el-carousel-item 在有限空間內(nèi),循環(huán)播放同一類型的圖片、文字等內(nèi)容,走馬燈也叫輪播圖。 比如 ? JS實現(xiàn)輪播圖效果(同時播放音頻)_trigger333的博客-CSDN博客 Element - The world\\\'s most popular Vue UI framework 代

    2024年02月02日
    瀏覽(28)
  • ElementUI淺嘗輒止14:Carousel 走馬燈

    在有限空間內(nèi),循環(huán)播放同一類型的圖片、文字等內(nèi)容 結(jié)合使用 el-carousel 和 el-carousel-item 標(biāo)簽就得到了一個走馬燈。幻燈片的內(nèi)容是任意的,需要放在 el-carousel-item 標(biāo)簽中。默認(rèn)情況下,在鼠標(biāo) hover 時底部的指示器時就會觸發(fā)切換。通過設(shè)置 trigger 屬性為 click ,可以達(dá)到點

    2024年02月10日
    瀏覽(28)
  • 制作輪播圖經(jīng)驗分享——element ui走馬燈的使用(附源碼,效果截圖)

    制作輪播圖經(jīng)驗分享——element ui走馬燈的使用(附源碼,效果截圖)

    先附上效果圖: ??element ui鏈接地址:Carousel 走馬燈 | Element Plus (gitee.io) 源碼: 這里我使用的是靜態(tài)圖片(本地) 經(jīng)驗分享: 在制作輪播圖的時候經(jīng)常會發(fā)現(xiàn)圖片大小不一,這時候可以在img標(biāo)簽里加上width:100%;height:100%即可實現(xiàn)圖片鋪滿。 當(dāng)然,這只是輪播圖的一種,還

    2024年02月11日
    瀏覽(25)
  • element-plus走馬燈不顯示

    element-plus走馬燈不顯示

    依賴正確,代碼用法正確,但是element-plu走馬燈就是不顯示?。?并且盒子的寬度總是0 在現(xiàn)有的布局中插入官方的案例,也不能顯示 但是把整個頁面都使用官方案例就可以正常顯示 所以,懷疑時自己的樣式?jīng)_突了 就content一個盒子,看到 display: flex; 就知道不對勁,去掉flex布

    2024年02月07日
    瀏覽(20)
  • 實現(xiàn)NoticeBar 通知欄。走馬燈公告欄

    微信小程序封裝公共組件——實現(xiàn)NoticeBar 通知欄。走馬燈公告欄 代碼如下(示例): index.wxml代碼如下(示例): index.ts 公告通知欄父組件傳notice數(shù)組,組件設(shè)置了timer可以多條進(jìn)行輪播

    2024年02月10日
    瀏覽(60)
  • 用 React+ts 實現(xiàn)無縫滾動的走馬燈

    用 React+ts 實現(xiàn)無縫滾動的走馬燈

    走馬燈是一種常見的網(wǎng)頁交互組件,可以展示多張圖片或者內(nèi)容,通過自動播放或者手動切換的方式,讓用戶能夠方便地瀏覽多張圖片或者內(nèi)容。 本次實現(xiàn)的不是輪播圖而是像傳送帶一樣的無限滾動的形式。 走馬燈可設(shè)置一下屬性: 滾動速度 滾動方向 一屏要顯示項的個數(shù)

    2024年02月13日
    瀏覽(24)
  • Proteus仿真--基于51單片機的走馬燈實現(xiàn)(仿真文件+程序)

    Proteus仿真--基于51單片機的走馬燈實現(xiàn)(仿真文件+程序)

    本文主要介紹基于51單片機的走馬燈仿真(完整仿真源文件及代碼見文末鏈接) 本設(shè)計中有16個LED燈用于流水走馬演示,一位數(shù)碼管用于顯示當(dāng)前模式狀態(tài),3個按鍵分別用于選擇模式及加減速度控制 仿真圖如下 其中 K1:用于模式切換選擇,有多種模式可切換 K2:加速流水/走

    2024年02月06日
    瀏覽(69)
  • transition 實現(xiàn)div伸縮動畫、3D翻轉(zhuǎn)動畫(vue版)、elementui走馬燈

    transition 實現(xiàn)div伸縮動畫、3D翻轉(zhuǎn)動畫(vue版)、elementui走馬燈

    代碼 ? template ?? ?div ?? ??? ?div ?? ??? ??? ? ?el-carousel :interval=\\\"4000\\\" type=\\\"card\\\" height=\\\"500px\\\" ?? ??? ??? ? ? ? ?el-carousel-item v-for=\\\"(i,index) in imageData\\\" :key=\\\"index\\\" ?? ??? ??? ? ? ? ? ?img :src=\\\"i.src\\\" style=\\\"width: 100%;height: 100%;\\\" ?? ??? ??? ? ? ? ?/el-carousel-item ?? ???

    2024年02月02日
    瀏覽(29)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包