Effect of bottom view for a text using CSS - css

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.

Related

How do I set an equal box-shadow for all 4 sides?

Codepen example: https://codepen.io/any_formless/pen/RwKgGOm
My box shadow is different on the sides than on the top, and the bottom is totally missing.
.example {
border-radius: 3vw;
box-shadow: inset 10px 10px 10px -10px rgb(0 0 0), inset -10px 10px 10px -10px rgb(0 0 0);
text-align: center;
padding: 5vw;
}
<div class="example">Text</div>
The applicable syntax for the box-shadow property is:
/* inset | offset-x | offset-y | blur-radius | spread-radius | color */
This is not to be confused with the shorthand syntax for certain box-model properties (e.g. margin or padding) which is:
/* top | right | bottom | left */
To achieve an evenly placed border, offset-x and offset-y should be 0:
.example {
border-radius: 3vw;
box-shadow: inset 0 0 10px 10px rgb(0 0 0);
text-align: center;
padding: 5vw;
}
<div class="example">Text</div>
Multiple independent shadows can be created using commas.
The original example is essentially creating two overlapping shadows, one for the top/left and one for the top/right:
.example {
border-radius: 3vw;
box-shadow:
inset 6px 5px 5px 0 rgb(0 0 0), /* left and top */
inset -6px 5px 5px 0 rgb(0 0 0) /* right and top */
;
text-align: center;
padding: 5vw;
}
<div class="example">Text</div>
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
Hello use something like this:
.example {
box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.75) inset;
-webkit-box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.75) inset;
-moz-box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.75) inset;
}
Also, don't forget to make the last px before rgba the same number for all.
If you use 4 values before color for box-shadow, respectively they mean:
offset-x, offset-y, blur-radius, spread-radius
For your example, if you would like to have all sides equal, you should not give any value to offset-x and offset-y.
So, something like that:
.example {
border-radius: 3vw;
box-shadow: inset 0 0 10px -10px rgb(0 0 0), inset 0 0 10px -10px rgb(0 0 0);
text-align: center;
padding: 5vw;
}
<div class="example">Text</div>

Is it possible to transition from an inset box-shadow to a regualr box-shadow?

