Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 选择::-ms展开{ 显示:无;/*删除Internet Explorer 10和11中的默认箭头*/ } /*以Internet Explorer 9为目标撤消自定义箭头*/ @媒体屏幕和(最小宽度:0\0){ 挑选{ 背景:无\9; 填充:5px\9; } } 苹果 菠萝 巧克力 烙饼_Html_Css_Combobox_Cross Browser_Skinning - Fatal编程技术网

Html 选择::-ms展开{ 显示:无;/*删除Internet Explorer 10和11中的默认箭头*/ } /*以Internet Explorer 9为目标撤消自定义箭头*/ @媒体屏幕和(最小宽度:0\0){ 挑选{ 背景:无\9; 填充:5px\9; } } 苹果 菠萝 巧克力 烙饼

Html 选择::-ms展开{ 显示:无;/*删除Internet Explorer 10和11中的默认箭头*/ } /*以Internet Explorer 9为目标撤消自定义箭头*/ @媒体屏幕和(最小宽度:0\0){ 挑选{ 背景:无\9; 填充:5px\9; } } 苹果 菠萝 巧克力 烙饼,html,css,combobox,cross-browser,skinning,Html,Css,Combobox,Cross Browser,Skinning,这为选择的元素使用了背景色,我删除了图像。一个非常好的例子,它使用了:after和:before来实现这个技巧,从Internet Explorer 10开始,您可以使用伪元素选择器来设置下拉箭头元素的样式并隐藏它 select::-ms-expand { display:none; /* or visibility: hidden; to keep it's space/hitbox */ } 其余的样式应该与其他浏览器类似 仅CSS和HTML的解决方案 它似乎与Chrome

这为选择的元素使用了背景色,我删除了图像。

一个非常好的例子,它使用了
:after
:before
来实现这个技巧,从Internet Explorer 10开始,您可以使用伪元素选择器来设置下拉箭头元素的样式并隐藏它

select::-ms-expand {
    display:none;
    /* or visibility: hidden; to keep it's space/hitbox */
}
其余的样式应该与其他浏览器类似


仅CSS和HTML的解决方案

它似乎与Chrome、Firefox和InternetExplorer11兼容。但请留下您对其他网络浏览器的反馈

正如所建议的,我将select封装在一个div中(为了x-browser兼容性,甚至两个div)以获得预期的行为

HTML:


我确实有这个问题,只是我不能使用图像,而且不受浏览器支持的限制。这应该是«按规格»,幸运的话,最终开始在任何地方工作

它使用分层旋转背景层来“剪切”下拉箭头,因为伪元素不适用于选择元素

编辑:在这个更新版本中,我使用CSS变量和一个小型主题系统

