React-Hook 轮子公开课(从零开始)用最基础的方式写出一个简单的组件库——第三课【Row、Col】布局组件

一、组件库介绍

有兴趣的同学 可以先着手看源码,之前写的一系列开源组件库项目(有帮助的同学也帮忙点个star👍)

名称官网github
tinkerbell-ui(vue2.0)http://tinkerbell.tophttps://github.com/hanbingxu82/tinkerbell-ui
tinkerbell-ui(vue3.0)https://github.com/hanbingxu82/tinkerbell-ui-next
tinkerbell-ui(react-hook)https://github.com/hanbingxu82/tinkerbell-ui-react

二、Row、Col组件流程介绍

想到布局组件,其实我们最先想到的也就是栅栏,最早接触前端的时候、或者最早接触ui组件的时候,我们首先是不是就先想起来了 Bootstrap 里面的栅栏呢?其实功能类似,底层的话采用的是什么功能呢?也就是@media媒体查询,利用的其实也就是浏览器的分辨率监听,实现了对应的class样式变更,从而达到了一个分割布局的这么一个效果,主要也是捋清我们怎样去写这个代码:

1、我们肯定是要把Row、Col当成两个正常普通的组件,可以在上面设置通用的事件,设置style、class、id属性等

2、那么话说回来 Row 是行、 Col 是列,如何对这两个组件进行组件传值,肯定是父组件 Row 包裹子组件 Col ,那如何使用 Row 的属性实现对 Col,组件的控制也同样是一个问题?

3、我们应该传递什么属性给 Row 组件,传递什么属性给 Col 组件?

Row:
justify: string // 水平排列方式
align: string // 垂直排列方式
gutter: number // 栅格间隔

Col:
span: number | string // 栅格占据的列数
push: number | string // 栅格向右移动格数
offset: number | string // 栅格左侧的间隔格数
pull: number | string // 栅格向左移动格数
xs: number | object // <768px 响应式栅格数或者栅格属性对象
sm: number | object // ≥768px 响应式栅格数或者栅格属性对象
md: number | object // ≥992 响应式栅格数或者栅格属性对象
lg: number | object // ≥1200 响应式栅格数或者栅格属性对象
xl: number | object // ≥1920px 响应式栅格数或者栅格属性对象

三、代码详解

3.1、Row.tsx


import React, { useEffect, useState,  } from 'react'
import './index.scss'
interface Iprops {
  justify: string // 水平排列方式
  align: string // 垂直排列方式
  gutter: number // 栅格间隔
}
// export const Context = createContext<any>(null)
function Row(props: any) {
  const [tbalign, setTbalign] = useState({})
  const [tbjustify, setTbjustify] = useState({})
  const { justify, align }: Iprops = props

  useEffect(() => {
    pjustify()
    palign()
  }, [])
  // 判断
  function pjustify() {
    if (justify == 'start') {
      setTbjustify({
        justifyContent: 'flex-start'
      })
    } else if (justify == 'center') {
      setTbjustify({
        justifyContent: 'center'
      })
    } else if (justify == 'end') {
      setTbjustify({
        justifyContent: 'flex-end'
      })
    } else if (justify == 'space-around') {
      setTbjustify({
        justifyContent: 'space-around'
      })
    } else if (justify == 'space-between') {
      setTbjustify({
        justifyContent: 'space-between'
      })
    } else {
      setTbjustify({})
    }
  }
  // 判断布局
  function palign() {
    if (align == 'top') {
      setTbalign({
        alignItems: 'flex-start'
      })
    } else if (align == 'middle') {
      setTbalign({
        alignItems: 'crenter'
      })
    } else if (align == 'bottom') {
      setTbalign({
        alignItems: 'flex-end'
      })
    } else {
      setTbalign({})
    }
  }
  return (
    <div className='tb-row' style={{ ...tbalign, ...tbjustify }}>
      {/* <Context.Provider value={{ ...{ ...props } }}> */}
        {React.Children.map(props.children, (item) => {
          return React.cloneElement(item, {
            item,
            parent: {
              props
            }
          })
        })}
      {/* </Context.Provider> */}
    </div>
  )
}
export default Row

3.2、Row / index.scss

.tb-row {
  min-height: 36px;
  display: flex;
  flex-wrap: wrap;
}

