vue3 antdv a-datepicker 修改datepicker 的panel宽度,初始弹出一些正常,但再次弹出,宽度就再次变小的解决

news2024/9/22 6:48:26

1、展示页面的框架结构:

2、然后,我们上二张图对比一下:

图1-1

需要的效果图:

图1-2

对比一下图1-1与图1-2,我们就会发现图1-1中的农历,换行显示了,第二张是有效的。

3、我们修改样式,让其变成我们想要的样式:

<style lang="less" scoped>
  @width: 425px;

  .lua-date-picker-custom {
    background: none !important;

    .ant-picker-panel-container {
      width: @width;
      background: #fff !important;
      color: #000000 !important;
    }

    .ant-picker-panel {
      width: @width;
      border: 0px solid #000000 !important;
    }

    .ant-picker-header {
      width: @width;
      color: #000000 !important;
    }

    .ant-picker-content {
      width: @width - 20px;
    }

    .ant-picker-content th,
    td {
      color: #000000 !important;
    }

    .ant-picker-content td:hover > .ant-picker-cell-inner {
      background: #fff !important;
    }

    .ant-picker-cell:hover:not(.ant-picker-cell-in-view) .ant-picker-cell-inner,
    .ant-picker-cell:hover:not(.ant-picker-cell-selected):not(.ant-picker-cell-range-start):not(
        .ant-picker-cell-range-end
      ):not(.ant-picker-cell-range-hover-start):not(.ant-picker-cell-range-hover-end)
      .ant-picker-cell-inner {
      background: #fff !important;
    }

    .ant-picker-cell-inner {
      background: #fff !important;
    }

    .ant-picker-time-panel-column
      > li.ant-picker-time-panel-cell
      .ant-picker-time-panel-cell-inner {
      color: #000000 !important;
    }

    .ant-picker-time-panel-column
      > li.ant-picker-time-panel-cell-selected
      .ant-picker-time-panel-cell-inner {
      background: #fff !important;
    }

    .ant-picker-datetime-panel .ant-picker-time-panel {
      border-left: 1px solid #000000 !important;
    }

    .ant-picker-time-panel-column:not(:first-child) {
      border-left: 1px solid #000000 !important;
    }

    .ant-picker-ok {
      background: #fff !important;
      color: #fff !important;
    }

    .ant-btn-primary[disabled],
    .ant-btn-primary[disabled]:hover,
    .ant-btn-primary[disabled]:focus,
    .ant-btn-primary[disabled]:active {
      color: #fff;
      border: none;
      background: #fff !important;
      text-shadow: none;
      box-shadow: none;
    }

    .ant-picker-range-arrow::after {
      border-color: #c0c4cc #c0c4cc transparent transparent;
    }
  }
</style>

3、我们发现代码中感觉没有什么不对的地方,但是为什么会出现不太稳定的情况呢,初始加载是好的,然后再次退出Modal,再次进入Modal就变窄了,就是变长了一些,宽度变小,导致农历显示换行的情况。

4、然后我们把scoped去掉,就会发现竟然好了,这个scoped是局部的意思,然后是在Modal中显示出来的。

5、稳定的css的写法如下:

<style lang="less">
  @width: 425px;

  .lua-date-picker-custom {
    background: none !important;

    .ant-picker-panel-container {
      width: @width;
      background: #fff !important;
      color: #000000 !important;
    }

    .ant-picker-panel {
      width: @width;
      border: 0px solid #000000 !important;
    }

    .ant-picker-header {
      width: @width;
      color: #000000 !important;
    }

    .ant-picker-content {
      width: @width - 20px;
    }

    .ant-picker-content th,
    td {
      color: #000000 !important;
    }

    .ant-picker-content td:hover > .ant-picker-cell-inner {
      background: #fff !important;
    }

    .ant-picker-cell:hover:not(.ant-picker-cell-in-view) .ant-picker-cell-inner,
    .ant-picker-cell:hover:not(.ant-picker-cell-selected):not(.ant-picker-cell-range-start):not(
        .ant-picker-cell-range-end
      ):not(.ant-picker-cell-range-hover-start):not(.ant-picker-cell-range-hover-end)
      .ant-picker-cell-inner {
      background: #fff !important;
    }

    .ant-picker-cell-inner {
      background: #fff !important;
    }

    .ant-picker-time-panel-column
      > li.ant-picker-time-panel-cell
      .ant-picker-time-panel-cell-inner {
      color: #000000 !important;
    }

    .ant-picker-time-panel-column
      > li.ant-picker-time-panel-cell-selected
      .ant-picker-time-panel-cell-inner {
      background: #fff !important;
    }

    .ant-picker-datetime-panel .ant-picker-time-panel {
      border-left: 1px solid #000000 !important;
    }

    .ant-picker-time-panel-column:not(:first-child) {
      border-left: 1px solid #000000 !important;
    }

    .ant-picker-ok {
      background: #fff !important;
      color: #fff !important;
    }

    .ant-btn-primary[disabled],
    .ant-btn-primary[disabled]:hover,
    .ant-btn-primary[disabled]:focus,
    .ant-btn-primary[disabled]:active {
      color: #fff;
      border: none;
      background: #fff !important;
      text-shadow: none;
      box-shadow: none;
    }

    .ant-picker-range-arrow::after {
      border-color: #c0c4cc #c0c4cc transparent transparent;
    }
  }