This might not make sense out of context, but I'm working on something where I would like there to be an inset box-shadow which transitions to a normal box-shadow. The transition works without the inset, but breaks with. Possible or not?
.foo{
height: 20rem;
width: 20rem;
box-shadow: inset 4px 0px 4px grey,
inset -4px 0px 4px grey;
background: cornsilk;
&:hover{
box-shadow: 1px 9px 4px 9px grey;
transition: box-shadow 1s;
}
}
https://codepen.io/bobam/pen/ZEWBeJp
The direct transition for the box-shadow inset to regular is not possible. But, there is one hack that can give a closer effect.
Consider the following css:
.foo {
width: 50px;
height: 50px;
border: 1px solid #aaa;
box-shadow: inset 0 0 10px #aaa;
animation: boxShadowOut 1s;
}
.foo:hover {
box-shadow: 0 0 10px #aaa;
animation: boxShadowIn 1s;
}
#keyframes boxShadowIn {
0% { box-shadow: inset 0 0 10px #aaa; }
50% { box-shadow: none; }
100% { box-shadow: 0 0 10px #aaa; }
}
#keyframes boxShadowOut {
0% { box-shadow: 0 0 10px #aaa; }
50% { box-shadow: none; }
100% { box-shadow: inset 0 0 10px #aaa; }
}
<div class="foo"></div>
You can do it with transition. You simply need to define all the shadows at once and play with the values to make them 0 when you don't need the shadow:
.foo {
height: 8rem;
width: 8rem;
margin:10px;
box-shadow:
inset 4px 0px 4px grey,
inset -4px 0px 4px grey,
0px 0px 0px 0px grey;
transition: box-shadow 1s;
background: cornsilk;
}
.foo:hover {
box-shadow:
inset 0px 0px 0px grey,
inset 0px 0px 0px grey,
1px 9px 4px 9px grey;
}
<div class="foo">
</div>

Trying to get a Codepen button to work but it's being affected by bootstrap css

I'm trying to get a Codepen button to work. After copying and implementing the code the buttons looks totally different than the given examples. It probably is affected by my use of Bootstrap CSS. What is a correct way to find and eliminate the Bootstrap code that is messing up the buttons?
Edit:
Below the code. Sorry for not providing it in the first place. Here is the codepen url with the original code:
https://codepen.io/soulwire/pen/bKens
HTML
<div class="container">
<div class="toggle">
<input type="checkbox">
<span class="button"></span>
<span class="label">+</span>
</div>
<div class="toggle">
<input type="checkbox" checked>
<span class="button"></span>
<span class="label">–</span>
</div>
</div>
CSS
#import compass
/* Squishy buttons */
#import url(http://fonts.googleapis.com/css?family=Lato:700)
html, body
font-family: 'Lato', sans-serif
background: url(http://s.cdpn.io/1715/dark_stripes.png)
text-align: center
height: 100%
.container
text-align: center
position: absolute
margin-top: -80px
width: 100%
top: 50%
.toggle
margin: 4px
display: inline-block
.toggle
$size: 140px
box-shadow: inset 0 0 35px 5px rgba(0,0,0,0.25), inset 0 2px 1px 1px
rgba(255,255,255,0.9), inset 0 -2px 1px 0 rgba(0,0,0,0.25)
border-radius: 8px
background: #ccd0d4
position: relative
height: $size
width: $size
&:before
$radius: $size * 0.845
$glow: $size * 0.125
box-shadow: 0 0 $glow $glow / 2 #fff
border-radius: $radius
background: #fff
position: absolute
margin-left: ( $radius - $glow ) * -0.5
margin-top: ( $radius - $glow ) * -0.5
opacity: 0.2
content: ''
height: $radius - $glow
width: $radius - $glow
left: 50%
top: 50%
.button
$radius: $size * 0.688
-webkit-filter: blur(1px)
-moz-filter: blur(1px)
filter: blur(1px)
transition: all 300ms cubic-bezier(0.230, 1.000, 0.320, 1.000)
box-shadow: 0 15px 25px -4px rgba(0,0,0,0.5), inset 0 -3px 4px -1px
rgba(0,0,0,0.2), 0 -10px 15px -1px rgba(255,255,255,0.6), inset 0 3px 4px
-1px rgba(255,255,255,0.2), inset 0 0 5px 1px rgba(255,255,255,0.8), inset 0
20px 30px 0 rgba(255,255,255,0.2)
border-radius: $radius
position: absolute
background: #ccd0d4
margin-left: $radius * -0.5
margin-top: $radius * -0.5
display: block
height: $radius
width: $radius
left: 50%
top: 50%
.label
transition: color 300ms ease-out
text-shadow: 1px 1px 3px #ccd0d4, 0 0 0 rgba(0,0,0,0.8), 1px 1px 4px #fff
line-height: $size - 1
text-align: center
position: absolute
font-weight: 700
font-size: 42px
display: block
opacity: 0.9
height: 100%
width: 100%
color: rgba(0,0,0,0.4)
input
opacity: 0
background :red
position: absolute
cursor: pointer
z-index: 1
height: 100%
width: 100%
left: 0
top: 0
&:active
~ .button
box-shadow: 0 15px 25px -4px rgba(0,0,0,0.4), inset 0 -8px 30px 1px
rgba(255,255,255,0.9), 0 -10px 15px -1px rgba(255,255,255,0.6), inset 0 8px
25px 0 rgba(0,0,0,0.4), inset 0 0 10px 1px rgba(255,255,255,0.6)
~ .label
font-size: 40px
color: rgba(0,0,0,0.45)
&:checked
~ .button
box-shadow: 0 15px 25px -4px rgba(0,0,0,0.4), inset 0 -8px 25px -1px
rgba(255,255,255,0.9), 0 -10px 15px -1px rgba(255,255,255,0.6), inset 0 8px
20px 0 rgba(0,0,0,0.2), inset 0 0 5px 1px rgba(255,255,255,0.6)
~ .label
font-size: 40px
color: rgba(0,0,0,0.4)

create multiple evenly spaced horizontal lines with only css

Is it possible to create multiple horizonal evenly spaced lines using only CSS? I am trying to replicate the look of a notecard and I would prefer not to use images. Seems like this should be possible. It looks like this person accomplished what i want to do, but they are using mozilla specific tags: Fiddle
Guess I have to add in code if I include a fiddle link.
The CSS from that page:
div {
background:
-moz-repeating-linear-gradient(center top , #fafafa, #fafafa 22px, #81CBBC 24px) repeat scroll 0 0 transparent;
border: 1px solid #f6f6f6;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
margin: 30px auto;
padding: 22px 15px 40px;
position: relative;
width: 400px;
color: #444;
}
h1 {
font: 24px/26px 'Helvetica Neue', Arial;
margin: 0 0 6px;
}
li {
font: 12px/16px Georgia;
margin: 0 0 7px;
}
div:before {
content: '';
z-index: -1;
width: 433px;
position: absolute;
bottom: -12px;
left: 4px;
height: 190px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.15);
background: -moz-repeating-linear-gradient(center top , #fafafa, #fafafa 22px, #81CBBC 24px) repeat scroll 0 0 transparent;
-moz-transform: rotate(-1deg);
}
div:after{
content: '';
z-index: -3;
width: 433px;
position: absolute;
bottom: -18px;
left: 6px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.15);
height: 190px;
background: -moz-repeating-linear-gradient(center top , #fafafa, #fafafa 22px, #81CBBC 24px) repeat scroll 0 0 transparent;
-moz-transform: rotate(-1deg);
}
Is this what you mean?
Fiddle
box-shadow:0 1px 0 1px #fff, 0 2px 0 1px #ccc, 0 4px 0 1px #fff, 0 5px 0 1px #ccc;

firefox chrome padding issue with button

I have a problem with a project, i don't know way, chrome and firefox are not display the same height with my buttons. I'd been looking around and I found that firefox has an issue with buttons, so i add the code below, but still doesn't work. What could it be?
.button-type::-moz-focus-inner { border: 0; padding: 0; margin:0; }
.button-type {
background: #a9a9a9;
-webkit-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 3px rgba(255,255,255,0.2), inset 0 2px rgba(255,255,255,0.2), inset 0 28px 22px rgba(255,255,255,0.2), inset 0 -10px 28px rgba(0,0,0,0.2);
box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 3px rgba(255,255,255,0.2), inset 0 2px rgba(255,255,255,0.2), inset 0 28px 22px rgba(255,255,255,0.2), inset 0 -10px 28px rgba(0,0,0,0.2);
font: Arial, Helvetica, sans-serif;
line-height: 1;
padding: 8px 15px;
width: auto;
height: auto;
border: none;
text-align: center;
font-size: 13px;
color: #fff;
cursor: pointer;
display: block;
text-decoration: none;
text-shadow: -1px -1px #333;
}
.button-type.black {
background: #000;
color: #fff;
}
.button-type.gray {
background: #a9a9a9;
}
.button-type.light-gray {
background: #d3d3d3;
color: #222;
}
Solve it the solution (and error) was:
display:block
replace it with:
display:inline

Resources