3.3、Col.tsx


import React, { useState, useEffect } from 'react'
// import { Context } from '../Row/index'
import './index.scss'
interface Iprops {
  span: number | string // 栅格占据的列数
  push: number | string // 栅格向右移动格数
  offset: number | string // 栅格左侧的间隔格数
  pull: number | string // 栅格向左移动格数
  xs: number | object // <768px 响应式栅格数或者栅格属性对象
  sm: number | object // ≥768px 响应式栅格数或者栅格属性对象
  md: number | object // ≥992 响应式栅格数或者栅格属性对象
  lg: number | object // ≥1200 响应式栅格数或者栅格属性对象
  xl: number | object // ≥1920px 响应式栅格数或者栅格属性对象 
}

function Col(props: any) {
  // const RowComponent = useContext(Context)
  // // 删除两个多余的传递属性 放置多个传递替换本身的 props 属性
  // if (RowComponent) {
  //   delete RowComponent.children
  //   delete RowComponent.item
  // }

  // 全部设置默认初始值
  const {
    span = 0,
    offset = 0,
    push = 0,
    pull,
    xs = 0,
    sm = 0,
    md = 0,
    lg = 0,
    xl = 0
  }: Iprops = props
  //   const [gutter, setGutter] = useState('')
  const [num, setNum] = useState(0)
  //   const [color, setColor] = useState('red')
  const [tbxs, setTbxs] = useState('')
  const [tbsm, setTbsm] = useState('')
  const [tbmd, setTbmd] = useState('')
  const [tblg, setTblg] = useState('')
  const [tbxl, setTbxl] = useState('')

  // 初始化
  useEffect(() => {
    setNum(4.1666)
    Pxs()
    Psm()
    Pmd()
    Plg()
    Pxl()
  }, []) // eslint-disable-line
  function Pxs() {
    // 如果是数值类型
    if (
      xs > 0 &&
      (/ Number/.test(Object.prototype.toString.call(xs)) ||
        / String/.test(Object.prototype.toString.call(xs)))
    ) {
      setTbxs('tb-col-xs-' + xs)
    } else if (xs && / Object/.test(Object.prototype.toString.call(xs))) {
      setTbxs(
        'tb-col-xs-' +
          (xs as { span: '' }).span +
          ' tb-col-xs-offset-' +
          (xs as { span: '' }).span
      )
    } else {
      setTbxs('')
    }
  }
  function Psm() {
    // 如果是数值类型
    if (
      sm > 0 &&
      (/ Number/.test(Object.prototype.toString.call(sm)) ||
        / String/.test(Object.prototype.toString.call(sm)))
    ) {
      setTbsm('tb-col-sm-' + sm)
    } else if (sm && / Object/.test(Object.prototype.toString.call(sm))) {
      setTbsm(
        'tb-col-sm-' +
          (sm as { span: '' }).span +
          ' tb-col-sm-offset-' +
          (sm as { span: '' }).span
      )
    } else {
      setTbsm('')
    }
  }
  function Pmd() {
    // 如果是数值类型
    if (
      md > 0 &&
      (/ Number/.test(Object.prototype.toString.call(md)) ||
        / String/.test(Object.prototype.toString.call(md)))
    ) {
      setTbmd('tb-col-md-' + md)
    } else if (md && / Object/.test(Object.prototype.toString.call(md))) {
      setTbmd(
        'tb-col-md-' +
          (md as { span: '' }).span +
          ' tb-col-md-offset-' +
          (md as { span: '' }).span
      )
    } else {
      setTbmd('')
    }
  }
  function Plg() {
    // 如果是数值类型
    if (
      lg > 0 &&
      (/ Number/.test(Object.prototype.toString.call(lg)) ||
        / String/.test(Object.prototype.toString.call(lg)))
    ) {
      setTblg('tb-col-lg-' + lg)
    } else if (lg && / Object/.test(Object.prototype.toString.call(lg))) {
      setTblg(
        'tb-col-lg-' +
          (lg as { span: '' }).span +
          ' tb-col-lg-offset-' +
          (lg as { span: '' }).span
      )
    } else {
      setTblg('')
    }
  }
  function Pxl() {
    // 如果是数值类型
    if (
      xl > 0 &&
      (/ Number/.test(Object.prototype.toString.call(xl)) ||
        / String/.test(Object.prototype.toString.call(xl)))
    ) {
      setTbxl('tb-col-xl-' + xl)
    } else if (xl && / Object/.test(Object.prototype.toString.call(xl))) {
      setTbxl(
        'tb-col-xl-' +
          (xl as { span: '' }).span +
          ' tb-col-xl-offset-' +
          (xl as { span: '' }).span
      )
    } else {
      setTbxl('')
    }
  }
  // const childrenItem = React.Children.map(props.children, (item) => {
  //   return React.cloneElement(item, {
  //     // ...RowComponent,
  //     item,
  //     instanceType:'Col',
  //     parent: {
  //       props
  //     }
  //   })
  // })

  return (
    <div
      className={`tb-col ${tbxs} ${tbsm} ${tbmd} ${tblg} ${tbxl} `}
      style={{
        width: `${num * Number(span)}%`,
        padding: `0 ${props.parent.props.gutter / 2}px`,
        marginLeft: `${num * Number(offset || pull) + '%'}`,
        marginRight: `${num * Number(push) + '%'}`
      }}
    >
      {/* {childrenItem ? childrenItem : props.children} */}
      {props.children}
    </div>
  )
}
export default Col

