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

如何选择渐变过滤器旁边的按钮

  •  0
  • HerrGanzorig  · 技术社区  · 7 年前

    我遇到了一个项目,该项目将梯度过滤器设置为整个网页。
    所以我实现了这样的过滤器。 jsfiddle

    HTML

    <div class="container">
       <button class="tag">Featured</button>
       <div id="grad1">
    </div>
    

    CSS

    #grad1 {
        height: 200px;
        background: red; /* For browsers that do not support gradients */
        background: -webkit-linear-gradient(red, yellow); /* For Safari 5.1 to 6.0 */
        background: -o-linear-gradient(red, yellow); /* For Opera 11.1 to 12.0 */
        background: -moz-linear-gradient(red, yellow); /* For Firefox 3.6 to 15 */
        background: linear-gradient(red, yellow); /* Standard syntax (must be last) */
        opacity: 0.5;
    }
    .container {
       border: 1px solid #DDDDDD;
       width: 200px;
       height: 200px;
       position: relative;
    }
    .tag {
       float: left;
       position: absolute;
       left: 0px;
       top: 0px;
       background-color: #92AD40;
       padding: 5px;
       color: #FFFFFF;
       font-weight: bold;
    }
    

    但问题是,在这种情况下,按钮不可选择。 我不知道如何使这个按钮工作。 如何使按钮可选,并在按钮上方显示渐变?

    最后,UI应该是这样的。
    enter image description here

    3 回复  |  直到 7 年前
        1
  •  1
  •   Ismail Farooq    7 年前

    看起来你在找 pointer-events: none;

    演示 http://jsfiddle.net/r6tdc3Lh/5/

        2
  •  0
  •   J4R    7 年前

    </div> 在ur代码的末尾。

    您的容器未关闭,因此无法单击您的按钮。

    尝试只添加另一个结束标记。

        3
  •  0
  •   Rahul    7 年前

    检查 fiddle . 你有两个问题1。设置 button attribute type="button" 和2。 .tag z-index 应该是 1 . 因为你的 按钮 absolute 位置

    更新

    我更新了 fiddle . 我认为这对你有帮助。