HerrGanzorig
HerrGanzorig

Reputation: 51

How to select a button beside the gradient filter

I met a project that set the gradient filter to whole web page.
So I have implemented the filter like this.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;
}

But the problem is button is not selectable in this case. I have no sense how to make the button work. How can I make button selectable and also show gradient above the button?

Finally UI should look like this.
enter image description here

Upvotes: 0

Views: 58

Answers (3)

Rahul
Rahul

Reputation: 2071

Check the fiddle. You have two issue 1. set button attribute type="button" and 2. .tag z-index should be 1. Because your button is absolute position.

UPDATE

I Update the fiddle. I think it will help you.

Upvotes: 0

Ismail Farooq
Ismail Farooq

Reputation: 6837

its seems you are looking for pointer-events: none;

Demo http://jsfiddle.net/r6tdc3Lh/5/

Upvotes: 1

J4R
J4R

Reputation: 1104

a </div> tag is missing. At the end of ur code.

Ur container isnt closing, so your button cant‘t be clicked.

Try to add just another closing tag.

Upvotes: 0

Related Questions