当前位置:网站首页>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>边栏推荐
- Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
- Transfer Learning - Distant Domain Transfer Learning
- A new technical director, who calls DDD a senior, is convinced
- 超越YOLO5-Face | YOLO-FaceV2正式开源Trick+学术点拉满
- ARM Mailbox
- 基于OpenVINO工具套件简单实现YOLOv7预训练模型的部署
- DAY22:sqli-labs 靶场通关wp(Less01~~Less20)
- HOG feature study notes
- 如何模拟后台API调用场景,很细!
- PHP技能评测
猜你喜欢

使用SuperMap iDesktopX数据迁移工具迁移地图文档和符号

MySQL learning

刷爆朋友圈,Alibaba出品亿级并发设计速成笔记太香了

线性表的查找

sql语句多字段多个值如何进行排序

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

"Dilili, wait for the lights, wait for the lights", the prompt sound for safe production in the factory

1349. Maximum number of students taking the exam Status Compression

迁移学习——Joint Geometrical and Statistical Alignment for Visual Domain Adaptation

如何基于OpenVINO POT工具简单实现对模型的量化压缩
随机推荐
.Net C# Console Create a window using Win32 API
直播预告|30分钟快速入门!来看可信分布式AI链桨的架构设计
Object.defineProperty实时监听数据变化并更新页面
亚马逊云科技携手中科创达为行业客户构建AIoT平台
原生js实现多选框全部选中和取消效果
如何发现一个有价值的 GameFi?
特殊矩阵的压缩存储
网络安全与元宇宙:找出薄弱环节
Oracle encapsulates restful interfaces into views
高数_复习_第1章:函数、极限、连续
C语言基础知识 -- 指针
How to create an rpm package
英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能
【OpenCV 图像处理2】:OpenCV 基础知识
2022 EdgeX中国挑战赛8月3日即将盛大开幕
Leetcode刷题——22. 括号生成
01 【前言 基础使用 核心概念】
转:查尔斯·汉迪:你是谁,比你做什么更重要
领域驱动设计——MDD
KingbaseES V8 GIS data migration solution (2. Introduction to the capabilities of Kingbase GIS)