DrS.
DrS.

Reputation: 67

CSS for Button shine effect with an Input element

I want a shine effect on my button which originally is an html input element (I don't want to change that). I have made a bootply but don't know how to get it the right way.

/* CSS used here will be applied after bootstrap.css */
body{ 
    background: #888;
}

span.button {
    width: 100%;
    height: 50px;
    /*background: #333;*/
    display: block;
    position: relative;
    margin: 50px auto 0;
    overflow: hidden;
    /*border: 1px solid #333333;*/
    /*color: white;*/
    text-decoration: none;
    
    -webkit-box-shadow: inset 0px 1px 1px 0px rgba(255,255,255,.4);
    -moz-box-shadow: inset 0px 1px 1px 0px rgba(255,255,255,.4);
    box-shadow: inset 0px 1px 1px 0px rgba(255,255,255,.4);
    
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    
    
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -ms-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    transition: all 0.2s ease;
    
    background-color: hsl(131, 100%, 5%) !important;
    background-repeat: repeat-x;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#3CCC77", endColorstr="#00190B");
    background-image: -khtml-gradient(linear, left top, left bottom, from(#3CCC77), to(#00190B));
    background-image: -moz-linear-gradient(top, #3CCC77, #00190B);
    background-image: -ms-linear-gradient(top, #3CCC77, #00190B);
    background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #3CCC77), color-stop(100%, #00190B));
    background-image: -webkit-linear-gradient(top, #3CCC77, #00190B);
    background-image: -o-linear-gradient(top, #3CCC77, #00190B);
    background-image: linear-gradient(#3CCC77, #00190B);
    border-color: #00190B #00190B hsl(131, 100%, -10%);
    color: #fff !important;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.99);
    -webkit-font-smoothing: antialiased;
}

span.button span.text {
    position: absolute;
    top: 16px;
    left: 65px;
    font: 15px Arial;
}

span.button span.shine {
    content: '';
    position: absolute;
    height: 1000px;
    width: 5px;
    background: white;
    top: -500px;
    left: -80px;
    display: block;
    opacity: 0.8;
    
    -webkit-box-shadow: 0px 0px 20px 10px white; 
    -moz-box-shadow: 0px 0px 20px 10px white; 
    box-shadow: 0px 0px 20px 10px white; 
    
    -webkit-transform: rotate(-45deg);  
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    transform: rotate(-45deg);
    
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -ms-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
}

span.button:hover {
    -webkit-box-shadow: inset 0px 1px 10px 0px rgba(255,255,255,.4), 0px 3px 3px 0px rgba(0,0,0,0.4);
    -moz-box-shadow: inset 0px 1px 10px 0px rgba(255,255,255,.4), 0px 3px 3px 0px rgba(0,0,0,0.4);
    box-shadow: inset 0px 1px 10px 0px rgba(255,255,255,.4), 0px 3px 3px 0px rgba(0,0,0,0.4);
}

span.button:active {
    -webkit-box-shadow: inset 0px 1px 15px 0px rgba(0,0,0,.4), inset 0px 1px 1px 1px rgba(0,0,0,.2), 0px 1px 1px 0 rgba(255,255,255,.5);
    -moz-box-shadow: inset 0px 1px 15px 0px rgba(0,0,0,.4), inset 0px 1px 1px 1px rgba(0,0,0,.2), 0px 1px 1px 0 rgba(255,255,255,.5);
    box-shadow: inset 0px 1px 15px 0px rgba(0,0,0,.4), inset 0px 1px 1px 1px rgba(0,0,0,.2), 0px 1px 1px 0 rgba(255,255,255,.5);
}

span.button:hover span.shine {
    left: 2000px;
    top: -300px;
}
<span class="button">
    <span class="shine"></span>
  
    <span class="text"><input class="btn btn-block" type="submit" name="submit" value="YES - YES - YES" /></span>
  
</span>

Bootply

Colors and everything is right already. And the effect is working fine. But the Input element should be one with the button as a whole. I have tried to reposition the html input element anywhere else within the button span, but that only makes everything worse.

Any help is highly appreciated. Many thanks.

Upvotes: 1

Views: 245

Answers (1)

TeT Psy
TeT Psy

Reputation: 341

From what i see, you just need to add that css to the input itself, otherwise remove the background style from the input and make it's width and height 100% to fit the parent that is styled.

Upvotes: 2

Related Questions