代码之家  ›  专栏  ›  技术社区  ›  NAVIN

如何设置CSS的选择及其下拉菜单时,选择[[副本]

  •  3
  • NAVIN  · 技术社区  · 7 年前

    select 标签。然而,点击这个标签边框颜色将从绿色变为蓝色,文本颜色将从绿色变为黑色。试图找出CSS实现的点击,但没有用。在inspect元素上可以看到的只是某个事件在上处于活动状态 选择 . 试图添加我自己的事件点击和改变CSS回来,但无法实现。

    CSS格式:

    .customSelect {
        border-radius: 1.25rem;
        height: calc(5.25rem + 2px);
        font-size: 3rem;
        color: #00a082;
        border: 3px solid #cbece5;
    }
    

    尝试在自定义click事件上添加相同的类,但是其他东西正在替换我的CSS。

    $("#selectId").click( () => {
        $("#selectId").addClass('customSelect');
    });
    

    如何添加自定义CSS 标签上也有 option

    编辑 为什么不给我一个复制品呢 how-to-style-the-option-of-a-html-select

    我的问题不是风格 但是为了阻止我 选择 框从改变边框颜色为蓝色,就像我们点击 或在 input

    4 回复  |  直到 7 年前
        1
  •  1
  •   NAVIN    7 年前

    我想出来了。选择蓝色,然后单击“上一步” 输入 , 选择 文本区域 标签是由于 独自创立 CSS。删除了类 form-control 选择

    CSS格式:

    /* Customized Select Box */
    .customSelect {
        background-color: #fff;
        background-clip: padding-box;
        border: 0.5rem solid #cbece5;
        border-radius: 1.25rem;
        color: #00a082;
        display: block;
        font-size: 2rem;
        height: 3.5rem;
        line-height: 1.5;
        padding: 0.25rem 0.75rem;
        width: 100%;
        transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
        transition-property: border-color, box-shadow;
        transition-duration: 0.15s, 0.15s;
        transition-timing-function: ease-in-out, ease-in-out;
        transition-delay: 0s, 0s;
    }
    
        2
  •  0
  •   AutoTurtle    7 年前

    您可能需要自己构建一个,因为访问select元素的各个元素非常复杂。我希望有人能提供一个更好的答案,但万一没有:W3学校有一个文件化的方法,这是相当沉重的。

    https://www.w3schools.com/howto/howto_custom_select.asp

    (抱歉链接;(已编辑)

        3
  •  0
  •   Jake    7 年前

    在您的情况下,您可以使用:

    .customSelect:hover

    .customSelect:active

    .customSelect:focus 将样式指定给键盘目标元素或鼠标激活的元素。

    这将是一个单独的风格,原来的 .customSelect 像这样:

    .customSelect {
      border-radius: 1.25rem;
      height: calc(5.25rem + 2px);
      font-size: 3rem;
      color: #00a082;
      border: 3px solid #cbece5;
    }
    
    .customSelect:hover {
      new-styles: new value;
    }
    

    .customSelect:hover, .customSelect:active {
      style-to-apply-to-both: value;
    }
    

    在此处了解有关选择器的更多信息: https://www.w3schools.com/cssref/sel_hover.asp

        4
  •  0
  •   Rafael    7 年前

    :active :hover

    enter image description here