Базовый синтаксис text-shadow
text-shadow: x-смещение у-смещение размытие цвет;
Первое значение — смещение по горизонтали, второе — по вертикали, размытие тени и цвет тени.
Примеры:
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
Вдавленные буквы
[CSS]body {
background: #222;
}
#text h1 {
color: rgba(0,0,0,0.6);
text-shadow: 2px 2px 3px rgba(255,255,255,0.1);
}[/CSS]
[CSS]background-color: #666666;
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
color: transparent;
text-shadow: rgba(255,255,255,0.5) 0px 3px 3px;[/CSS]
Жесткая тень
text-shadow: 6px 6px 0px rgba(0,0,0,0.2);
Двойная тень
text-shadow: 4px 3px 0px #fff, 9px 8px 0px rgba(0,0,0,0.15);
Зависшие буквы
[CSS]text-shadow: 0px 3px 0px #b2a98f,
0px 14px 10px rgba(0,0,0,0.15),
0px 24px 2px rgba(0,0,0,0.1),
0px 34px 30px rgba(0,0,0,0.1);[/CSS]
3D текст
[CSS]text-shadow: 0px 4px 3px rgba(0,0,0,0.4),
0px 8px 13px rgba(0,0,0,0.1),
0px 18px 23px rgba(0,0,0,0.1);[/CSS]
Еще 3D
[CSS]text-shadow: 0 1px 0 #ccc,
0 2px 0 #c9c9c9,
0 3px 0 #bbb,
0 4px 0 #b9b9b9,
0 5px 0 #aaa,
0 6px 1px rgba(0,0,0,.1),
0 0 5px rgba(0,0,0,.1),
0 1px 3px rgba(0,0,0,.3),
0 3px 5px rgba(0,0,0,.2),
0 5px 10px rgba(0,0,0,.25),
0 10px 10px rgba(0,0,0,.2),
0 20px 20px rgba(0,0,0,.15);[/CSS]
Сияние
[CSS]text-shadow: 0px 0px 6px rgba(255,255,255,0.7);[/CSS]
Ретро
[CSS]text-shadow: -10px 10px 0px #00e6e6,
-20px 20px 0px #01cccc,
-30px 30px 0px #00bdbd;[/CSS]
Много теней
[CSS]text-shadow: 0px 15px 5px rgba(0,0,0,0.1),
10px 20px 5px rgba(0,0,0,0.05),
-10px 20px 5px rgba(0,0,0,0.05);[/CSS]
Выпуклый
[CSS]color: rgba(0,0,0,0.6);
text-shadow: 2px 8px 6px rgba(0,0,0,0.2),
0px -5px 35px rgba(255,255,255,0.3);[/CSS]
И подборка для освоения
[CSS].text-shadow (@string: 0 1px 3px rgba(0, 0, 0, 0.25))
{ text-shadow: @string;}
.box-shadow (@string)
{-webkit-box-shadow: @string;
-moz-box-shadow: @string;
box-shadow: @string;}
.drop-shadow (@x: 0, @y: 1px, @blur: 2px, @spread: 0, @alpha: 0.25)
{-webkit-box-shadowx @y @blur @spread rgba(0, 0, 0, @alpha);
-moz-box-shadowx @y @blur @spread rgba(0, 0, 0, @alpha);
box-shadowx @y @blur @spread rgba(0, 0, 0, @alpha);}
.inner-shadow (@x: 0, @y: 1px, @blur: 2px, @spread: 0, @alpha: 0.25)
{-webkit-box-shadow: inset @x @y @blur @spread rgba(0, 0, 0, @alpha);
-moz-box-shadow: inset @x @y @blur @spread rgba(0, 0, 0, @alpha);
box-shadow: inset @x @y @blur @spread rgba(0, 0, 0, @alpha);}
.box-sizing (@type: border-box)
{-webkit-box-sizing: @type;
-moz-box-sizing: @type;
box-sizingtype;}
.border-radius (@radius: 5px)
{-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radiusradius;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clipadding-box;}
.border-radiuses (@topright: 0, @bottomright: 0, @bottomleft: 0, @topleft: 0)
{-webkit-border-top-right-radius: @topright;
-webkit-border-bottom-right-radius: @bottomright;
-webkit-border-bottom-left-radius: @bottomleft;
-webkit-border-top-left-radius: @topleft;
-moz-border-radius-topright: @topright;
-moz-border-radius-bottomright: @bottomright;
-moz-border-radius-bottomleftbottomleft;
-moz-border-radius-toplefttopleft;
border-top-right-radiustopright;
border-bottom-right-radiusbottomright;
border-bottom-left-radius: @bottomleft;
border-top-left-radius: @topleft;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clipadding-box;}
.opacity (@opacity: 0.5)
{-webkit-opacity: @opacity;
-moz-opacity: @opacity;
opacity: @opacity;}
.gradient (@startColor: #eee, @endColor: white)
{background-color: @startColor;
background: -webkit-gradient(linear, left top, left bottom, from(@startColor), to(@endColor));
background: -webkit-linear-gradient(top, @startColor, @endColor);
background: -moz-linear-gradient(top, @startColor, @endColor);
background: -ms-linear-gradient(top, @startColor, @endColor);
background: -o-linear-gradient(top, @startColor, @endColor);}
.horizontal-gradient (@startColor: #eee, @endColor: white)
{background-color: @startColor;
background-image: -webkit-gradient(linear, left top, right top, from(@startColor), to(@endColor));
background-image: -webkit-linear-gradient(left, @startColor, @endColor);
background-image: -moz-linear-gradient(left, @startColor, @endColor);
background-image: -ms-linear-gradient(left, @startColor, @endColor);
background-image: -o-linear-gradient(left, @startColor, @endColor);}
.animation (@name, @duration: 300ms, @delay: 0, @ease: ease)
{-webkit-animation: @name @duration @delay @ease;
-moz-animation: @name @duration @delay @ease;
-ms-animation: @name @duration @delay @ease;}
.transition (@transition)
{-webkit-transition: @transition;
-moz-transition: @transition;
-ms-transition: @transition;
-o-transitiontransition;
}
.transform(@string)
{-webkit-transform: @string;
-moz-transform: @string;
-ms-transform: @string;
-o-transform: @string;}
.scale (@factor)
{-webkit-transform: scale(@factor);
-moz-transform: scale(@factor);
-ms-transform: scale(@factor);
-o-transform: scale(@factor);}
.rotate (@deg)
{-webkit-transform: rotate(@deg);
-moz-transform: rotate(@deg);
-ms-transform: rotate(@deg);
-o-transform: rotate(@deg);}
.skew (@deg, @deg2)
{-webkit-transform: skew(@deg, @deg2);
-moz-transform: skew(@deg, @deg2);
-ms-transform: skew(@deg, @deg2);
-o-transform: skew(@deg, @deg2);}
.translate (@x, @y:0)
{-webkit-transform: translate(@x, @y);
-moz-transform: translate(@x, @y);
-ms-transform: translate(@x, @y);
-o-transform: translate(@x, @y);}
.translate3d (@x, @y: 0, @z: 0)
{-webkit-transform: translate3d(@x, @y, @z);
-moz-transform: translate3d(@x, @y, @z);
-ms-transform: translate3d(@x, @y, @z);
-o-transform: translate3d(@x, @y, @z);}
.perspective (@value: 1000)
{-webkit-perspective: @value;
-moz-perspective: @value;
-ms-perspective: @value;
perspective: @value;}
.transform-origin (@x:center, @y:center)
{-webkit-transform-origin: @x @y;
-moz-transform-origin: @x @y;
-ms-transform-origin: @x @y;
-o-transform-originx @y;}[/CSS]
Первое значение — смещение по горизонтали, второе — по вертикали, размытие тени и цвет тени.
Примеры:
Вдавленные буквы
[CSS]body {
background: #222;
}
#text h1 {
color: rgba(0,0,0,0.6);
text-shadow: 2px 2px 3px rgba(255,255,255,0.1);
}[/CSS]
[CSS]background-color: #666666;
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
color: transparent;
text-shadow: rgba(255,255,255,0.5) 0px 3px 3px;[/CSS]
Жесткая тень
Двойная тень
Зависшие буквы
[CSS]text-shadow: 0px 3px 0px #b2a98f,
0px 14px 10px rgba(0,0,0,0.15),
0px 24px 2px rgba(0,0,0,0.1),
0px 34px 30px rgba(0,0,0,0.1);[/CSS]
3D текст
[CSS]text-shadow: 0px 4px 3px rgba(0,0,0,0.4),
0px 8px 13px rgba(0,0,0,0.1),
0px 18px 23px rgba(0,0,0,0.1);[/CSS]
Еще 3D
[CSS]text-shadow: 0 1px 0 #ccc,
0 2px 0 #c9c9c9,
0 3px 0 #bbb,
0 4px 0 #b9b9b9,
0 5px 0 #aaa,
0 6px 1px rgba(0,0,0,.1),
0 0 5px rgba(0,0,0,.1),
0 1px 3px rgba(0,0,0,.3),
0 3px 5px rgba(0,0,0,.2),
0 5px 10px rgba(0,0,0,.25),
0 10px 10px rgba(0,0,0,.2),
0 20px 20px rgba(0,0,0,.15);[/CSS]
Сияние
[CSS]text-shadow: 0px 0px 6px rgba(255,255,255,0.7);[/CSS]
Ретро
[CSS]text-shadow: -10px 10px 0px #00e6e6,
-20px 20px 0px #01cccc,
-30px 30px 0px #00bdbd;[/CSS]
Много теней
[CSS]text-shadow: 0px 15px 5px rgba(0,0,0,0.1),
10px 20px 5px rgba(0,0,0,0.05),
-10px 20px 5px rgba(0,0,0,0.05);[/CSS]
Выпуклый
[CSS]color: rgba(0,0,0,0.6);
text-shadow: 2px 8px 6px rgba(0,0,0,0.2),
0px -5px 35px rgba(255,255,255,0.3);[/CSS]
И подборка для освоения
[CSS].text-shadow (@string: 0 1px 3px rgba(0, 0, 0, 0.25))
{ text-shadow: @string;}
.box-shadow (@string)
{-webkit-box-shadow: @string;
-moz-box-shadow: @string;
box-shadow: @string;}
.drop-shadow (@x: 0, @y: 1px, @blur: 2px, @spread: 0, @alpha: 0.25)
{-webkit-box-shadowx @y @blur @spread rgba(0, 0, 0, @alpha);
-moz-box-shadowx @y @blur @spread rgba(0, 0, 0, @alpha);
box-shadowx @y @blur @spread rgba(0, 0, 0, @alpha);}
.inner-shadow (@x: 0, @y: 1px, @blur: 2px, @spread: 0, @alpha: 0.25)
{-webkit-box-shadow: inset @x @y @blur @spread rgba(0, 0, 0, @alpha);
-moz-box-shadow: inset @x @y @blur @spread rgba(0, 0, 0, @alpha);
box-shadow: inset @x @y @blur @spread rgba(0, 0, 0, @alpha);}
.box-sizing (@type: border-box)
{-webkit-box-sizing: @type;
-moz-box-sizing: @type;
box-sizingtype;}
.border-radius (@radius: 5px)
{-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radiusradius;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clipadding-box;}
.border-radiuses (@topright: 0, @bottomright: 0, @bottomleft: 0, @topleft: 0)
{-webkit-border-top-right-radius: @topright;
-webkit-border-bottom-right-radius: @bottomright;
-webkit-border-bottom-left-radius: @bottomleft;
-webkit-border-top-left-radius: @topleft;
-moz-border-radius-topright: @topright;
-moz-border-radius-bottomright: @bottomright;
-moz-border-radius-bottomleftbottomleft;
-moz-border-radius-toplefttopleft;
border-top-right-radiustopright;
border-bottom-right-radiusbottomright;
border-bottom-left-radius: @bottomleft;
border-top-left-radius: @topleft;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clipadding-box;}
.opacity (@opacity: 0.5)
{-webkit-opacity: @opacity;
-moz-opacity: @opacity;
opacity: @opacity;}
.gradient (@startColor: #eee, @endColor: white)
{background-color: @startColor;
background: -webkit-gradient(linear, left top, left bottom, from(@startColor), to(@endColor));
background: -webkit-linear-gradient(top, @startColor, @endColor);
background: -moz-linear-gradient(top, @startColor, @endColor);
background: -ms-linear-gradient(top, @startColor, @endColor);
background: -o-linear-gradient(top, @startColor, @endColor);}
.horizontal-gradient (@startColor: #eee, @endColor: white)
{background-color: @startColor;
background-image: -webkit-gradient(linear, left top, right top, from(@startColor), to(@endColor));
background-image: -webkit-linear-gradient(left, @startColor, @endColor);
background-image: -moz-linear-gradient(left, @startColor, @endColor);
background-image: -ms-linear-gradient(left, @startColor, @endColor);
background-image: -o-linear-gradient(left, @startColor, @endColor);}
.animation (@name, @duration: 300ms, @delay: 0, @ease: ease)
{-webkit-animation: @name @duration @delay @ease;
-moz-animation: @name @duration @delay @ease;
-ms-animation: @name @duration @delay @ease;}
.transition (@transition)
{-webkit-transition: @transition;
-moz-transition: @transition;
-ms-transition: @transition;
-o-transitiontransition;
}
.transform(@string)
{-webkit-transform: @string;
-moz-transform: @string;
-ms-transform: @string;
-o-transform: @string;}
.scale (@factor)
{-webkit-transform: scale(@factor);
-moz-transform: scale(@factor);
-ms-transform: scale(@factor);
-o-transform: scale(@factor);}
.rotate (@deg)
{-webkit-transform: rotate(@deg);
-moz-transform: rotate(@deg);
-ms-transform: rotate(@deg);
-o-transform: rotate(@deg);}
.skew (@deg, @deg2)
{-webkit-transform: skew(@deg, @deg2);
-moz-transform: skew(@deg, @deg2);
-ms-transform: skew(@deg, @deg2);
-o-transform: skew(@deg, @deg2);}
.translate (@x, @y:0)
{-webkit-transform: translate(@x, @y);
-moz-transform: translate(@x, @y);
-ms-transform: translate(@x, @y);
-o-transform: translate(@x, @y);}
.translate3d (@x, @y: 0, @z: 0)
{-webkit-transform: translate3d(@x, @y, @z);
-moz-transform: translate3d(@x, @y, @z);
-ms-transform: translate3d(@x, @y, @z);
-o-transform: translate3d(@x, @y, @z);}
.perspective (@value: 1000)
{-webkit-perspective: @value;
-moz-perspective: @value;
-ms-perspective: @value;
perspective: @value;}
.transform-origin (@x:center, @y:center)
{-webkit-transform-origin: @x @y;
-moz-transform-origin: @x @y;
-ms-transform-origin: @x @y;
-o-transform-originx @y;}[/CSS]