• 當前位置:首頁 > IT技術 > 移動平臺 > 正文

    直播app開發,首頁輪播圖效果實現
    2021-10-28 15:12:14

    直播app開發,首頁輪播圖效果實現的相關代碼

    ?

    npm install react-slick --save
    npm install slick-carousel

    ?

    安裝完后需要在使用輪播圖的頁面上導入css文件:

    ?

    ?

    import Slider from 'react-slick';
    import 'slick-carousel/slick/slick.css';
    import 'slick-carousel/slick/slick-theme.css';

    ?

    swiper.js

    ?

    ?

    import React, { Component } from 'react';
    import Slider from 'react-slick';
    import 'slick-carousel/slick/slick.css';
    import 'slick-carousel/slick/slick-theme.css';
    ?
    export default class SimpleSlider extends Component {
    ? ? render() {
    ? ? ? ? const settings = {
    ? ? ? ? ? ? dots: true,
    ? ? ? ? ? ? dotsClass:'slick-dots1',//自定義指示器的樣式
    ? ? ? ? ? ? // dots: {'dot-style':String},
    ? ? ? ? ? ? infinite: true,
    ? ? ? ? ? ? speed: 500,
    ? ? ? ? ? ? slidesToShow: 1,
    ? ? ? ? ? ? slidesToScroll: 1,
    ? ? ? ? ? ? height:500
    ? ? ? ? };
    ? ? ? ? return (
    ? ? ? ? ? ? <div style={{margin:'50px 12px 40px 12px'}}>
    ? ? ? ? ? ? ? ? <h2> Single Item</h2>
    ? ? ? ? ? ? ? ? <Slider {...settings}>
    ? ? ? ? ? ? ? ? ? ? <div>
    ? ? ? ? ? ? ? ? ? ? ? ? <h3>1</h3>
    ? ? ? ? ? ? ? ? ? ? ? ? <div style={{background:'#25f5f5',height:'160px'}}>sdfkjsdlfjldskfjlksjdf</div>
    ? ? ? ? ? ? ? ? ? ? </div>
    ? ? ? ? ? ? ? ? ? ? <div>
    ? ? ? ? ? ? ? ? ? ? ? ? <h3>2</h3>
    ? ? ? ? ? ? ? ? ? ? </div>
    ? ? ? ? ? ? ? ? ? ? <div>
    ? ? ? ? ? ? ? ? ? ? ? ? <h3>3</h3>
    ? ? ? ? ? ? ? ? ? ? </div>
    ? ? ? ? ? ? ? ? ? ? <div>
    ? ? ? ? ? ? ? ? ? ? ? ? <h3>4</h3>
    ? ? ? ? ? ? ? ? ? ? </div>
    ? ? ? ? ? ? ? ? ? ? <div>
    ? ? ? ? ? ? ? ? ? ? ? ? <h3>5</h3>
    ? ? ? ? ? ? ? ? ? ? </div>
    ? ? ? ? ? ? ? ? ? ? <div>
    ? ? ? ? ? ? ? ? ? ? ? ? <h3>6</h3>
    ? ? ? ? ? ? ? ? ? ? </div>
    ? ? ? ? ? ? ? ? </Slider>
    ? ? ? ? ? ? </div>
    ? ? ? ? );
    ? ? }
    }

    ?

    swiper.css

    ?

    ?

    //輪播圖下方dot樣式
    .slick-dots1
    {
    ? position: absolute;
    ? bottom: -25px;
    ? display: block;
    ? width: 100%;
    ? padding: 0;
    ? margin: 0;
    ? list-style: none;
    ? text-align: center;
    }
    .slick-dots1 li
    {
    ? position: relative;
    ? display: inline-block;
    ? width: 20px;
    ? height: 20px;
    ? margin: 0 5px;
    ? padding: 0;
    ? cursor: pointer;
    }
    .slick-dots1 li button
    {
    ? font-size: 0;
    ? line-height: 0;
    ? display: block;
    ? width: 20px;
    ? height: 20px;
    ? padding: 5px;
    ? cursor: pointer;
    ? color: transparent;
    ? border: 0;
    ? outline: none;
    ? background: transparent;
    }
    .slick-dots1 li button:hover,
    .slick-dots1 li button:focus
    {
    ? outline: none;
    }
    .slick-dots1 li button:hover:before,
    .slick-dots1 li button:focus:before
    {
    ? opacity: 1;
    }
    //未選中時的樣式
    .slick-dots1 li button:before
    {
    ? font-family: 'slick';
    ? font-size: 8px;
    ? line-height: 8px;
    ? position: absolute;
    ? top: 0;
    ? left: 0;
    ? width: 20px;
    ? height: 8px;
    ? content: '?';
    ? text-align: center;
    ? //opacity: .25;
    ? color: #CCCCCC;
    ? -webkit-font-smoothing: antialiased;
    ? -moz-osx-font-smoothing: grayscale;
    }
    //選中的樣式
    .slick-dots1 li.slick-active button:before
    {
    ? //opacity: .75;
    ? color: #2183E2;
    ?
    ? border-radius: 5px;
    }?

    ?

    以上就是 直播app開發,首頁輪播圖效果實現的相關代碼,更多內容歡迎關注之后的文章

    ?

    本文摘自 :https://www.cnblogs.com/

    開通會員,享受整站包年服務
    国产呦精品一区二区三区网站|久久www免费人咸|精品无码人妻一区二区|久99久热只有精品国产15|中文字幕亚洲无线码