Box-shadow inner glow with inset - css

I have been trying to apply glow with CSS box-shadow property (tried inset) on hover. So far, I have been able to do this with inset - http://jsfiddle.net/bgGS6 (hover over list item to see the effect).
Test code:
HTML:
<ul>
<li>
home
</li>
</ul>
CSS:
ul {
list-style:none;
}
li {
width:50px;
height:25px;
background:black;
color:white;
font-size:1.25em;
padding:10px;
}
li:hover {
box-shadow: inset 0 9px 10px 0px #00abe3;
}
I'm trying to achieve something like this:
I'm wondering if it will be possible to increase glow toward the center and fade it out towards the edges. I assume ultimate solution will be to add a png on hover, but want to find out if this can be achieved with CSS alone.
Update: Added radial gradient to top and it is pretty close to what I need - http://jsfiddle.net/bgGS6/5 Will add rules for cross-browser compatibility as well.
It flickers because of transition, not sure how to fix that. Any suggestions?

You can simply chain your shadows, thus:
box-shadow: inset 0 3px 3px 0px #fff,inset 0 9px 10px 0px #00abe3;
Demo Fiddle
What this does is add an initial inset box shadow with the same colour as the background (in this case just white) to make it look like the element is faded at the edges, before applying your highlighing box shadow- with larger pixel distances defined.

