I have an HTML input range set up with a bunch of CSS changes to the appearance, and I was wondering if there was any way to make it smoothly change from wherever it is to where the user changes?
input[type=range] {
-webkit-appearance: none;
width: 100%;
height: 20px;
border-radius: 5px;
border: 1px solid;
background: none;
box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555 inset;
transition: 0.4s all ease-out;
outline: none;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 30px;
height: 30px;
background-color: #CCC;
border: solid 1px #333;
border-radius: 4px;
box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555 inset;
cursor: pointer;
transition: 0.4s all ease-out;
}
input[type=range]:hover {
background: rgba(255, 255, 255, 0.2);
box-shadow: 0px 0px 13px 0px #444, 0px 0px 20px 0px #444 inset;
}
input[type=range]:hover::-webkit-slider-thumb {
border: solid 1px #444;
box-shadow: 0px 0px 15px 0px #444, 0px 0px 20px 0px #444 inset;
}
input[type=range]:focus {
background: rgba(255, 255, 255, 0.4);
box-shadow: 0px 0px 18px 0px #333, 0px 0px 15px 0px #333 inset;
}
input[type=range]:focus::-webkit-slider-thumb {
border: solid 1px #333;
box-shadow: 0px 0px 22px 0px #333, 0px 0px 15px 0px #333 inset;
}
<input type="range" id="brightness_slider" value="90" step="1" min="30" max="100">
These are the things that affect the smoothness:
The width of the banner
The min/max range
The size of steps
So if you have:
1000px wide range input
0 - 1000 range
Step size of 1
Each step will be just 1px, and it will be quite smooth.
If you have:
1000px wide range input
0 -100 range
Step size of 25
It will snap between the allowable values, appearing less fluid.
This is really a feature of the interaction between your step size and your range, and provides useful feedback to the user on what values are acceptable.
I realize this is quite old at this point but the solution I came up with I found was pretty elegant and easy to do so I thought I would share it.
First I had an indexed scroller to make it easier. For example, I had an array of values like the following:
myArray = [0, 100, 1000, 10000, 100000]
I set my input range min to 0, max to the number of items in the array 4. Then I set the step to .01 to get smooth scrolling.
On the input event I did the following:
index = Math.round(event * 1);
value = myArray[index];
And that's basically it, as you scroll it will be smooth, and the values will change in between the ranges as you would expect.
Related
I would like to create an animation starting when my div's attribute changed using pure CSS.
The div's initial state is:
display: none;
Changing display attribute to a value unequal none,
a animation should be played (inner glow effect using an inset box shadow).
The change of the attribute can occour multiple times. After every change the animation
should be played.
Is this possible using pure css? Or do I need to use javascript additionally?
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.0);
animation-duration: 5s;
animation-name: card-appear;
#keyframes card-appear{
0% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.0);
}
10% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.2);
}
20% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.4);
}
30% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.6);
}
40% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.8);
}
50% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,1.0);
}
60% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.8);
}
70% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.6);
}
80% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.4);
}
90% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.2);
}
100% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.0);
}
}
I would like to ask how should I apply different colour glow to an image border when a user hover over? like say that in this JSFiddle file, I have a green thumb and a red thumb. I want each image border to glow according to the colour of the image, or any colour that I specify. How should I achieve that?
PS** For example purposes the image are converted to base64 in the JSFiddle.
This is how I do in my CSS
img{
width: 16px;
cursor: pointer;
padding: 10px;
}
img:hover{
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: inset 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
}
Thank You
If I understand your question then here is an example DEMO
img{
width: 48px;
cursor: pointer;
/*padding: 10px;*/
/* border:1px solid #fff;*/
margin-right: 20px;
}
img:hover{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
-moz-box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
}
img:last-of-type:hover{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
-moz-box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
}
As written in the comment, there is no way for HTML/CSS to determine the main color of the image displayed. If you know the predominant color of each image, give them class names accordingly and write the related CSS.
See demo for a simple version.
img.green:hover{
border-color: #66afe9;
box-shadow: 0 0 8px rgba(0,255,0, 0.6);
}
img.red:hover{
border-color: #66afe9;
box-shadow: 0 0 8px rgba(255,0,0, 0.6);
}
Change:
box-shadow: inset 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
to:
box-shadow: inset 0 0 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
DEMO
box-shadow Syntax:
Formal syntax: none | [inset? && [ <offset-x> <offset-y> <blur-radius>? <spread-radius>? <color>? ] ]#
Box shadow also worked for,
img:hover{ box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); }
If you want to more style in css
http://ianlunn.github.io/Hover/
or use your custom image like this
img:hover{background:url('http://www.addglitter.com/link-sparkle.gif');
I have this problem where I want to have a border and a box-shadow, but the shadow must be over the border.
The box-shadow property starts when the border ends, is it possible to move it over the border?
.border
{
border: solid rgba(128,42,42,.98) 16px;
}
.img-box-shadow
{
-moz-box-shadow: 0px 0px 20px #000000;
-webkit-box-shadow: 0px 0px 20px #000000;
box-shadow: 0px 0px 20px #000000;
}
My HTML:
<img class="border img-box-shadow" src="img.png">
Already tried inset in my box shadow, but it didn't work!
I'm looking for this effect:
And I'm getting this result:
I think this would be much more easily achieved with two overlayed box shadows
Something like this approaches what you're looking for
box-shadow: 0 0 20px 5px #000000,
0 0 0 16px rgba(128,42,42,.98);
Seem like you want an inset box shadow, then you can use:
box-shadow: inset 0 -15px 10px -10px #444;
-moz-box-shadow: inset 0 -15px 10px -10px #444;
-webkit-box-shadow: inset 0 -15px 10px -10px #444;
Fiddle Demo
How about this one?
.ds-bottom {
position:relative;
overflow:hidden;
border-bottom:1px solid #ddd;
}
.ds-bottom:before {
content: "";
position:absolute;
z-index: 1;
width:96%;
bottom: -10px;
height: 10px;
left: 2%;
border-radius: 100px / 5px;
box-shadow:0 0 18px rgba(0,0,0,0.6);
}
You can try using inset and then lowering the alpha value of your border. It may not exactly be what you want, but it's close.
.border
{
border: solid rgba(128,42,42,.5) 4px;
}
.img-box-shadow
{
-moz-box-shadow: inset 0px 0px 20px #000000;
-webkit-box-shadow: inset 0px 0px 20px #000000;
box-shadow: inset 0px 0px 20px #000000;
}
Alternate option (borrowed from this question). Don't use the .border and just use this (you can play around with pixel values):
.img-box-shadow
{
box-shadow: rgba(0,0,0,.98) 0px 0px 3px, inset rgba(0,0,0,.98) 0px -2px 3px;
}
Here's a JSFiddle
First, you have mistake in box shadow format.
box-shadow: 0px 0px 20px #000000;
Change to
box-shadow: 0px 0px 20px 0 #000000;
Due to the right format of Box Shadow Properties
box-shadow: horizontal-length vertical-length blur-radius
spread-radius;
Next, to make it works with your requirement you must wrap your image inside div. Box-shadow wont works over border.
Here's the style
div {
display:inline-block;
padding:4px; /* Act as border width */
background:rgba(128,42,42,.98); /* Act as border color */
}
.img-box-shadow
{
box-shadow: inset 0px 0px 20px 0 #000000;
-webkit-box-shadow: inset 0px 0px 20px 0 #000000;
-moz-box-shadow: inset 0px 0px 20px 0 #000000;
}
And the HTML Markup
<div class="img-box-shadow">
<img src="http://graph.facebook.com/715380382/picture?type=large">
</div>
Check live demo http://jsbin.com/hex/1/edit
Here's the code I got from a css button generator I was wondering how to make them all the same size instead of the button adjusting to the text length.
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #ffffff;
padding: 10px 20px;
background: -moz-linear-gradient(
top,
#42aaff 0%,
#003366);
background: -webkit-gradient(
linear, left top, left bottom,
from(#42aaff),
to(#003366));
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
border: 1px solid #003366;
-moz-box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
inset 0px 0px 1px rgba(255,255,255,0.5);
-webkit-box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
inset 0px 0px 1px rgba(255,255,255,0.5);
box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
inset 0px 0px 1px rgba(255,255,255,0.5);
text-shadow:
0px -1px 0px rgba(000,000,000,0.7),
0px 1px 0px rgba(255,255,255,0.3);
}
Just give them all a fixed width according to your largest content.
You can either do it with fixed px or percentage. But the trick is to then do text-align:center and also I'd throw them into a list:
http://codepen.io/anon/pen/CfjcG
well... you need to make an element out of it, that code is to just give you the effects you need for whatever you designed on the button creator, you need to apply it to an element that has a specific size.. for example
.buttons{
width:60px;
height:30px;
float:left;
(all the button stuff)
}
if you want it a different size just change the value of the width and height... this should do it.. let me know if it works.. :)
i have a line of width: 15px; and height of 2px;
my question is, how to create the shadow only on right and left side?
This fiddle has examples showing shadows only on:
Top and bottom
Left and right
Top
With that you should be able to do any kind of shadow.
http://jsfiddle.net/rafaelchiti/5jdHW/
The code:
div {
margin-top: 20px;
margin-left: 20px;
width: 100px;
height: 100px;
}
.horizontal {
box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset,
0px -15px 10px -11px rgba(0, 0, 0, .1) inset;
}
.vertical {
box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset,
0px -15px 10px -11px rgba(0, 0, 0, .1) inset;
}
.one-side {
box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset;
}
Hope this help.
Try this (based on the link you gave in your comment above):
box-shadow: 2px 2px 5px 2px rgba(0, 0, 0, 1);
-webkit-box-shadow: 2px 2px 5px 2px rgba(0, 0, 0, 1);
You can tweak it to how you like it using the CSS3 Generator
CSS Box Shadow
Add the following class to apply shadow. Check this jsfiddle example
.shadow {
-moz-box-shadow: 3px 3px 10px 1px #000;
-webkit-box-shadow: 3px 3px 10px 1px #000;
box-shadow: 3px 3px 10px 1px #000;
}
The horizontal offset of the shadow, positive means the shadow will
be on the right of the box, a negative offset will put the shadow on
the left of the box.
The vertical offset of the shadow, a negative one means the
box-shadow will be above the box, a positive one means the shadow
will be below the box.
The blur radius (optional), if set to 0 the shadow will be sharp,
the higher the number, the more blurred it will be.
The spread radius (optional), positive values increase the size of
the shadow, negative values decrease the size. Default is 0 (the
shadow is same size as blur).
Color Hexadecimal color value.
.box {
height: 150px;
width: 300px;
margin: 20px;
border: 1px solid #ccc;
}
.top {
box-shadow: 0 -5px 5px -5px #333;
}
.right {
box-shadow: -5px 0 5px -5px #333;
}
.bottom {
box-shadow: 0 5px 5px -5px #333;
}
.left {
box-shadow: 5px 0 5px -5px #333;
}
.all {
box-shadow: 0 0 5px #333;
}
in the body put..
<div class="box top"></div>
<div class="box right"></div>
<div class="box bottom"></div>
<div class="box left"></div>
<div class="box all"></div>