elementui messageBox自定义弹窗的样式(若依)

背景

  • 在scoped中自定义样式之后:发现自定义样式没有生效
html 复制代码
<style scoped>
.custom-alert  {
  height: 300px; /* 你想要设置的高度 */
  overflow-y: auto;
}
</style>

解决方法

  • 新建一个style标签,不要加scoped
  • 样式生效了
html 复制代码
<style>
.custom-alert .el-message-box__message {
  height: 300px; /* 你想要设置的高度 */
  overflow-y: auto;
}
</style>

使用

在使用$alter的时候,使用 属性 customClass

js 复制代码
  this.$alert(response.msg, "导入结果", {
    dangerouslyUseHTMLString: true,
    customClass: 'custom-alert'
  });

延伸

  • 其实这个配置不只是用于$alert,其他的confirm什么的也可以用
  • 其实custom-alert 是整个 弹窗的样式,.el-message-box__message 后面才是消息的样式,这样就可以保证只改变消息内容区域的样式,按钮一直保持在下面
相关推荐
恋猫de小郭4 小时前
AGENTS.md 真的对 AI Coding 有用吗?或许在此之前你没用对?
前端·人工智能·ai编程
sunny_6 小时前
构建工具的第三次革命:从 Rollup 到 Rust Bundler,我是如何设计 robuild 的
前端·rust·前端工程化
rfidunion7 小时前
springboot+VUE+部署(12。Nginx和前端配置遇到的问题)
前端·vue.js·spring boot
珹洺7 小时前
Java-servlet(五)手把手教你利用Servlet配置HTML请求与相应
java·运维·服务器·前端·servlet·html·maven
FYKJ_20107 小时前
springboot大学校园论坛管理系统--附源码42669
java·javascript·spring boot·python·spark·django·php
QQ24391977 小时前
语言在线考试与学习交流网页平台信息管理系统源码-SpringBoot后端+Vue前端+MySQL【可直接运行】
前端·spring boot·sql·学习·java-ee
范特西.i8 小时前
QT聊天项目(6)
前端
a1117768 小时前
水体渲染系统(html开源)
前端·开源·threejs·水体渲染
程序员小李白8 小时前
CSS 盒子模型
前端·css·html
Zzz不能停8 小时前
单行 / 多行文本显示省略号(CSS 实现)
前端·css