just as a note, you should structure your html like this:
<ul>
<li>
<a>Home</a>
</li>
</ul>
The following is css to create a blue effect, and you can probably customize it to your liking but you can get the basic gist of it:
ul li a{
background-color: #759ae9;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #759ae9), color-stop(50%, #376fe0), color-stop(50%, #1a5ad9), color-stop(100%, #2463de));
background-image: -webkit-linear-gradient(top, #759ae9 0%, #376fe0 50%, #1a5ad9 50%, #2463de 100%);
background-image: -moz-linear-gradient(top, #759ae9 0%, #376fe0 50%, #1a5ad9 50%, #2463de 100%);
background-image: -ms-linear-gradient(top, #759ae9 0%, #376fe0 50%, #1a5ad9 50%, #2463de 100%);
background-image: -o-linear-gradient(top, #759ae9 0%, #376fe0 50%, #1a5ad9 50%, #2463de 100%);
background-image: linear-gradient(top, #759ae9 0%, #376fe0 50%, #1a5ad9 50%, #2463de 100%);
border-top: 1px solid #1f58cc;
border-right: 1px solid #1b4db3;
border-bottom: 1px solid #174299;
border-left: 1px solid #1b4db3;
border-radius: 4px;
-webkit-box-shadow: inset 0 0 2px 0 rgba(57, 140, 255, 0.8);
box-shadow: inset 0 0 2px 0 rgba(57, 140, 255, 0.8);
color: #fff;
font: bold 12px/1 "helvetica neue", helvetica, arial, sans-serif;
padding: 7px 0;
text-shadow: 0 -1px 1px #1a5ad9;
width: 150px;
}
As a further note, please check out some tutorials on CSS3. There are plenty out there that could help you get a more broad idea of the tools you have to play with to achieve what you need. A good place to start would be Codeacademy.com They have a pretty good tutorial on CSS3

You could add a :before pseudo-element which has a box-shadow;
li {
width:50px;
height:25px;
background:black;
color:white;
font-size:1.25em;
padding:10px;
position: relative;
}
li:hover {
box-shadow: inset 0 9px 10px 0px #00abe3;
}
li:hover:before {
position: absolute;
width: 10px;
height: 2px;
background: rgba(255, 255, 255, 0.4);
content:' ';
left: 30px;
top: 1px;
box-shadow: 0 3px 7px 5px rgba(255, 255, 255, 0.4);
}
See this fiddle

Related

Skew GradientBackground Whitespace

It's hard to see but on the INSIDE of the Border, left and right side only of the skewed rectangle, there is whitespace which is only there if I have a gradient background
https://imgur.com/a/fDcD8bi
my css:
padding: 50px 0;
margin: 0;
border-radius: 15px;
border-radius: 0;
border: 4px solid #717171;
transform: skewX(352deg);
box-shadow: -5px 10px 10px 0px #0b0b0b2b;
cursor: pointer;
background: rgb(41,41,41);
background: -moz-linear-gradient(15deg, rgba(41,41,41,1) 0%, rgba(59,59,59,1) 100%);
background: -webkit-linear-gradient(15deg, rgba(41,41,41,1) 0%, rgba(59,59,59,1) 100%);
background: linear-gradient(15deg, rgba(41,41,41,1) 0%, rgba(59,59,59,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#292929",endColorstr="#3b3b3b",GradientType=1);
Any CSS magicians could help me with the whitespace on the inside? as I'd like to have the rectangle skewed with a gradient. But they don't work together so well. Thanks

sass border with 3 colors, is possible?

So, I'm trying to create an border of 1px, with a color 30% green, 20% red, 27% blue, with 70% of opacity, it is possible? I'm using sass but I have not found a way to make this
.box
width: 100px
height: 100px
background: gray
margin: 50px auto 0 auto
border-color: #ff0000 #0000ff
My pen: http://codepen.io/mejingjard/pen/xwxLKO?editors=110
Yes it's possible, and it's actually really simple with rgba()
border-color: rgba(20%,30%,27%,0.7);
Read about this and more sass color functions at
http://sass-lang.com/documentation/Sass/Script/Functions.html#rgba-instance_method
You can give this a try, however this alternative is with four borders, not the three. With RGBA you can change the opacity. You can visit http://www.cssportal.com/css3-rgba-generator/ to generate the CSS3 RGBA colours; there you can also change the opacity.
div {
width: 100px;
height: 100px;
margin: auto;
}
.one {
border-top: 1px solid rgba(0, 255, 0, 0.7);
border-right: 1px solid rgba(255, 0, 0, 0.7);
border-bottom: 1px solid rgba(0, 0, 255, 0.7);
border-left: 1px solid rgba(255, 0, 0, .5);
<div class="one"></div>
Alternatively if you wanted to go for more of a gradient look you can try applying a CSS3 gradient within a pseudo-element, however only two border colors are adopted, and it's without the opacity.
.one{
margin: auto;
width: 100px;
height: 100px;
border: 1px solid transparent;
-moz-border-image: -moz-linear-gradient(top, #E93478 0%, #FF0 100%);
-webkit-border-image: -webkit-linear-gradient(top, #E93478 0%, #FF0 100%);
border-image: linear-gradient(to bottom, #E93478 0%, #FF0 100%);
border-image-slice: 1;}
<div class="one"></div>

CSS button size different in Firefox 19 (works in chrome and IE9)

Firefox version 19 is giving me problems with spacing between an input field and a button. I would like the input button to appear to be inside the form background, and vertically centered, but the button is larger in Firefox than in Chrome or IE9 so it touches with the bottom of the form background. I am seeing this on a 1600x900 display. It looks fine on Chrome and IE9. Here is the jsfiddle http://jsfiddle.net/gyFS4/1/
HTML
<div id="signUp">
<form action="" method="post" id="signup">
<input type="text" class="left" id="email" name="email" placeholder="Enter your email address" value="">
<input type="submit" id="notify-me" class="button" value="Sign me up!">
</form>
</div>
CSS
form {
width: 406px;
margin: 0px auto;
margin-top: 32px;
background: #ffffff;
height: 46px;
border-radius: 22px;
-moz-box-shadow: 0px 0px 0px 6px rgba(255, 255, 255, 0.4);
-webkit-box-shadow: 0px 0px 0px 6px rgba(255, 255, 255, 0.4);
box-shadow: 0px 0px 0px 6px rgba(255, 255, 255, 0.4);
}
#email {
margin-left: 16px;
margin-right: 16px;
height: 36px;
width: 240px;
font-size: 1em;
color: #202020;
background: transparent;
border: none;
}
#email:focus {
outline: none;
}
.button {
margin-top: 3px;
background-color: #c3d753;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #c3d753), color-stop(100%, #a7ba3f));
background-image: -webkit-linear-gradient(top, #c3d753, #a7ba3f);
background-image: -moz-linear-gradient(top, #c3d753, #a7ba3f);
background-image: -ms-linear-gradient(top, #c3d753, #a7ba3f);
background-image: -o-linear-gradient(top, #c3d753, #a7ba3f);
background-image: linear-gradient(top, #c3d753, #a7ba3f);
-moz-border-radius:20px;
-webkit-border-radius:20px;
border-radius:20px;
border:1px solid #82922d;
display:inline-block;
color:#ffffff;
font-family: Open Sans, sans-serif;
font-size:1em;
font-weight: 400;
padding:8px 16px;
text-decoration:none;
text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
}
.button:hover {
background-color: #daf159;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #daf159), color-stop(100%, #a7ba3f));
background-image: -webkit-linear-gradient(top, #daf159, #a7ba3f);
background-image: -moz-linear-gradient(top, #daf159, #a7ba3f);
background-image: -ms-linear-gradient(top, #daf159, #a7ba3f);
background-image: -o-linear-gradient(top, #daf159, #a7ba3f);
background-image: linear-gradient(top, #daf159, #a7ba3f);
}
.button:active {
background-color: #c3d753;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #a7ba3f), color-stop(100%, #c3d753));
background-image: -webkit-linear-gradient(top, #a7ba3f, #c3d753);
background-image: -moz-linear-gradient(top, #a7ba3f, #c3d753);
background-image: -ms-linear-gradient(top, #a7ba3f, #c3d753);
background-image: -o-linear-gradient(top, #a7ba3f, #c3d753);
background-image: linear-gradient(top, #a7ba3f, #c3d753);
-moz-box-shadow:inset 0px 1px 3px rgba(0, 0, 0, 0.7);
-webkit-box-shadow:inset 0px 1px 3px rgba(0, 0, 0, 0.7);
box-shadow:inset 0px 1px 3px rgba(0, 0, 0, 0.7);
}
You need to specify a height and width on .button class.
.button {
...
width:125px;
height:40px;
}
The above looks good to me. Adjust to your tastes.
http://jsfiddle.net/gyFS4/10/
Try:
#-moz-document url-prefix() {
form {
padding: 0px 0px 3px;
}
}
I just looked at your site in Firefox 19 and it looked fine. But that maybe because my browser picked a font as I don't have the "Open sans" font on my computer.
Usually the problem you're describing is caused by the parent elements width being too small. Make sure you are adding each child elements width and both sides of all margins, borders, and padding. And as the button is being auto sized based on the font you may want to use firebug's "Layout" tab to see what the actual size of the button is. Also to avoid the font problem use a font that is on all computers, or use "#font-face" to give the visitors computer the font it needs to use (as long as the font isn't copyrighted).

Sliding door technique with semi transparent backgrounds?

I'm working on a button with a glossy appearance. The button can have various colors and sizes. This is what i have done so far:
.btn-zen-inverse, .btn-zen-inverse:hover{
color: white;
background:
url("../img/btn_right.png") no-repeat right 0,
url("../img/btn_left.png") no-repeat left 0,
url("../img/btn_center.png") repeat-x 42px 0;
background-color: #273032;
background-size: contain;
line-height: 50px;
margin: 12px 18px 3px 0;
padding: 0;
border: 2px solid white !important;
}
The images referenced are alpha transparent. The idea is to set the color based on the background-color attribute. The image has a few other properties aswell, but those are merely estetic.
This ofcorse renders an image that looks like this!
I would like the center-image to be visible only in the central part of the image. As you can see from my css. This only has to work perectly in the latest version of the big 4 browsers.
This is what I would like it to look like:
One suggesion is to do this with background-gradients. If that is possible, I need to define the background position similairly to the way padding/margin works. Is that possible?
The design contains:
2 borders:
one white
one gradiented,
A background gradient.
and a 1px thick vertical gradient at the very top.
This is as closer as i can get with CSS only.
Note that multiple backgrounds are not supported by IE8. Neither is the following code, but at least you don't need images.
Live demo
HTML:
<a class="button dark" href="#"><span>Prova Zenconomy Gratis</span></a>
CSS:
.button {
display:inline-block;
border:2px solid;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
line-height:40px;
text-decoration:none;
font-family:Helvetica,Arial,sans-serif;
-webkit-box-shadow: 0 0 4px 1px rgba(204, 204, 204, 0.7);
-moz-box-shadow: 0 0 4px 1px rgba(204, 204, 204, 0.7);
box-shadow: 0 0 4px 1px rgba(204, 204, 204, 0.7);
}
.button > span {
padding:0 40px;
display:block;
border:3px solid;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
}
.button.dark {
border-color:#FFF;
color:#FFF;
background:#030303;
}
.button.dark > span {
border-color:#000;
-webkit-box-shadow: inset 0 3px 5px -1px rgba(255,255,255,0.3);
-moz-box-shadow: inset 0 3px 5px -1px rgba(255,255,255,0.3);
box-shadow: inset 0 3px 5px -1px rgba(255,255,255,0.3);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwLjMiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0.3)), color-stop(100%,rgba(255,255,255,0)));
background: -webkit-linear-gradient(top, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%);
}
There are 2 classes (.button for the layout and .dark for colors and gradient) so that you can have different types of buttons in your page.
Please check this code as solution to your query.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.btn-zen-inverse, .btn-zen-inverse:hover{
color:#fff;
background:
url("https://lh4.googleusercontent.com/-V_jjGSjquMg/UHPqq7_FfvI/AAAAAAAAA6s/fK5QEHGzC9I/s128/left.png") no-repeat right 0,
url("https://lh4.googleusercontent.com/-V_jjGSjquMg/UHPqq7_FfvI/AAAAAAAAA6s/fK5QEHGzC9I/s128/left.png") no-repeat left 0,
url("https://lh3.googleusercontent.com/-JgxTtVru7R8/UHPqq1RgAII/AAAAAAAAA6o/gmfFayABGfQ/s128/center.png") repeat-x 42px 0;
background-color: #ff09f9;
background-size: contain;
line-height: 50px;
margin: 12px 18px 3px 0;
padding: 0;
border: 2px solid white !important;
text-align:center
}
</style>
</head>
<body>
<div class="btn-zen-inverse">Content</div>
</body>
</html>

How to create this CSS border

Hi guys i'm trying to create this(image) css border around a div, but having trouble.
I have created the border but cannot get the border to be smooth.
here is my code
border-left: 5px solid #036;
border-right: 5px solid #036;
border-top: 10px solid #036;
border-bottom: 5px solid #036;
Fiddle Up, You can see it here.
Hope it help.
EDIT:
Html:
<div class="a">
<span class="abs">Title here?</span>
<div class="b">
Hello.
</div>
</div>​
Css:
div.a {
border-top: 10px solid #333;
border-left: 5px solid #333;
border-bottom: 5px solid #333;
border-right: 5px solid #333;
border-radius: 10px;
background-color: #333;
width: 200px;
height: 400px;
}
div.b {
border-radius: 5px;
background-color: #FFF;
width: 180px;
height: 350px;
padding: 10px;
}
.abs {
color: #FFF;
display: inline-block;
font-weight: bold;
margin-bottom: 10px;
}
You can attain such a setup using new CSS3 facilities, namely border-radius and gradient form of background image. You can find information about those all around the internet, for example background gradient and border radius.
Below is example, it will not work in all browsers, and is not exactly what you want, but it should be enough to give you the basic idea:
The html structure could look like this:
<div id="big_div">
Search for a hotel
<div id="small_white_div">
Some other content
</div>
</div>
And the corresponding css would be:
#big_div {height:450px;width:250px;border-radius: 5px;background-color:red;
background-image: linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209) 51%,
rgb(33,51,140) 100%);
background-image: -o-linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209) 51%,
rgb(33,51,140) 100%);
background-image: -moz-linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209)
51%, rgb(33,51,140) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209)
51%, rgb(33,51,140) 100%);
background-image: -ms-linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209) 51%,
rgb(33,51,140) 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.05, rgb(33,51,140)),
color-stop(0.51, rgb(125,187,209)),
color-stop(1, rgb(33,51,140))
);}
#small_white_div {height:400px;width:220px;margin:auto;border-radius:5px;
background-color:white;margin-top:20px;}
Good luck.
It's done with background image.
You are looking for border-radius to get the rounded corners. Try out something like this:
-webkit-border-radius: 8px 8px 8px 8px;
-moz-border-radius: 8px 8px 8px 8px;
border-radius: 8px 8px 8px 8px;
Note this is CSS3 and will not work in older versions of IE

Resources