3.4、Col / index.scss

.tb-col {
  max-width: 100%;
  min-height: 36px;
  /* background: brown; */
  /* padding: 30px; */
  box-sizing: border-box;
}

@media only screen and (max-width: 767px) {
  .tb-col-xs-offset-1 {
    margin-left: calc(4.1666% * 1) !important;
  }

  .tb-col-xs-offset-2 {
    margin-left: calc(4.1666% * 2) !important;
  }

  .tb-col-xs-offset-3 {
    margin-left: calc(4.1666% * 3) !important;
  }

  .tb-col-xs-offset-4 {
    margin-left: calc(4.1666% * 4) !important;
  }

  .tb-col-xs-offset-5 {
    margin-left: calc(4.1666% * 5) !important;
  }

  .tb-col-xs-offset-6 {
    margin-left: calc(4.1666% * 6) !important;
  }

  .tb-col-xs-offset-7 {
    margin-left: calc(4.1666% * 7) !important;
  }

  .tb-col-xs-offset-8 {
    margin-left: calc(4.1666% * 8) !important;
  }

  .tb-col-xs-offset-9 {
    margin-left: calc(4.1666% * 9) !important;
  }

  .tb-col-xs-offset-10 {
    margin-left: calc(4.1666% * 10) !important;
  }

  .tb-col-xs-offset-11 {
    margin-left: calc(4.1666% * 11) !important;
  }

  .tb-col-xs-offset-12 {
    margin-left: calc(4.1666% * 12) !important;
  }

  .tb-col-xs-offset-13 {
    margin-left: calc(4.1666% * 13) !important;
  }

  .tb-col-xs-offset-14 {
    margin-left: calc(4.1666% * 14) !important;
  }

  .tb-col-xs-offset-15 {
    margin-left: calc(4.1666% * 15) !important;
  }

  .tb-col-xs-offset-16 {
    margin-left: calc(4.1666% * 16) !important;
  }

  .tb-col-xs-offset-17 {
    margin-left: calc(4.1666% * 17) !important;
  }

  .tb-col-xs-offset-18 {
    margin-left: calc(4.1666% * 18) !important;
  }

  .tb-col-xs-offset-19 {
    margin-left: calc(4.1666% * 19) !important;
  }

  .tb-col-xs-offset-20 {
    margin-left: calc(4.1666% * 20) !important;
  }

  .tb-col-xs-offset-21 {
    margin-left: calc(4.1666% * 21) !important;
  }

  .tb-col-xs-offset-22 {
    margin-left: calc(4.1666% * 22) !important;
  }

  .tb-col-xs-offset-23 {
    margin-left: calc(4.1666% * 23) !important;
  }

  .tb-col-xs-offset-24 {
    margin-left: calc(4.1666% * 24) !important;
  }

  .tb-col-xs-1 {
    width: calc(4.1666% * 1) !important;
  }

  .tb-col-xs-2 {
    width: calc(4.1666% * 2) !important;
  }

  .tb-col-xs-3 {
    width: calc(4.1666% * 3) !important;
  }

  .tb-col-xs-4 {
    width: calc(4.1666% * 4) !important;
  }

  .tb-col-xs-5 {
    width: calc(4.1666% * 5) !important;
  }

  .tb-col-xs-6 {
    width: calc(4.1666% * 6) !important;
  }

  .tb-col-xs-7 {
    width: calc(4.1666% * 7) !important;
  }

  .tb-col-xs-8 {
    width: calc(4.1666% * 8) !important;
  }

  .tb-col-xs-9 {
    width: calc(4.1666% * 9) !important;
  }

  .tb-col-xs-10 {
    width: calc(4.1666% * 10) !important;
  }

  .tb-col-xs-11 {
    width: calc(4.1666% * 11) !important;
  }

  .tb-col-xs-12 {
    width: calc(4.1666% * 12) !important;
  }

  .tb-col-xs-13 {
    width: calc(4.1666% * 13) !important;
  }

  .tb-col-xs-14 {
    width: calc(4.1666% * 14) !important;
  }

  .tb-col-xs-15 {
    width: calc(4.1666% * 15) !important;
  }

  .tb-col-xs-16 {
    width: calc(4.1666% * 16) !important;
  }

  .tb-col-xs-17 {
    width: calc(4.1666% * 17) !important;
  }

  .tb-col-xs-18 {
    width: calc(4.1666% * 18) !important;
  }

  .tb-col-xs-19 {
    width: calc(4.1666% * 19) !important;
  }

  .tb-col-xs-20 {
    width: calc(4.1666% * 20) !important;
  }

  .tb-col-xs-21 {
    width: calc(4.1666% * 21) !important;
  }

  .tb-col-xs-22 {
    width: calc(4.1666% * 22) !important;
  }

  .tb-col-xs-23 {
    width: calc(4.1666% * 23) !important;
  }

  .tb-col-xs-24 {
    width: calc(4.1666% * 24) !important;
  }
}

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

  .tb-col-sm-offset-1 {
    margin-left: calc(4.1666% * 1) !important;
  }

  .tb-col-sm-offset-2 {
    margin-left: calc(4.1666% * 2) !important;
  }

  .tb-col-sm-offset-3 {
    margin-left: calc(4.1666% * 3) !important;
  }

  .tb-col-sm-offset-4 {
    margin-left: calc(4.1666% * 4) !important;
  }

  .tb-col-sm-offset-5 {
    margin-left: calc(4.1666% * 5) !important;
  }

  .tb-col-sm-offset-6 {
    margin-left: calc(4.1666% * 6) !important;
  }

  .tb-col-sm-offset-7 {
    margin-left: calc(4.1666% * 7) !important;
  }

  .tb-col-sm-offset-8 {
    margin-left: calc(4.1666% * 8) !important;
  }

  .tb-col-sm-offset-9 {
    margin-left: calc(4.1666% * 9) !important;
  }

  .tb-col-sm-offset-10 {
    margin-left: calc(4.1666% * 10) !important;
  }

  .tb-col-sm-offset-11 {
    margin-left: calc(4.1666% * 11) !important;
  }

  .tb-col-sm-offset-12 {
    margin-left: calc(4.1666% * 12) !important;
  }

  .tb-col-sm-offset-13 {
    margin-left: calc(4.1666% * 13) !important;
  }

  .tb-col-sm-offset-14 {
    margin-left: calc(4.1666% * 14) !important;
  }

  .tb-col-sm-offset-15 {
    margin-left: calc(4.1666% * 15) !important;
  }

  .tb-col-sm-offset-16 {
    margin-left: calc(4.1666% * 16) !important;
  }

  .tb-col-sm-offset-17 {
    margin-left: calc(4.1666% * 17) !important;
  }

  .tb-col-sm-offset-18 {
    margin-left: calc(4.1666% * 18) !important;
  }

  .tb-col-sm-offset-19 {
    margin-left: calc(4.1666% * 19) !important;
  }

  .tb-col-sm-offset-20 {
    margin-left: calc(4.1666% * 20) !important;
  }

  .tb-col-sm-offset-21 {
    margin-left: calc(4.1666% * 21) !important;
  }

  .tb-col-sm-offset-22 {
    margin-left: calc(4.1666% * 22) !important;
  }

  .tb-col-sm-offset-23 {
    margin-left: calc(4.1666% * 23) !important;
  }

  .tb-col-sm-offset-24 {
    margin-left: calc(4.1666% * 24) !important;
  }

  .tb-col-sm-1 {
    width: calc(4.1666% * 1) !important;
  }

  .tb-col-sm-2 {
    width: calc(4.1666% * 2) !important;
  }

  .tb-col-sm-3 {
    width: calc(4.1666% * 3) !important;
  }

  .tb-col-sm-4 {
    width: calc(4.1666% * 4) !important;
  }

  .tb-col-sm-5 {
    width: calc(4.1666% * 5) !important;
  }

  .tb-col-sm-6 {
    width: calc(4.1666% * 6) !important;
  }

  .tb-col-sm-7 {
    width: calc(4.1666% * 7) !important;
  }

  .tb-col-sm-8 {
    width: calc(4.1666% * 8) !important;
  }

  .tb-col-sm-9 {
    width: calc(4.1666% * 9) !important;
  }

  .tb-col-sm-10 {
    width: calc(4.1666% * 10) !important;
  }

  .tb-col-sm-11 {
    width: calc(4.1666% * 11) !important;
  }

  .tb-col-sm-12 {
    width: calc(4.1666% * 12) !important;
  }

  .tb-col-sm-13 {
    width: calc(4.1666% * 13) !important;
  }

  .tb-col-sm-14 {
    width: calc(4.1666% * 14) !important;
  }

  .tb-col-sm-15 {
    width: calc(4.1666% * 15) !important;
  }

  .tb-col-sm-16 {
    width: calc(4.1666% * 16) !important;
  }

  .tb-col-sm-17 {
    width: calc(4.1666% * 17) !important;
  }

  .tb-col-sm-18 {
    width: calc(4.1666% * 18) !important;
  }

  .tb-col-sm-19 {
    width: calc(4.1666% * 19) !important;
  }

  .tb-col-sm-20 {
    width: calc(4.1666% * 20) !important;
  }

  .tb-col-sm-21 {
    width: calc(4.1666% * 21) !important;
  }

  .tb-col-sm-22 {
    width: calc(4.1666% * 22) !important;
  }

  .tb-col-sm-23 {
    width: calc(4.1666% * 23) !important;
  }

  .tb-col-sm-24 {
    width: calc(4.1666% * 24) !important;
  }
}

