I am currently working with vue.js version 2.6.10 and element-ui version 2.15.1. The element-ui component I am using is as follows:
<el-tooltip content="Top center" placement="top">
<span>Dark</span>
</el-tooltip>
By default, the tooltip has a black background.
https://i.stack.imgur.com/6gj84.png
After referring to the documentation, I noticed the existence of the effect
attribute with accepted values of dark
or light
.
I am curious if there is a way to customize the background color of el-tooltip?
Edit:
I attempted the following:
<el-tooltip content="Top center" placement="top" effect="light" class="custom-tooltip">
<span>Dark</span>
</el-tooltip>
<style scoped>
.custom-tooltip {
background-color: #ffcc00;
color: #000;
}
</style>
Resulted in:
https://i.stack.imgur.com/Db0ZD.png
Another attempt (following the example):
<el-tooltip content="Top center" placement="top" effect="light" effect="customized">
<span>Dark</span>
</el-tooltip>
<style>
.el-popper.is-customized {
/* Set padding to ensure the height is 32px */
padding: 6px 12px;
background: linear-gradient(90deg, rgb(159, 229, 151), rgb(204, 229, 129));
}
.el-popper.is-customized .el-popper__arrow::before {
background: linear-gradient(45deg, #b2e68d, #bce689);
right: 0;
}
</style>
Resulted in: