CSS - 使用 SELECT 标签时下拉框的边框半径?不是 SELECT 输入本身,实际的下拉框?

2023-07-31前端开发问题
7

本文介绍了CSS - 使用 SELECT 标签时下拉框的边框半径?不是 SELECT 输入本身,实际的下拉框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试设置选择下拉框的样式.

I am trying to style a select drop down box.

到目前为止,我通过将某些样式应用于选择标签,在下拉框本身(带有选项的下拉框)内实现了样式效果.

So far, I have achieved a styled effect within the drop down box itself (the box that drops down with the options) by applying certain styles to the select tag.

这是我目前使用的css:

Here is the css I have used so far:

input, select {
    background: #fcfcfc;
    padding: 7px 25px;
    border: 0 none;
    font: bold 12px Arial,Helvetica,Sans-serif;
    color: #6a6f75;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); 
    -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    -moz-box-shadow: , 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    -webkit-background-clip: padding-box;
    -webkit-transition: all 0.7s ease-out 0s;  /* Saf3.2+, Chrome */
    -moz-transition: all 0.7s ease-out 0s;  /* FF4+ */
    -ms-transition: all 0.7s ease-out 0s;  /* IE10? */
    -o-transition: all 0.7s ease-out 0s;  /* Opera 10.5+ */
    transition: all 0.7s ease-out 0s;
}

select {
    padding: 7px 10px;
}

input:focus, select:focus
{
    background: #6699cc;
    color: #e7f3ff;
    text-shadow:
        -1px -1px 0 #666,
        1px -1px 0 #666,
        -1px 1px 0 #666,
        1px 1px 0 #666;
    -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
}

此 css 适用于特定页面中的 INPUT 和 SELECT 标记.

This css applies to the INPUT and SELECT tags found within a specific page.

现在,这确实为焦点事件上的下拉框设置样式,背景转换为蓝色(在 Firefox 中有效)我想做的是向下拉框添加一个弯曲的边框,以便它融合更多的是选择输入本身.

Now, this does style the drop down box on the focus event, with the background transforming to blue (works in Firefox) What I want to do though, is add a curved border to the drop down box, so that it blends in more with the select input itself.

这将实现类似这样的效果:

This will achieve an effect something like this:

( Choose )
( Option )
| Option |
( Option )

与此相比(请原谅我的粗略示例):

In comparison to this (please forgive my crude examples):

( Choose )
| Option |
| Option |
| Option |

我不知道这是否可能,因为我应用于 select 标签的背景样式正在生效,但边框半径样式仅应用于 SELECT 输入本身而不是下拉框.

I don't know if this is even possible yet, as the background styles I have applied to the select tag are coming into effect, but the border radius styles are only applied to the SELECT input itself and not the drop down box.

有没有这方面知识比较多的人,请花几分钟给我指点一下?

Would someone with some more knowledge in this regard, please take a few minutes to enlighten me?

是否可以为下拉框添加弧形边框,还是只能使用弧形边框设置 SELECT 输入的样式?

Is it possible to add a curved border to the drop down box, or is it only possible to style the SELECT input with a curved border?

推荐答案

你将无法实现这种 SELECT DROPDOWN 样式,使用标准的 HTML 表单元素,你必须用 DIV 非表单替换"下拉/选择元素,然后将所选值更新为隐藏的表单元素或隐藏的选择下拉菜单.

You will not be able to achieve this SELECT DROPDOWN style, with standard HTML form elements, you would have to 'substitute' the dropdown / select with DIV non form elements, then update the selected value to either a hidden form element or a hidden select dropdown.

如果你以你想要的方式得到它,它就不会跨浏览器兼容.

If you got it somewhat that way you wanted, it would not be cross-browser compatible.

这里是一个 jQuery 替代示例:https://stackoverflow.com/a/8450718/158014

An example of a jQuery substitute is here: https://stackoverflow.com/a/8450718/158014

这篇关于CSS - 使用 SELECT 标签时下拉框的边框半径?不是 SELECT 输入本身,实际的下拉框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

layui 单选框、复选框、下拉菜单不显示问题如何解决?
1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
2024-11-09 前端开发问题
313

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

jQuery怎么动态向页面添加代码?
append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href...
2024-10-18 前端开发问题
125

CoffeeScript 总是以匿名函数返回
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)...
2024-04-20 前端开发问题
13

getFullYear 在一年的第一天返回前一年
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)...
2024-04-20 前端开发问题
6

如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?
How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社...
2024-04-20 前端开发问题
6