@media only screen and (min-width: 992px) {
  .tb-col-md-offset-1 {
    margin-left: calc(4.1666% * 1) !important;
  }

  .tb-col-md-offset-2 {
    margin-left: calc(4.1666% * 2) !important;
  }

  .tb-col-md-offset-3 {
    margin-left: calc(4.1666% * 3) !important;
  }

  .tb-col-md-offset-4 {
    margin-left: calc(4.1666% * 4) !important;
  }

  .tb-col-md-offset-5 {
    margin-left: calc(4.1666% * 5) !important;
  }

  .tb-col-md-offset-6 {
    margin-left: calc(4.1666% * 6) !important;
  }

  .tb-col-md-offset-7 {
    margin-left: calc(4.1666% * 7) !important;
  }

  .tb-col-md-offset-8 {
    margin-left: calc(4.1666% * 8) !important;
  }

  .tb-col-md-offset-9 {
    margin-left: calc(4.1666% * 9) !important;
  }

  .tb-col-md-offset-10 {
    margin-left: calc(4.1666% * 10) !important;
  }

  .tb-col-md-offset-11 {
    margin-left: calc(4.1666% * 11) !important;
  }

  .tb-col-md-offset-12 {
    margin-left: calc(4.1666% * 12) !important;
  }

  .tb-col-md-offset-13 {
    margin-left: calc(4.1666% * 13) !important;
  }

  .tb-col-md-offset-14 {
    margin-left: calc(4.1666% * 14) !important;
  }

  .tb-col-md-offset-15 {
    margin-left: calc(4.1666% * 15) !important;
  }

  .tb-col-md-offset-16 {
    margin-left: calc(4.1666% * 16) !important;
  }

  .tb-col-md-offset-17 {
    margin-left: calc(4.1666% * 17) !important;
  }

  .tb-col-md-offset-18 {
    margin-left: calc(4.1666% * 18) !important;
  }

  .tb-col-md-offset-19 {
    margin-left: calc(4.1666% * 19) !important;
  }

  .tb-col-md-offset-20 {
    margin-left: calc(4.1666% * 20) !important;
  }

  .tb-col-md-offset-21 {
    margin-left: calc(4.1666% * 21) !important;
  }

  .tb-col-md-offset-22 {
    margin-left: calc(4.1666% * 22) !important;
  }

  .tb-col-md-offset-23 {
    margin-left: calc(4.1666% * 23) !important;
  }

  .tb-col-md-offset-24 {
    margin-left: calc(4.1666% * 24) !important;
  }

  .tb-col-md-1 {
    width: calc(4.1666% * 1) !important;
  }

  .tb-col-md-2 {
    width: calc(4.1666% * 2) !important;
  }

  .tb-col-md-3 {
    width: calc(4.1666% * 3) !important;
  }

  .tb-col-md-4 {
    width: calc(4.1666% * 4) !important;
  }

  .tb-col-md-5 {
    width: calc(4.1666% * 5) !important;
  }

  .tb-col-md-6 {
    width: calc(4.1666% * 6) !important;
  }

  .tb-col-md-7 {
    width: calc(4.1666% * 7) !important;
  }

  .tb-col-md-8 {
    width: calc(4.1666% * 8) !important;
  }

  .tb-col-md-9 {
    width: calc(4.1666% * 9) !important;
  }

  .tb-col-md-10 {
    width: calc(4.1666% * 10) !important;
  }

  .tb-col-md-11 {
    width: calc(4.1666% * 11) !important;
  }

  .tb-col-md-12 {
    width: calc(4.1666% * 12) !important;
  }

  .tb-col-md-13 {
    width: calc(4.1666% * 13) !important;
  }

  .tb-col-md-14 {
    width: calc(4.1666% * 14) !important;
  }

  .tb-col-md-15 {
    width: calc(4.1666% * 15) !important;
  }

  .tb-col-md-16 {
    width: calc(4.1666% * 16) !important;
  }

  .tb-col-md-17 {
    width: calc(4.1666% * 17) !important;
  }

  .tb-col-md-18 {
    width: calc(4.1666% * 18) !important;
  }

  .tb-col-md-19 {
    width: calc(4.1666% * 19) !important;
  }

  .tb-col-md-20 {
    width: calc(4.1666% * 20) !important;
  }

  .tb-col-md-21 {
    width: calc(4.1666% * 21) !important;
  }

  .tb-col-md-22 {
    width: calc(4.1666% * 22) !important;
  }

  .tb-col-md-23 {
    width: calc(4.1666% * 23) !important;
  }

  .tb-col-md-24 {
    width: calc(4.1666% * 24) !important;
  }
}

@media only screen and (min-width: 1200px) {
  .tb-col-lg-offset-1 {
    margin-left: calc(4.1666% * 1) !important;
  }

  .tb-col-lg-offset-2 {
    margin-left: calc(4.1666% * 2) !important;
  }

  .tb-col-lg-offset-3 {
    margin-left: calc(4.1666% * 3) !important;
  }

  .tb-col-lg-offset-4 {
    margin-left: calc(4.1666% * 4) !important;
  }

  .tb-col-lg-offset-5 {
    margin-left: calc(4.1666% * 5) !important;
  }

  .tb-col-lg-offset-6 {
    margin-left: calc(4.1666% * 6) !important;
  }

  .tb-col-lg-offset-7 {
    margin-left: calc(4.1666% * 7) !important;
  }

  .tb-col-lg-offset-8 {
    margin-left: calc(4.1666% * 8) !important;
  }

  .tb-col-lg-offset-9 {
    margin-left: calc(4.1666% * 9) !important;
  }

  .tb-col-lg-offset-10 {
    margin-left: calc(4.1666% * 10) !important;
  }

  .tb-col-lg-offset-11 {
    margin-left: calc(4.1666% * 11) !important;
  }

  .tb-col-lg-offset-12 {
    margin-left: calc(4.1666% * 12) !important;
  }

  .tb-col-lg-offset-13 {
    margin-left: calc(4.1666% * 13) !important;
  }

  .tb-col-lg-offset-14 {
    margin-left: calc(4.1666% * 14) !important;
  }

  .tb-col-lg-offset-15 {
    margin-left: calc(4.1666% * 15) !important;
  }

  .tb-col-lg-offset-16 {
    margin-left: calc(4.1666% * 16) !important;
  }

  .tb-col-lg-offset-17 {
    margin-left: calc(4.1666% * 17) !important;
  }

  .tb-col-lg-offset-18 {
    margin-left: calc(4.1666% * 18) !important;
  }

  .tb-col-lg-offset-19 {
    margin-left: calc(4.1666% * 19) !important;
  }

  .tb-col-lg-offset-20 {
    margin-left: calc(4.1666% * 20) !important;
  }

  .tb-col-lg-offset-21 {
    margin-left: calc(4.1666% * 21) !important;
  }

  .tb-col-lg-offset-22 {
    margin-left: calc(4.1666% * 22) !important;
  }

  .tb-col-lg-offset-23 {
    margin-left: calc(4.1666% * 23) !important;
  }

  .tb-col-lg-offset-24 {
    margin-left: calc(4.1666% * 24) !important;
  }

  .tb-col-lg-1 {
    width: calc(4.1666% * 1) !important;
  }

  .tb-col-lg-2 {
    width: calc(4.1666% * 2) !important;
  }

  .tb-col-lg-3 {
    width: calc(4.1666% * 3) !important;
  }

  .tb-col-lg-4 {
    width: calc(4.1666% * 4) !important;
  }

  .tb-col-lg-5 {
    width: calc(4.1666% * 5) !important;
  }

  .tb-col-lg-6 {
    width: calc(4.1666% * 6) !important;
  }

  .tb-col-lg-7 {
    width: calc(4.1666% * 7) !important;
  }

  .tb-col-lg-8 {
    width: calc(4.1666% * 8) !important;
  }

  .tb-col-lg-9 {
    width: calc(4.1666% * 9) !important;
  }

  .tb-col-lg-10 {
    width: calc(4.1666% * 10) !important;
  }

  .tb-col-lg-11 {
    width: calc(4.1666% * 11) !important;
  }

  .tb-col-lg-12 {
    width: calc(4.1666% * 12) !important;
  }

  .tb-col-lg-13 {
    width: calc(4.1666% * 13) !important;
  }

  .tb-col-lg-14 {
    width: calc(4.1666% * 14) !important;
  }

  .tb-col-lg-15 {
    width: calc(4.1666% * 15) !important;
  }

  .tb-col-lg-16 {
    width: calc(4.1666% * 16) !important;
  }

  .tb-col-lg-17 {
    width: calc(4.1666% * 17) !important;
  }

  .tb-col-lg-18 {
    width: calc(4.1666% * 18) !important;
  }

  .tb-col-lg-19 {
    width: calc(4.1666% * 19) !important;
  }

  .tb-col-lg-20 {
    width: calc(4.1666% * 20) !important;
  }

  .tb-col-lg-21 {
    width: calc(4.1666% * 21) !important;
  }

  .tb-col-lg-22 {
    width: calc(4.1666% * 22) !important;
  }

  .tb-col-lg-23 {
    width: calc(4.1666% * 23) !important;
  }

  .tb-col-lg-24 {
    width: calc(4.1666% * 24) !important;
  }
}

