当前位置:网站首页>select 标签自定义样式
select 标签自定义样式
2022-08-05 02:14:00 【tengyuxin】
需求原因:我在vue开发中,也会习惯使用各种UI库,但让人难受的是,提供的UI组件的样式难以覆盖,比如我要用的select,我的界面风格是深蓝色的,它的白色背景都不符合需求,要跑到element-plus的样式文件去修改。
=》之后,我想,这种简单的组件,我完全可以自己手写,好处可以让我更好的掌握select本身,消除不确定的部分。
=》以后,可以直接拿来当组件使用
下面就是自己修改出来的样式截图

vue3 里面的html结构
<div class="selectParent">
<select class="selectBox">
<option
v-for="item in blockArr"
:key="item.value"
:value="item.value"
class="optionCommon"
>
{
{ item.label }}
</option>
</select>
</div>vue3 script setup里面
<script setup>
import { reactive, ref } from "vue";
let data1 = [
{
label: "滕滕勇猛无敌1",
value: 1,
},
{
label: "滕滕勇猛无敌2",
value: 2,
},
{
label: "滕滕勇猛无敌3",
value: 3,
},
{
label: "滕滕勇猛无敌4",
value: 4,
},
{
label: "滕滕勇猛无敌5",
value: 5,
},
];
let blockArr = reactive(data1);
</script>vue3 style
<style scoped>
.selectParent {
display: flex;
flex-direction: row;
justify-content: center;
padding-top: 1.1rem;
}
.selectBox {
background-color: rgba(255, 255, 255, 0);
color: #fff;
border: none;
font-size: 2.6rem;
}
.optionCommon {
background-color: rgba(5, 36, 72, 1);
}
/* select 选中时,不显示边框 */
select {
outline: none;
}
</style>outline属性
在点击select时,会出现边框,这个边框叫外围边框,不占内容大小。案例如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style type="text/css">
p {
border:red solid thin;
outline:#00ff00 dotted thick;
}
</style>
</head>
<body>
<p><b>注释:</b>只有在规定了 !DOCTYPE 时,Internet Explorer 8 (以及更高版本) 才支持 outline 属性。</p>
</body>
</html>边栏推荐
猜你喜欢

SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型

开篇-开启全新的.NET现代应用开发体验

Simple implementation of YOLOv7 pre-training model deployment based on OpenVINO toolkit

DAY22:sqli-labs 靶场通关wp(Less01~~Less20)

常见的硬件延迟
![[Word] #() error occurs after Word formula is exported to PDF](/img/6a/168ded19d22826b6af974907f480fb.png)
[Word] #() error occurs after Word formula is exported to PDF

Jincang database KingbaseES V8 GIS data migration solution (3. Data migration based on ArcGIS platform to KES)

【Word】Word公式导出PDF后出现井号括号#()错误

CPDA|运营人如何从负基础学会数据分析(SQL)

.Net C# Console Create a window using Win32 API
随机推荐
std::string::find 返回值的坑
“配置”是把双刃剑,带你了解各种配置方法
短域名绕过及xss相关知识
Fragment visibility judgment
AI+小核酸药物|Eleven完成2200万美元种子轮融资
优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
iNFTnews | What can NFTs bring to the sports industry and fans?
重新审视分布式系统:永远不会有完美的一致性方案……
Using OpenVINO to implement the flying paddle version of the PGNet inference program
LPQ (local phase quantization) study notes
Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
ExcelPatternTool: Excel table-database mutual import tool
[Word] #() error occurs after Word formula is exported to PDF
线性表的查找
金仓数据库 KingbaseES V8 GIS数据迁移方案(3. 基于ArcGIS平台的数据迁移到KES)
Simple implementation of YOLOv7 pre-training model deployment based on OpenVINO toolkit
【OpenCV 图像处理2】:OpenCV 基础知识
js中try...catch和finally的用法
How to create an rpm package
1349. 参加考试的最大学生数 状态压缩