</style>

只是把scoped给去掉了,就达到了我们的效果,其实就是全局样式的意思。

6、经过实测以后,我们发现不管是将css放到主页面,还是放到Modal中,一定要去掉scoped才行,否则不生效。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2043173.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

秋招突击——8/15——知识补充——垃圾回收机制

文章目录 引言正文指针引用可达性分析算法垃圾回收算法标记清除算法标记整理算法复制分代收集 垃圾收集器Serial收集器ParNew并行收集器Parallel Scavenge吞吐量优先收集器Serial Old老年代收集器Parallel old收集器CMS收集器G1收集器&#xff08;Garbage First垃圾优先&#x…

关于堆的介绍

1.堆的概念及结构 如果有一个关键码的集合&#xff0c;把它的所有元素按完全二叉树的顺序存储方式存储在一个一维数组中&#xff0c;并满足&#xff1a;且则称为小堆&#xff08;或大堆&#xff09;。将根节点最大的堆叫做最大堆或者大根堆&#xff0c;根节点最小的堆叫做最小…

【Linux】:进程控制(创建、终止、等待、替换)

目录 1.进程创建 2.进程终止&#xff08;退出&#xff09; 2.1 什么是进程终止 2.2 进程退出的场景&#xff08;原因&#xff09; 2.3 进程退出码 2.4 错误码errno 2.5 进程常见的退出方法 正常终止 从main函数返回 调用库函数exit 系统接口_exit 3.进程等待 3.1 …

【Linux】简易线程池项目

线程池是一个可以巩固一些线程相关接口 && 加强理解的一个小项目。 注意&#xff1a;这里的线程池使用的线程并不是Linux原生接口&#xff0c;而是经过封装的&#xff0c;具体请看线程封装&#xff0c;为什么不使用原生接口&#xff1f; 因为原生接口一旦进行pthread…

2024最新easyrecovery 14中文破解版图文教程

使用EasyRecovery易恢复进行数据恢复非常简单。首先&#xff0c;用户需要选择需要恢复的数据类型&#xff0c;如文档、图片、视频等。然后&#xff0c;软件会对选定的存储设备进行全面扫描&#xff0c;以寻找可恢复的数据。在扫描过程中&#xff0c;用户可以预览部分已找到的文…

成化瓷器“制字衣横少越刀”--还有例外

孙瀛洲先生关于成化款瓷器的名言非常经典&#xff0c;但是&#xff0c;凡事总有以外。 图1&#xff0c;本人收藏成化斗彩鸡缸杯底款&#xff0c;制字的衣横越过双勾刀。 下面是两件台北故宫成化瓷器底款&#xff0c;制字下面的衣横也是越过刀了。 所以&#xff0c;凡事总有例外…

mysql5.7安装

1.创建一个software文件 2.先下载mysql的repo源 wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 3安装源包 rpm -ivh mysql-community-release-el7-5.noarch.rpm 可能会报错 改成命令 rpm -ivh mysql-community-release-el7-5.noarch.rpm --nodeps…

优化图像处理:从旋转与缩放到水印添加

1. 旋转与缩放的仿射变换 在 OpenCV 中&#xff0c;cv2.getRotationMatrix2D() 函数可以生成旋转矩阵&#xff0c;该矩阵用于对图像进行旋转和缩放变换。旋转矩阵的主要参数是&#xff1a; Center&#xff1a;旋转中心点的坐标 (x, y)。 Angle&#xff1a;旋转角度&#xff0…

数据结构与算法--图的应用

文章目录 回顾提要连通图生成树最小生成树构造最小生成树的算法普里姆(Prim)算法克鲁斯卡尔(Kruskal)算法 最短路径狄杰斯特拉 (Dijkstra) 算法当前最短路径的更新拓扑排序拓扑排序方法拓扑排序示例总结 回顾 图的遍历方法&#xff1a; 深度优先遍历 (DFS)&#xff1a;从任意…