@media only screen and (min-width: 1920px) {
  .tb-col-xl-offset-1 {
    margin-left: calc(4.1666% * 1) !important;
  }

  .tb-col-xl-offset-2 {
    margin-left: calc(4.1666% * 2) !important;
  }

  .tb-col-xl-offset-3 {
    margin-left: calc(4.1666% * 3) !important;
  }

  .tb-col-xl-offset-4 {
    margin-left: calc(4.1666% * 4) !important;
  }

  .tb-col-xl-offset-5 {
    margin-left: calc(4.1666% * 5) !important;
  }

  .tb-col-xl-offset-6 {
    margin-left: calc(4.1666% * 6) !important;
  }

  .tb-col-xl-offset-7 {
    margin-left: calc(4.1666% * 7) !important;
  }

  .tb-col-xl-offset-8 {
    margin-left: calc(4.1666% * 8) !important;
  }

  .tb-col-xl-offset-9 {
    margin-left: calc(4.1666% * 9) !important;
  }

  .tb-col-xl-offset-10 {
    margin-left: calc(4.1666% * 10) !important;
  }

  .tb-col-xl-offset-11 {
    margin-left: calc(4.1666% * 11) !important;
  }

  .tb-col-xl-offset-12 {
    margin-left: calc(4.1666% * 12) !important;
  }

  .tb-col-xl-offset-13 {
    margin-left: calc(4.1666% * 13) !important;
  }

  .tb-col-xl-offset-14 {
    margin-left: calc(4.1666% * 14) !important;
  }

  .tb-col-xl-offset-15 {
    margin-left: calc(4.1666% * 15) !important;
  }

  .tb-col-xl-offset-16 {
    margin-left: calc(4.1666% * 16) !important;
  }

  .tb-col-xl-offset-17 {
    margin-left: calc(4.1666% * 17) !important;
  }

  .tb-col-xl-offset-18 {
    margin-left: calc(4.1666% * 18) !important;
  }

  .tb-col-xl-offset-19 {
    margin-left: calc(4.1666% * 19) !important;
  }

  .tb-col-xl-offset-20 {
    margin-left: calc(4.1666% * 20) !important;
  }

  .tb-col-xl-offset-21 {
    margin-left: calc(4.1666% * 21) !important;
  }

  .tb-col-xl-offset-22 {
    margin-left: calc(4.1666% * 22) !important;
  }

  .tb-col-xl-offset-23 {
    margin-left: calc(4.1666% * 23) !important;
  }

  .tb-col-xl-offset-24 {
    margin-left: calc(4.1666% * 24) !important;
  }

  .tb-col-xl-1 {
    width: calc(4.1666% * 1) !important;
  }

  .tb-col-xl-2 {
    width: calc(4.1666% * 2) !important;
  }

  .tb-col-xl-3 {
    width: calc(4.1666% * 3) !important;
  }

  .tb-col-xl-4 {
    width: calc(4.1666% * 4) !important;
  }

  .tb-col-xl-5 {
    width: calc(4.1666% * 5) !important;
  }

  .tb-col-xl-6 {
    width: calc(4.1666% * 6) !important;
  }

  .tb-col-xl-7 {
    width: calc(4.1666% * 7) !important;
  }

  .tb-col-xl-8 {
    width: calc(4.1666% * 8) !important;
  }

  .tb-col-xl-9 {
    width: calc(4.1666% * 9) !important;
  }

  .tb-col-xl-10 {
    width: calc(4.1666% * 10) !important;
  }

  .tb-col-xl-11 {
    width: calc(4.1666% * 11) !important;
  }

  .tb-col-xl-12 {
    width: calc(4.1666% * 12) !important;
  }

  .tb-col-xl-13 {
    width: calc(4.1666% * 13) !important;
  }

  .tb-col-xl-14 {
    width: calc(4.1666% * 14) !important;
  }

  .tb-col-xl-15 {
    width: calc(4.1666% * 15) !important;
  }

  .tb-col-xl-16 {
    width: calc(4.1666% * 16) !important;
  }

  .tb-col-xl-17 {
    width: calc(4.1666% * 17) !important;
  }

  .tb-col-xl-18 {
    width: calc(4.1666% * 18) !important;
  }

  .tb-col-xl-19 {
    width: calc(4.1666% * 19) !important;
  }

  .tb-col-xl-20 {
    width: calc(4.1666% * 20) !important;
  }

  .tb-col-xl-21 {
    width: calc(4.1666% * 21) !important;
  }

  .tb-col-xl-22 {
    width: calc(4.1666% * 22) !important;
  }

  .tb-col-xl-23 {
    width: calc(4.1666% * 23) !important;
  }

  .tb-col-xl-24 {
    width: calc(4.1666% * 24) !important;
  }
}

四、效果呈现

在这里插入图片描述
在这里插入图片描述
至此效果实现

这边 react 官网也在进行开发,也请大家持续关注博主

结语

✨ 每天创作一点点
✨ 开心快乐一整天
✨ 点赞关注加收藏
✨ 美好一天又一天

铁铁们 感谢支持 我需要你们的三连 👍👍👍
请添加图片描述

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

归来巨星

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

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

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

打赏作者

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

抵扣说明:

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

余额充值