Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use SVG and CSS3 to make select drop-down menu beautify effect

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

这篇文章主要介绍如何使用SVG和CSS3制作select下拉菜单美化效果,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

HTML结构

我们现在来看一下select下拉菜单的Html结构:。

Choose your option Option 1 Option 2 Option 3

我们需要将它转换为下面的结构:

Choose your option Option 1 Option 2 Option 3

Choose your option Option 1 Option 2 Option 3

我们保留实际的select元素是因为我们需要它来选择元素值。

placeholder占位符被设置为disabled,并且设置为空值。它是一个可选项,可以不使用它,这时,第一个列表选项将被显示或者是有"selected"属性的列表项将被显示。

我们可以为select元素设置一个 data-link 或 data-class 属性。 data-link 属性运行在点击列表项时打开一个动态链接。 data-class 属性可以为列表项自定义一个class。

CSS

所有demo的基本样式都定义在cs-select.css文件中。这里我们定义了select下拉菜单的基本样式,使它看起来有扁平化的效果。下面的CSS样式是border效果的select下拉菜单样式效果:

@font-face { font-family: 'icomoon'; src:url('../fonts/icomoon/icomoon.eot?-rdnm34'); src:url('../fonts/icomoon/icomoon.eot?#iefix-rdnm34') format('embedded-opentype'), url('../fonts/icomoon/icomoon.woff?-rdnm34') format('woff'), url('../fonts/icomoon/icomoon.ttf?-rdnm34') format('truetype'), url('../fonts/icomoon/icomoon.svg?-rdnm34#icomoon') format('svg'); font-weight: normal; font-style: normal;} p.cs-skin-border { background: transparent; font-size: 2em; font-weight: 700; max-width: 600px;} @media screen and (max-width: 30em) { .cs-skin-border { font-size: 1em; }} .cs-skin-border > span { border: 5px solid #000; border-color: inherit; transition: background 0.2s, border-color 0.2s;} .cs-skin-border > span::after,.cs-skin-border .cs-selected span::after { font-family: 'icomoon'; content: 'e000';} .cs-skin-border ul span::after { content: ''; opacity: 0;} .cs-skin-border .cs-selected span::after { content: 'e00e'; color: #ddd9c9; font-size: 1.5em; opacity: 1; transition: opacity 0.2s;} .cs-skin-border.cs-active > span { background: #fff; border-color: #fff; color: #2980b9;} .cs-skin-border .cs-options { color: #2980b9; font-size: 0.75em; opacity: 0; transition: opacity 0.2s, visibility 0s 0.2s;} .cs-skin-border.cs-active .cs-options { opacity: 1; transition: opacity 0.2s;} .cs-skin-border ul span { padding: 1em 2em; backface-visibility: hidden;} .cs-skin-border .cs-options li span:hover,.cs-skin-border li.cs-focus span { background: #f5f3ec;}以上是"如何使用SVG和CSS3制作select下拉菜单美化效果"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report