Let's say i have a button class
.mat-cancel-color {
width: 160px;
border: 1px solid #dddddd;
color: #dddddd;
background-color: white;
border-radius: 25px;
}
and whenever i click something(not the 'mat-cancel-color' button) i want this class to gain a glow effect which would fade away over .4s.
should i create a new class and then give that class the box-shadow(glow) property, then below transition-duration property and then the the box-shadow(no glow) property again? as such:
click-class {
-webkit-box-shadow: 0px 0px 15px 10px rgba(255,255,0,1);
-moz-box-shadow: 0px 0px 15px 10px rgba(255,255,0,1);
box-shadow: 0px 0px 15px 10px rgba(255,255,0,1);
transition-duration: .4s;
-webkit-box-shadow: 0px 0px 0px 0px rgba(255,255,0,1);
-moz-box-shadow: 0px 0px 0px 0px rgba(255,255,0,1);
box-shadow: 0px 0px 0px 0px rgba(255,255,0,1);
}
or does transition-duration only work when switching classes or does it also work when switching properties inside a class? if it as such, how should i go about it?
EDIT: mistook transition-delay with transition-duration.
What you are looking for is a CSS animation. Mainly because you don't want the default state with the glow, that's why transition won't work here.
.mat-cancel-color {
width: 160px;
border: 1px solid #dddddd;
color: #dddddd;
background-color: white;
border-radius: 25px;
}
.mat-cancel-color:hover {
animation-name: glow;
animation-duration: .4s;
}
.mat-cancel-color-trans {
width: 160px;
border: 1px solid #dddddd;
color: #dddddd;
background-color: white;
border-radius: 25px;
transition: all .4s ease;
box-shadow: 0px 0px 15px 10px rgba(255, 255, 0, 0);
}
.mat-cancel-color-trans:hover {
box-shadow: 0px 0px 0px 0px rgba(255, 255, 0, 1);
}
/* Standard syntax */
#keyframes glow {
0% {
box-shadow: 0px 0px 15px 10px rgba(255, 255, 0, 1);
}
100% {
box-shadow: 0px 0px 0px 0px rgba(255, 255, 0, 1);
}
}
<button class="mat-cancel-color">Button</button>
<button class="mat-cancel-color-trans">Button</button>
You could use some psudo classes like this:
:active:not(*element/class*) {...}
and then put the glow animation that you want within the brackets. :active is a psudo class that is only applied when the element named is clicked. :not() excludes the class listed in the parentheses. As long as you have the glow animation working fine, then this should work.
This is a snippet of my test code:
a:active:not(.mat-cancel-color) {...}
I want exactly matched button with gradient and Box-shadow.
I tried gradient css3 properties (box-shadow: 2px 3px 3px #333;) but couldn't meet the expected result. Can anyone Suggest me the proper way.
I'm not getting what you want but I'm trying according to your question.
You can use 2 color box-shadow and advance gradient use like this:-
.answer-btn {
color: #fff;
font-family: Arial, sans-serif;
min-width: 267px;
padding: 18px 0 19px;
text-align: center;
border: none;
border-bottom: inset 1px #2894cc;
border-color: -moz-use-text-color -moz-use-text-color rgba(38, 144, 202, 0.11);
background-color: #278abe;
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9Ii0yNSUiIHI9IjEwMCUiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiM0MWJlZTgiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMyNjhhYmQiLz48L3JhZGlhbEdyYWRpZW50PjwvZGVmcz48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSJ1cmwoI2dyYWQpIiAvPjwvc3ZnPiA=');
background-size: 100%;
background-image: -moz-radial-gradient(50% -25%, ellipse farthest-side, #41bee8, #268abd 100%);
background-image: -webkit-radial-gradient(50% -25%, ellipse farthest-side, #41bee8, #268abd 100%);
background-image: radial-gradient(ellipse farthest-side at 50% -25%, #41bee8, #268abd 100%);
-moz-border-radius: 5px !important;
-webkit-border-radius: 5px;
border-radius: 5px !important;
-moz-box-shadow: 0px 7px 0px 0px #1b6b9e, 0px 0px 10px 1px #b3b3b4;
-webkit-box-shadow: 0px 7px 0px 0px #1b6b9e, 0px 0px 10px 1px #b3b3b4;
box-shadow: 0px 7px 0px 0px #1b6b9e, 0px 0px 10px 1px #b3b3b4;
-moz-transition: all 0.1s;
-o-transition: all 0.1s;
-webkit-transition: all 0.1s;
transition: all 0.1s;
font-size: 25px;
font-size: 1.5625rem;
}
.answer-btn:active {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
-moz-transform: translate(0px, 5px);
-ms-transform: translate(0px, 5px);
-webkit-transform: translate(0px, 5px);
transform: translate(0px, 5px);
}
https://jsfiddle.net/kant707/9zLLpLbg/
Whether it is possible tilt, rotate, shrink 3d text? I want to create an effect of bottom view on my text (or if text lies on a table) using only CSS. Is it possible? I do not mean the animation, only static effect. I can do it in the 3dsMAX or PhotoShop, but I want to know how it can be implemented in CSS.
I have:
Fiddle
I want:
I got a little bit this effect (due to the large shadow). But I want to make it more clear and explicit. Further increase in the shade does not enhance the effect. I need to tilt and compress vertically my text. What styles can help me in this?
I would be grateful for any ideas!
My shadow styles:
text-shadow: 0px 0px 0 rgb(221,120,128),
-1px 1px 0 rgb(215,114,122),
-2px 2px 0 rgb(209,108,116),
-3px 3px 0 rgb(203,102,110),
-4px 4px 0 rgb(197,96,104),
-5px 5px 0 rgb(191,90,98),
-6px 6px 0 rgb(185,84,92),
-7px 7px 0 rgb(178,77,85),
-8px 8px 0 rgb(172,71,79),
-9px 9px 0 rgb(166,65,73),
-10px 10px 0 rgb(160,59,67),
-11px 11px 0 rgb(154,53,61),
-12px 12px 0 rgb(148,47,55),
-13px 13px 0 rgb(142,41,49),
-14px 14px 0 rgb(136,35,43),
-15px 15px 0 rgb(130,29,37),
-16px 16px 15px rgba(0,0,0,0.6),
-16px 16px 1px rgba(0,0,0,0.5),
0px 0px 15px rgba(0,0,0,.2);
}
that is not easy i think you will need js for that,unfortunately css text-shadow property is only 2 dimensional. Here is a quick example, use your keyboard to controll the angle
0- REAL 3D USING ONLY CSS cross browser compatibility solution(prefixfree)
For Cross-browser gradients (NO -webkit-,-moz-,-ms-)
save your time using LeaVerou/prefixfree
you can find a CDN Version here
3D DEMO with prefixfree & CSS only
figure {
transform-origin:center center;
transform-style:preserve-3d;
transform: rotate3d(-1,0,0,-72deg);
}
1- REAL 3D USING JQUERY cross browser compatibility solution(prefixfree)
3D DEMO with Jquery
MARKUP
<figure></figure>
JS
var shadowLength = 40;
for(var i = 0;i < shadowLength; i++){
var layer = $("<h1>3D TEXT</h1>").css("transform", "translateZ(-"+i+"px)");
$("figure").append(layer);
}
CSS
* { box-sizing:border-box; }
:root{
background-color: #00dbba;
overflow:hidden;
text-align:center;
}
figure {
transform-origin:center center;
transform-style:preserve-3d;
transform: rotate3d(-1,0,0,-72deg);
}
h1:first-child{
color:white;
}
h1 {
display:block;
width:100%;
padding:40px;
line-height:1.5;
font:900 8em 'Concert One', sans-serif;
text-transform:uppercase;
position:absolute;
color:#51B3A3;
}
you can now choose the position by changing the value of rotateZ(Value deg) rotateX(Value deg) rotateY(Value deg) to get the perfect position.
figure {
transform-origin:center center;
transform-style:preserve-3d;
transform: rotateZ(0deg) rotateX(70deg) rotateY(-12deg);
}
deep understanding css3D
Read how Nesting 3D Transformed Elements Works
and don't miss [CSSconf.eu 2013] Ana-Maria Tudor: Maths-powered transforms for creating 3D shapes
if you need more, read
1- css-3d-animation-how
2- Ana-Maria Tudor on stackoverflow
2- REAL 3D
3D DEMO with animation
figure#figure3d {
-webkit-transform: rotateX(54deg) scale(1) skew(10deg) translate3d(0px, 0px, 0px);
-webkit-transform-origin:center center;
-webkit-transform-style:preserve-3d;
}
you can remove the span if you don't like the animation at the beginning
span{
display:none;/*comment me to remove the animation*/
}
3- IN GENERAL
3D DEMO with animation
or change the angle like this
-webkit-transform:rotate3d(-1,1,0,40deg);
3D DEMO without animation
#figure3d span {
color:silver;
-webkit-text-shadow: 0px 1px 0px #c0c0c0, 0px 2px 0px #b0b0b0, 0px 3px 0px #a0a0a0, 0px 4px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6);
-moz-text-shadow: 0px 1px 0px #c0c0c0, 0px 2px 0px #b0b0b0, 0px 3px 0px #a0a0a0, 0px 4px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6);
-ms-text-shadow: 0px 1px 0px #c0c0c0, 0px 2px 0px #b0b0b0, 0px 3px 0px #a0a0a0, 0px 4px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6);
text-shadow: 0px 1px 0px #c0c0c0, 0px 2px 0px #b0b0b0, 0px 3px 0px #a0a0a0, 0px 4px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6);
}
* { -webkit-box-sizing:border-box; }
figure#figure3d {
-webkit-transform: rotate(0deg) scale(1) skew(0deg) translate3d(0px, 0px, 0px);
-webkit-transform-origin:center center;
-webkit-transform-style:preserve-3d;
}
4- USING ONLY CSS
the max you can do using text-shadow only ist something like this
#figure3d {
-webkit-transform: rotateX(65deg) scale(1) skew(10deg) translate3d(0px, 0px, 0px);
-webkit-transform-origin: center center;
-webkit-transform-style: preserve-3d;
font-size:3.6em;
letter-spacing:10px;
font-family: 'Alfa Slab One', cursive;
font-weight:900;
color:white;
text-shadow: -1px 1px 0 #51B3A3,
-2px 2px 0 #51B3A3,
-2px 3px 0 #51B3A3,
-2px 5px 0 #51B3A3,
-2px 7px 0 #51B3A3,
-2px 8px 0 #51B3A3,
-2px 10px 0 #51B3A3,
-2px 11px 0 #51B3A3,
-3px 13px 0 #51B3A3,
-3px 14px 0 #51B3A3,
-3px 16px 0 #51B3A3,
-3px 17px 0 #51B3A3,
-4px 19px 0 #51B3A3,
-4px 20px 0 #51B3A3,
-4px 22px 0 #51B3A3,
-4px 23px 0 #51B3A3,
-4px 25px 0 #51B3A3,
-4px 26px 0 #51B3A3,
-5px 28px 0 #51B3A3,
-5px 29px 0 #51B3A3;
}
3D DEMO with text-shadow only
you can then ajust it as you like!
I think this is what you're referring to (Fiddle). The transform selector is going to be your friend in this situation, i.e. transform: rotate(6.5deg) rotateX(188deg) skewX(-25deg).
HTML:
<div id="wrapper" contenteditable="true" spellcheck="false">
<p>Where</p>
<p>are the</p>
<p>trees</p>
</div>
CSS:
#import url(http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:bold);
/* Global ------------------------------------------------------ */
html {
height: 100%;
font: 62.5%/1 "Lucida Sans Unicode","Lucida Grande",Verdana,Arial,Helvetica,sans-serif;
background: url(http://s.cdpn.io/79/glow.png) no-repeat center center,
url(http://s.cdpn.io/79/tilt-shift.jpg) no-repeat center center;
background-size: auto, cover;
}
body {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
width: 100%;
height: 100%;
text-align: center;
background-color: hsla(30,20%,95%,.9);
}
/* Wrapper ------------------------------------------------------ */
#wrapper {
position: relative;
text-align: center;
font-weight: bold;
font-family: "Yanone Kaffeesatz", "Lucida Grande", Lucida, Verdana, sans-serif;
margin: 0 auto;
width: 600px;
padding: 7em 0;
background: url(http://s.cdpn.io/79/tilt-shift.jpg) no-repeat center center;
border-radius: 4px;
box-shadow: inset 0 -1px 0 hsla(0,0%,0%,.2), 0 21px 8px -12px rgba(0,0,0,.2);
perspective: 350;
}
#wrapper:focus {
outline: none;
}
#wrapper p {
font-size: 10em;
margin: 0;
color: #fff;
text-transform: uppercase;
letter-spacing: 0.03em;
text-shadow: rgba(0,0,0,0.1) 0 20px 80px;
-webkit-transition: -webkit-transform .1s ease-in; /* only WebKit because of performance */
}
/* Hover ------------------------------------------------------ */
#wrapper:hover p {
color: hsla(0,0%,0%,0);
transform: rotate(6.5deg) rotateX(28deg) skewX(-4deg);
-webkit-transition: -webkit-transform .1s ease-out; /* only WebKit because of performance */
}
#wrapper:hover p:nth-child(1) {
font-size: 9em;
text-shadow: #fff 0 0 10px,
#fff 0 4px 3px, #ddd 0 9px 3px, #ccc 0 12px 1px,
rgba(0,0,0,0.2) 0 14px 5px, rgba(0,0,0,0.1) 0 20px 10px,
rgba(0,0,100,0.2) 0 15px 80px;
text-indent: 0.3em;
}
#wrapper:hover p:nth-child(2) {
font-size: 10em;
text-shadow: #fff 0 0 1px,
#eee 0 4px 3px, #ddd 0 9px 3px, #ccc 0 12px 1px,
rgba(0,0,0,0.2) 0 14px 3px, rgba(0,0,0,0.1) 0 20px 10px,
rgba(0,0,100,0.2) 0 15px 80px;
}
#wrapper:hover p:nth-child(3) {
font-size: 11em;
text-shadow: #fff 0 0 2px,
#fff 0 4px 5px, #ddd 0 9px 5px, #ccc 0 12px 10px,
rgba(0,0,0,0.2) 0 14px 5px, rgba(0,0,0,0.1) 0 20px 10px,
rgba(0,0,100,0.2) 0 15px 80px;
}
/* Middle ------------------------------------------------------ */
#wrapper p:nth-child(2):hover {
text-shadow: #fff 0 -5px 1px,
#eee 0 -1px 3px, #ddd 0 4px 3px, #ccc 0 7px 1px,
rgba(0,0,0,0.2) 0 15px 5px, rgba(0,0,0,0.1) 0 20px 10px,
rgba(0,0,0,0.2) 0 15px 80px;
}
#wrapper p:nth-child(2):active {
text-shadow: rgba(0,0,0,0.2) 0 14px 5px, rgba(0,0,0,0.1) 0 20px 10px,
rgba(0,0,0,0.2) 0 15px 80px;
}
#wrapper p::selection {
background-color: red;
}
You can get an aproximate result setting a rotation with perspective:
display: inline-block;
-webkit-transform: perspective(200px) rotateX(20deg);
-webkit-transform-origin: 30% bottom;
transform: perspective(60px) rotateX(23deg);
transform-origin: 30% bottom;
fiddle
I set the display to inline-block so that the perspective is centered, otherwise it is skewed.
I have got a small problem with my list item on hover.
The menu bar has a small inset shadow at the bottom, defined on the li items. On li:hover the small inset at the bottom changes to a inset shadow on all 4 sides.
I`m pretty happy about how the menu reacts, except for the li:lastchild. On hover it first delete the bottom & right inset shadow and then prints the new 4 sided inset shadow. Al the other li items just change the shadow from a single bottom to all 4 sides, without resetting the shadow.
I know the css shadow part is not written very clean. But because the hover has to CHANGE te shadow instead of replace i cant simple commit a statement on multiple selectors. (If you guys know a way to do this please feel free to comment!)
So my question is, how do i get a different inset shadow on the li:lastchild which will change on hover instead of getting replaced?
The code on cedepen
<ul class="hoofd-menu menu">
<li class="menu-item">Menu Item I</li>
<li class="menu-item">Menu Item II</li>
<li class="menu-item">Menu Item III</li>
<li class="menu-item">Menu Item IV</li>
<li class="menu-item">Menu Item V</li>
<li class="menu-item">Menu Item VI</li>
</ul>
<style>
.menu li {
margin: 0 0 0 -4px;
padding: 15px 15px;
}
/* Menu Item Hover effect */
.menu li {
box-shadow: 0 -9px 5px -5px rgba(0,0,0, 1) inset, /* dark shadow */
2px -2px 3px 0px rgba(255,255,255, 0.2), /* white - top */
2px 2px 3px 0px rgba(255,255,255, 0.2); /* white - bottom */
}
li:last-child.menu-item {
box-shadow: -9px 0px 5px -5px rgba(0,0,0, 1) inset, /*dark shadow right */
0px -9px 5px -5px rgba(0,0,0, 1) inset, /*dark shadow */
2px -2px 3px 0px rgba(255,255,255, 0.2), /* white - top */
2px 2px 3px 0px rgba(255,255,255, 0.2); /* white - bottom */
}
li:first-child.menu-item {
box-shadow: 0px -9px 5px -5px rgba(0,0,0, 1) inset, /* dark shadow */
-2px -2px 3px 0px rgba(255,255,255, 0.2), /* white - left */
2px -2px 3px 0px rgba(255,255,255, 0.2), /* white - top */
2px 2px 3px 0px rgba(255,255,255, 0.2); /* white - bottom */
}
.menu li:hover {
cursor: pointer;
box-shadow: -1px -1px 10px 4px rgba(0,0,0, 1) inset, /* dark shadow */
2px -2px 3px 0px rgba(255,255,255, 0.2), /* white - top */
2px 2px 3px 0px rgba(255,255,255, 0.2); /* white - bottom */
}
.menu li:hover>a {
text-shadow: -1px -1px 3px rgba(0,0,0, 0.2); /* text shadow */
}
li:hover:last-child.menu-item {
box-shadow: -1px -1px 10px 4px rgba(0,0,0, 1) inset, /* dark shadow */
2px -2px 3px 0px rgba(255,255,255, 0.2), /* white - top */
2px 2px 3px 0px rgba(255,255,255, 0.2); /* white - bottom */
}
li:hover:first-child.menu-item {
box-shadow: -1px -1px 10px 4px rgba(0,0,0, 1) inset, /* dark shadow */
-2px -2px 3px 0px rgba(255,255,255, 0.2), /* white - top */
2px -2px 3px 0px rgba(255,255,255, 0.2), /* white - top */
2px 2px 3px 0px rgba(255,255,255, 0.2); /* white - bottom */
}
/******************************************************************************************/
/* Round corners */
/******************************************************************************************/
li:first-child.menu-item {
-moz-border-radius-bottomleft: 5px;
border-bottom-left-radius: 5px;
-moz-border-radius-topleft: 5px;
border-top-left-radius: 5px;
}
li:last-child.menu-item {
-moz-border-radius-bottomright: 5px;
border-bottom-right-radius: 5px;
-moz-border-radius-topright: 5px;
border-top-right-radius: 5px;
}
/******************************************************************************************/
/* Color palette */
/******************************************************************************************/
a {color: #0861a5;}
a:hover {color: #d98500;}
.menu li:hover>a,
.menu a {color: #dddddd;}
body {background-color: #b8d3e2;}
.menu li {background-color: #87a0af;}
.menu {font-family: Arial, Helvetica, sans-serif}
a {text-decoration: none;}
a, .menu li>a {
transition: 1.5s ease 0.2s;
-moz-transition: 1.5s ease 0.2s;
-webkit-transition: 1.5s ease 0.2s;
-o-transition: 1.5s ease 0.2s;
}
a:hover, .menu li, .menu li:hover>a {
transition: 0.4s ease 0.6s;
-moz-transition: 0.4s ease 0.6s;
-webkit-transition: 0.4s ease 0.6s;
-o-transition: 0.4s ease 0.6s;
}
ul, li, ol {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}
ul {
margin: 100px 50px;
}
/* algemeen menu*/
.menu ul {
list-style-type: none;
}
.menu li {
display: inline;
}
</style>
If you want to make transitions with box-shadow, the elements of the box-shadow must make "pairs" and must match the "class" of the shadow.
Pixels and colors can be transitioned, keywords not.
Your base element is
.menu li {
box-shadow: 0 -9px 5px -5px rgba(0,0,0, 1) inset,
2px -2px 3px 0px rgba(255,255,255, 0.2),
2px 2px 3px 0px rgba(255,255,255, 0.2);
}
and you can transition correctly to this:
.menu li:hover {
box-shadow: -1px -1px 10px 4px rgba(0,0,0, 1) inset,
2px -2px 3px 0px rgba(255,255,255, 0.2),
2px 2px 3px 0px rgba(255,255,255, 0.2);
}
Because the first element is inset and both cases, and the other 2 aren't in both cases.
The last child is
li:last-child.menu-item {
box-shadow: -9px 0px 5px -5px rgba(0,0,0, 1) inset,
0px -9px 5px -5px rgba(0,0,0, 1) inset, /* PROBLEM HERE */
2px -2px 3px 0px rgba(255,255,255, 0.2),
2px 2px 3px 0px rgba(255,255,255, 0.2);
}
And the second element is inset and doesn't match the second in the hover that is not inset. THIS is the part that fails.
Once understood where the problems is there are several solutions. May be the easier is to set only 1 inset that has both x and y offsets:
li:last-child.menu-item {
box-shadow: -9px -9px 5px -5px rgba(0,0,0, 1) inset, /* combined shadows */
2px -2px 3px 0px rgba(255,255,255, 0.2),
2px 2px 3px 0px rgba(255,255,255, 0.2);
}
The result maybe isn't exactly the previous one, but that is transitionable