在centos7安装mysql

1.卸载旧环境 ps axj | grep mysql ps axj | grep mariabd 如果是这样就什么都不需要做。 如果不是 2.检查并卸载系统安装包 //检查安装包 rpm -qa | grep mysql//卸载安装包 rpm -qa | grep mysql | xargs yum -y remove 3.安装官方yum源 先查看系统的版本 比如我是7.9版…

力扣高频SQL 50题(基础版)第四十题之1164. 指定日期的产品价格

文章目录 力扣高频SQL 50题&#xff08;基础版&#xff09;第四十题1164. 指定日期的产品价格题目说明实现过程准备数据实现方式结果截图总结FIRST_VALUE()函数LAST_VALUE()函数NTH_VALUE()函数 LAST_VALUE()函数NTH_VALUE()函数 力扣高频SQL 50题&#xff08;基础版&#xff0…

YJ0043定制版抖音电商卷抢购系统带回收商城抖音电商优惠卷投资理财系统

系统是基于逍遥商城二开的系统&#xff0c;pc手机端都新增了邀请码验证 手机端重新定制的UI&#xff0c;前端产品不至于抖音卷也可以自行更改其他产品 用户前端下单&#xff0c;后台订单可以直接回收&#xff0c;后台支持设置默认邀请码和抢卷时间限制

动手学深度学习(pytorch)学习记录10-从零开始实现softmax回归[学习记录]

注&#xff1a;本代码在jupyter notebook上运行 封面图片来源 导包 import torch from IPython import display import torchvision from torchvision import transforms from torch.utils import data设置加载数据的线程数 def get_dataloader_workers(): ""&qu…

《学会 SpringBoot 系列 · spring.factories 详解》

&#x1f4e2; 大家好&#xff0c;我是 【战神刘玉栋】&#xff0c;有10多年的研发经验&#xff0c;致力于前后端技术栈的知识沉淀和传播。 &#x1f497; &#x1f33b; CSDN入驻不久&#xff0c;希望大家多多支持&#xff0c;后续会继续提升文章质量&#xff0c;绝不滥竽充数…

机器人阻抗控制之设计方法

机器人阻抗控制的设计方法主要围绕调整机器人与环境之间的动态关系&#xff0c;使其等效为由弹簧-阻尼-质量组成的二阶系统。这一控制策略不是直接控制机器人的运动或其与外界的接触力&#xff0c;而是控制这二者之间的动态关系。以下是机器人阻抗控制设计方法的详细阐述&#…

Centos7系统上安装docker

centos7安装docker 安装之前&#xff0c;一定查看是否安装docker&#xff0c;如果有&#xff0c;卸载老版本 我是虚拟机装的Centos7&#xff0c;linux 3.10 内核&#xff0c;docker官方说至少3.8以上&#xff0c;建议3.10以上&#xff08;ubuntu下要linux内核3.8以上&#xff…

LVS详细配置

目录 LVS简介 LVS集群体系结构 LVS相关术语 lvs集群的类型 1、NAT模式 NAT简介 NAT模式数据逻辑 2、DR模式 DR模式简介 DR模式数据逻辑 DR模式的特点 3、TUN模式 TUN模式简介 TUN模式数据传输过程 TUN模式特点 4、fullnet模式 LVS模式总结 LVS调度算法 LVS静…

python从入门到精通:函数

目录 1、函数介绍 2、函数的定义 3、函数的传入参数 4、函数的返回值 5、函数说明文档 6、函数的嵌套调用 7、变量的作用域 1、函数介绍 函数是组织好的&#xff0c;可重复使用的&#xff0c;用来实现特定功能的代码段。 name "zhangsan"; length len(nam…

机器学习(1)--数据可视化

文章目录 数据可视化作用可视化方法实现可视化 总结 数据可视化 数据可视化是将数据以图形、图像、动画等视觉形式表示出来&#xff0c;以便人们能够更直观地理解、分析和交流数据中的信息。 作用 一个整理的好好的数据&#xff0c;我们为什么要将其可视化呢&#xff1f;将它…

深入理解指针

前言&#xff1a;对于指针我们已经有了初步的了解&#xff0c;并已能够简单使用。今天我们来深入理解指针。让我们的指针功力更上一层楼。 1 使用指针访问数组 有了指针的知识&#xff0c;再结合数组的特点&#xff0c;我们就可以使用指针来访问数组了。 #include<stdio.…