:根目录{
--半径:2px;
--baseFg:浅灰色;
--baseBg:白色;
--重音fg:#006fc2;
--埃森伯格:#bae1ff;
}
.主题粉红{
--半径:2米;
--baseFg:#c70062;
--baseBg:#ffe3f1;
--accentFg:#c70062;
--口音:#ffaad4;
}
三、主题建设{
--半径:0;
--baseFg:白色;
--baseBg:黑色;
--重音fg:黑色;
--口音背景:橙色;
}
挑选{
字体:40012px/1.3无衬线;
-webkit外观:无;
外观:无;
颜色:var(--baseFg);
边框:1px实心变量(--baseFg);
线高:1;
大纲:0;
填充:0.65em 2.5em 0.55em 0.75em;
边界半径:var(--半径);
背景色:var(--baseBg);
背景图像:线性梯度(var(--baseFg),var(--baseFg)),
线性梯度(-135度,透明50%,var(-accentBg)50%),
线性梯度(-225deg,透明50%,var(-accentBg)50%),
线性梯度(var(--accentBg)42%,var(--accentFg)42%);
背景重复:不重复,不重复,不重复,不重复;
背景尺寸:1px100%,20px22px,20px22px,20px100%;
背景位置:右20px中心,右下,右下,右下;
}
选择:悬停{
背景图像:线性渐变(var(--accentFg),var(--accentFg)),
线性梯度(-135度,透明50%,var(-50%),
线性梯度(-225deg,透明50%,var(-accentFg)50%),
线性梯度(var(--accentFg)42%,var(--accentBg)42%);
}
选择:活动{
背景图像:线性渐变(var(--accentFg),var(--accentFg)),
线性梯度(-135度,透明50%,var(-50%),
线性梯度(-225deg,透明50%,var(-accentFg)50%),
线性梯度(var(--accentFg)42%,var(--accentBg)42%);
颜色:var(--accentBg);
边框颜色:var(--accentFg);
背景色:var(--accentFg);
}

这么多选择
...
这么多选择
...
这么多选择
...
可以改进中的第三种方法,以处理悬停效果和其他鼠标事件。只需确保“button”元素正好位于标记中的select元素之后。然后使用+CSS选择器将其作为目标:

HTML:
。。。
CSS:
。选择输入:悬停+。选择按钮{
}
但是,当鼠标悬停在select元素上的任意位置时,而不仅仅是在“按钮”上,这将显示悬停效果

我将此方法与Angular(因为我的项目恰好是Angular应用程序)结合使用,以覆盖整个select元素,并让Angular在“button”-元素中显示所选选项的文本。在这种情况下,将鼠标悬停在“选择”按钮上的任意位置时,应用悬停效果是非常有意义的


但是,没有JavaScript它是无法工作的,因此如果您想这样做,并且您的站点必须在没有JavaScript的情况下工作,那么您应该确保您的脚本添加了增强所需的元素和类。这样,没有JavaScript的浏览器只会得到一个普通的、未设置样式的select,而不是一个无法正确更新的已设置样式的徽章。

以下是一个基于本次讨论中我最喜欢的想法的解决方案。这允许在不使用任何附加标记的情况下直接设置元素的样式

它在InternetExplorer10(及更高版本)中工作,并为InternetExplorer8/9提供了安全的后备。这些浏览器的一个警告是,背景图像必须定位,并且足够小,以隐藏在本机扩展控件后面

HTML 代码笔
这是一个适用于所有现代浏览器的版本。该键使用
外观:无
,删除默认格式。由于所有的格式都消失了,您必须在箭头中添加回去,以便在视觉上区分选择和输入

工作示例:

select:not([多个]){
-webkit外观:无;
-moz外观:无;
背景位置:右50%;
背景重复:无重复;
背景图片:url数据:图像/png;Bas64,IvBorwwwwwwwwww数据(数据:数据:数据:图像/png;Bas64,基础64,IvBoBorwww7,数据数据:图像/数据:图像/巴巴巴巴巴巴新;基础64,IvBorwwwwwwwwwwwwwwwwwwww2-2-wwww2-2-2-wwwwww2-2-2-2-2-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww8-www8-2-2-w8-w8-www8-8-w8-w8-8-8-8-8-8-8-8-8-8-8-8-2-8-8-8-8-8-8-5-5-5-5-8-8-0xNzozMjowMcAgicagicJ4GpHjKzJpSreyGeg1SbNm6CmRmPsJodRwoi8Vd3LnczLm9YZy8OtK5LzaylZy1Zew50YxGbNjJ4GpHjKzJpXnjCmLwDgLwDgLwDgBibyZy6YWwJvDg1Wb6Eg1Wp1Ww9Ww9WpHc8Hc8LhCc8LlJaviiIbBwBbxUc2BwXczBwCc4BxBzBzBwCbWc2BzBzBzBbWc2
<select class="important">
  <option>Important Option</option>
  <option>Another Important Option</option>
</select>

<style type="text/css">
  .important {
    font-weight: bold;
  }
</style>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>Select Styling</title>
  <link href="selectExample.css" rel="stylesheet">
</head>
<body>
<select id="styledSelect" class="blueText">
  <option value="apple">Apple</option>
  <option value="orange">Orange</option>
  <option value="cherry">Cherry</option>
</select>
</body>
</html>
/* All select elements on page */
select {
  position: relative;
}

/* Style by class. Effects the text of the contained options. */
.blueText {
  color: #0000FF;
}

/* Style by id. Effects position of the select drop down. */
#styledSelect {
  left: 100px;
}
select  {
    outline: 0;
    overflow: hidden;
    height: 30px;
    background: #2c343c;
    color: #747a80;
    border: #2c343c;
    padding: 5px 3px 5px 10px;
    -moz-border-radius: 6px;
    -webkit-border-radius: 6px;
    border-radius: 10px;
}

select option {border: 1px solid #000; background: #010;}
select {
  -webkit-appearance: none;
}
select {
    -webkit-appearance: button;
    -moz-appearance: button;
    -webkit-user-select: none;
    -moz-user-select: none;
    -webkit-padding-end: 20px;
    -moz-padding-end: 20px;
    -webkit-padding-start: 2px;
    -moz-padding-start: 2px;
    background-color: #F07575; /* Fallback color if gradients are not supported */
    background-image: url(../images/select-arrow.png), -webkit-linear-gradient(top, #E5E5E5, #F4F4F4); /* For Chrome and Safari */
    background-image: url(../images/select-arrow.png), -moz-linear-gradient(top, #E5E5E5, #F4F4F4); /* For old Firefox (3.6 to 15) */
    background-image: url(../images/select-arrow.png), -ms-linear-gradient(top, #E5E5E5, #F4F4F4); /* For pre-releases of Internet Explorer  10*/
    background-image: url(../images/select-arrow.png), -o-linear-gradient(top, #E5E5E5, #F4F4F4); /* For old Opera (11.1 to 12.0) */
    background-image: url(../images/select-arrow.png), linear-gradient(to bottom, #E5E5E5, #F4F4F4); /* Standard syntax; must be last */
    background-position: center right;
    background-repeat: no-repeat;
    border: 1px solid #AAA;
    border-radius: 2px;
    box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1);
    color: #555;
    font-size: inherit;
    margin: 0;
    overflow: hidden;
    padding-top: 2px;
    padding-bottom: 2px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
select {
   -webkit-appearance: none;
   -moz-appearance: none;
   appearance: none;       /* Remove default arrow */
   background-image: url(...);   /* Add custom arrow */
}
select::-ms-expand {
    display: none; /* Hide the default arrow in Internet Explorer 10 and Internet Explorer 11 */
}
/* Target Internet Explorer 9 to undo the custom arrow */
@media screen and (min-width:0\0) {
    select {
        background-image:none\9;
        padding: 5px\9;
    }
}
label {
    position: relative;
    display: inline-block;
}
select {
    display: inline-block;
    padding: 4px 3px 5px 5px;
    width: 150px;
    outline: none;
    color: black;
    border: 1px solid #C8BFC4;
    border-radius: 4px;
    box-shadow: inset 1px 1px 2px #ddd8dc;
    background-color: lightblue;
}
select::-ms-expand {
    display:none;
    /* or visibility: hidden; to keep it's space/hitbox */
}
<div class="sort-options-wrapper">
    <div class="sort-options-wrapper-2">
        <select class="sort-options">
                <option value="choiceOne">choiceOne</option>
                <option value="choiceOne">choiceThree</option>
                <option value="choiceOne">choiceFour</option>
                <option value="choiceFiveLongTestPurpose">choiceFiveLongTestPurpose</option>
        </select>
    </div>
    <div class="search-select-arrow-down"></div>
</div>
.sort-options-wrapper {
    display: inline-block;
    position: relative;
    border: 1px solid #83837F;
}

/* This second wrapper is needed for x-browser compatibility */
.sort-options-wrapper-2 {
    overflow: hidden;
}

select {
    margin-right: -19px; /* That's what is hiding the default-provided browser arrow */
    padding-left: 13px;
    margin-left: 0;
    border: none;
    background: none;

    /* margin-top & margin-bottom must be set since some
       browsers have default values for select elements */
    margin-bottom: 1px;
    margin-top: 1px;
}

select:focus {
    outline: none; /* Removing default browsers outline on focus */
}
.search-select-arrow-down {
    position: absolute;
    height: 10px;
    width: 12px;
    background: url(http://i.imgur.com/pHIYN06.png) scroll no-repeat 2px 0px;
    left: 1px;
    top: 5px;
}
<select class="select-input">...</select>
<div class="select-button"></div>
.select-input:hover+.select-button {
    <Hover styles here>
}
<select name='options'>
  <option value='option-1'>Option 1</option>
  <option value='option-2'>Option 2</option>
  <option value='option-3'>Option 3</option>
</select>
body {
  padding: 4em 40%;
  text-align: center;
}

select {
  $bg-color: lightcyan;
  $text-color: black;
  appearance: none; // Using -prefix-free http://leaverou.github.io/prefixfree/
  background: {
    color: $bg-color;
    image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/1255/caret--down-15.png");
    position: right;
    repeat: no-repeat;
  }
  border: {
    color: mix($bg-color, black, 80%);
    radius: .2em;
    style: solid;
    width: 1px;
    right-color: mix($bg-color, black, 60%);
    bottom-color: mix($bg-color, black, 60%);
  }
  color: $text-color;
  padding: .33em .5em;
  width: 100%;
}

// Removes default arrow for Internet Explorer 10 (and later)
// Internet Explorer 8/9 gets the default arrow which covers the caret
// image as long as the caret image is smaller than and positioned
// behind the default arrow
select::-ms-expand {
    display: none;
}
<style>

    .stylish span   {position:relative;}
    .stylish select {position:absolute;left:0px;display:none}

</style>
...
<div class="stylish">
    <label> Choose your superhero: </label>
    <span>
        <input onclick="$(this).closest('div').find('select').slideToggle(110)"><br>
        <select size=15 onclick="$(this).hide().closest('div').find('input').val($(this).find('option:selected').text());">

            <optgroup label="Fantasy"></optgroup>
            <option value="1">  Gandalf        </option>
            <option value="2">  Harry Potter   </option>
            <option value="3">  Jon Snow       </option>

            <!-- ... and so on -->

        </select>
    </span>
</div>