Vue css实现语文作文格子效果

20 篇文章 0 订阅

Vue + css实现语文作文格子效果,基本上是css实现的,且需要提示每满100字数给出提示,且每一行拼接完整行数

效果图:
在这里插入图片描述

![在这里插入图片描述](https://img-blog.csdnimg.cn/5ea3a563154341c68bf30c2b15da8183.png

代码区域:

DOM部分

<!-- 语文作文 -->
          <div v-if="cellList.length > 0" class="ChineseWrittes">
            <div
              v-for="(item, index) in cellList"
              :key="index"
              :class="[(index + 1) % 22 == 0 ? 'littleCellB' : 'littleCell']"
            >
              <div v-if="(index + 1) % 100 == 0" class="cellTips">
                <span>{{ index + 1 }}</span>
              </div>
            </div>
          </div>
         //之所以要去余数22取整,是因为每行22个,每行的最后一个去掉右边边框,如此就不会有样式冲突

样式style部分

  // 作文样式
  .ChineseWrittes {
    width: 99.85%;
    margin: 0 auto;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    border: 1px solid #000000;
    border-top: none;
    .littleCell {
      width: 30px;
      height: 30px;
      margin-bottom: 5px;
      border: 1px solid #171212;
      border-left: none;
    }
    .littleCellB {
      width: 30px;
      height: 30px;
      margin-bottom: 5px;
      border: 1px solid #171212;
      border-left: none;
      border-right: none;
    }
    //文字提示
    .cellTips {
      position: absolute;
      color: rgb(8, 8, 8);
      font-weight: 560;
      left: 6px;
      top: -6px;
    }
  }

格子个数来源

cellList为一个数组,需要多少个格子,只需控制cellList数组中元素的个数即可

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值