码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • CSS 修改el-calendar的样式,自定义样式


    需求:自定义elementui的日历的样式;给符合条件的时间展示红点。

    elementui的原始样式: 

    目标样式:

     

    代码实现:

    html:

    1. <el-calendar v-model="calendarValue">
    2. <template slot="dateCell" slot-scope="{date, data}">
    3. <div class="is-point">
    4. <span>{{ Number(data.day.split('-')[2]) }}span>
    5. <i v-show="pointList.includes(data.day)" />
    6. div>
    7. template>
    8. el-calendar>

    JS:

    1. export default {
    2. name: 'Dashboard',
    3. data() {
    4. return {
    5. calendarValue: new Date(),
    6. pointList: ['2023-09-12', '2023-09-11', '2023-09-01'],
    7. }
    8. },
    9. }

    css: 

    1. <style lang="scss" scoped>
    2. ::v-deep .el-calendar {
    3. padding-right: 17px;
    4. .el-calendar__header {
    5. font-size: 16px;
    6. font-weight: 700;
    7. color: #000000;
    8. line-height: 22px;
    9. border-bottom: 0;
    10. }
    11. .el-calendar__body {
    12. padding: 0px 0px 30px;
    13. thead {
    14. th {
    15. color: #7f2ca9;
    16. font-weight: 600;
    17. font-size: 14px;
    18. }
    19. }
    20. .el-calendar-table__row {
    21. td {
    22. border: 0;
    23. height: unset;
    24. border-radius: 50%;
    25. font-size: 13px;
    26. }
    27. .el-calendar-day {
    28. height: 33px;
    29. line-height: 37px;
    30. padding: 0;
    31. span {
    32. height: 24px;
    33. line-height: 24px;
    34. width: 24px;
    35. text-align: center;
    36. border-radius: 50%;
    37. display: inline-block;
    38. }
    39. &:hover {
    40. background-color: unset;
    41. span {
    42. background-color: #7f2ca91a;
    43. color: #7f2ca9;
    44. }
    45. }
    46. }
    47. .is-selected {
    48. background-color: unset;
    49. .el-calendar-day {
    50. span {
    51. background-color: #7f2ca9;
    52. color: #ffffff;
    53. }
    54. }
    55. }
    56. }
    57. }
    58. .is-point {
    59. display: flex;
    60. flex-direction: column;
    61. justify-content: flex-end;
    62. align-items: center;
    63. margin: 0;
    64. i {
    65. margin-top: 1px;
    66. display: inline-block;
    67. width: 6px;
    68. height: 6px;
    69. background: #ff0000;
    70. border-radius: 50%;
    71. }
    72. }
    73. }
    74. style>

     在这里小记一下,主要也是为了保留一下这次的修改成果,方便以后使用

    有个没改好的地方就是,右上角的选择上下月的按钮不好修改为左右箭头,所以那块就没做优化,大家要是有好方法可以让我借鉴借鉴,ui如下:

  • 相关阅读:
    【中秋国庆不断更】OpenHarmony定义可动画属性:@AnimatableExtend装饰器
    【Canvas与艺术】绘制铜质钢底24周年纪念章
    Linux 中的 chmod 命令及示例
    Spring学习笔记(三十七)——Flyway 数据库版本控制
    Thymeleaf简要学习笔记(转自代码重工)
    基于javaweb+mysql的jsp+servlet学生成绩管理系统(管理员、教师、学生)
    virtualBOX网络配置
    【Syslog】采用Syslog4j发送总线日志
    嵌入式培训机构四个月实训课程笔记(完整版)-Linux ARM驱动编程第六天-ARM Linux编程之高级驱动基础 (物联技术666)
    MySQL中的日志(redo log、undo log、binlog)
  • 原文地址:https://blog.csdn.net/qq_58340302/article/details/132882233
  • 最新文章
  • 【JVM】编译执行与解释执行的区别是什么?JVM 使用哪种方式?
    用 Hashids 优雅解决 C 端自增 ID 暴露问题
    V8引擎 精品漫游指南--Ignition篇(上) 指令 栈帧 槽位 调用约定 内存布局 基础内容
    LLVM Pass快速入门(四):代码插桩
    milkup:桌面端 markdown AI续写和即时渲染
    基于项目工程构建SBOM(软件物料清单)的研究
    鸿蒙应用开发UI基础第二节:鸿蒙应用程序框架核心解析与实操
    .NET 中如何快速实现 List 集合去重?
    扣子Coze实战:从0到1打造抖音+小红书热点监控智能体
    浅谈数据访问层
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号