Skew text on bottom only - html

I have a requirement where I have to skew dynamic text only on the bottom, like so:
I'm not looking for actual code so much as I am a general approach, or even a gauge of feasibility.
What I've tried
So far, the only thing I've tried is floating a rounded image over the bottom of the character that's the same color as the background. This "works" for some letters without curved bottoms, like "N", but for letters like "O", this approach fails:
Is something like this possible using a combination of CSS transforms, or any other programmatic approach?

I think you need HTML5 Canvas for better results. But still i have a trick to do with just simple way:
UPDATE :
As you said you want just the bottom to get cut in a slant. I guess this is what you looking for.
body {
margin: 0px;
}
.container {
display: inline-block;
float: left;
width: 250px;
height: 250px;
font-family: impact, Calibri;
background: #E80000;
text-align: center;
overflow: hidden;
margin-right: 10px;
}
.skew {
display: block;
height: 170px;
width: 249px;
text-align: center;
font-size: 200px;
line-height: 200px;
color: white;
overflow: hidden;
}
.overlay {
position: relative;
display: block;
height: 20px;
text-align: center;
background: #E80000;
transform: skewY(-3deg);
/* Standard syntax */
margin-top: -5px;
}
<div class="container">
<div class="skew">
NO
</div>
<span class="overlay"></span>
</div>
For better understanding the trick have a look : http://jsfiddle.net/mt3d6vxh/3/

I think the only way of doing this would be a lot of jQuery/JavaScript to draw to a canvas.
This may help:
http://jsfiddle.net/joshnh/pXbVh/
html {
background: #ffe;
text-align: center;
}
.skewed {
display: inline-block;
font: 2em/1 impact, sans-serif;
margin-top: 5em;
position: relative;
-webkit-transform: rotate(-10deg) skew(-10deg, 0);
-moz-transform: rotate(-10deg) skew(-10deg, 0);
-ms-transform: rotate(-10deg) skew(-10deg, 0);
-o-transform: rotate(-10deg) skew(-10deg, 0);
transform: rotate(-10deg) skew(-10deg, 0);
}
.skewed:after,
.skewed:before {
background: #666;
box-shadow: inset 0 0 0 .5em #666,
inset 0 .7em 0 #666,
inset 0 .9em 0 #888,
inset 0 1.4em 0 #666,
inset 0 1.6em 0 #888,
inset 0 2.1em 0 #666,
inset 0 2.3em 0 #888,
inset 0 2.5em 0 #666;
content: '';
height: 3em;
position: absolute;
top: 0em;
width: 3.5em;
z-index: -1;
}
.skewed:after {
border-radius: .25em 0 0 .25em;
left: -2.5em;
}
.skewed:before {
border-radius: 0 .25em .25em 0;
right: -2.5em;
}
.skewed span {
background: #666;
box-shadow: 0 0 0 .2em #ffe;
color: #ffe;
padding: 1em;
position: relative;
text-shadow: 1px 2px 0 #666,
2px 3px 0 #888;
text-transform: uppercase;
}
Also if you want to try out the canvas route:
http://www.html5rocks.com/en/tutorials/canvas/texteffects/

Related

How to remove the bottom part of my ugly arrow mark in the pseudo `after` content

body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent ;
transform-origin: 0 0;
transform: rotate(135deg);
box-shadow: 0px 0px 5px rgba(0, 0, 0, .5);
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
Can you please replace ".triangle::after" with this code and check whether it solves you problem or not?
.triangle::after {
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent;
transform-origin: 0 0;
transform: rotate(135deg);
background: #fff;
box-shadow: -2px 2px 2px 1px rgb(233, 233, 233);
}
Just add z-index: -1; to the pseudo element to move it behind the main element:
body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent ;
transform-origin: 0 0;
transform: rotate(135deg);
box-shadow: 0px 0px 5px rgba(0, 0, 0, .5);
z-index: -1;
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
It may be help and also looks good
body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 17px;
right: 1%;
box-sizing: border-box;
border: 0.75em solid;
border-color: #fff;
transform-origin: 0 0;
transform: rotate(-133deg);
box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.3);
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
Same method use here.
Z-index: -1 is safe bro

Fading a div overflow into adjacent div

I am trying to create a card UI at: https://codepen.io/sarimabbas/pen/qjZYvr
.book_left {
width: 35%;
height: 300px;
float: left;
overflow-x: hidden;
background: transparent;
}
.book_left img {
width: auto;
height: 100%;
border-radius: 10px 0 0 10px;
-webkit-border-radius: 10px 0 0 10px;
-moz-border-radius: 10px 0 0 10px;
position: relative;
}
.book_right {
width: 65%;
height: 300px;
float: left;
background: #000000;
border-radius: 0 10px 10px 0;
-webkit-border-radius: 0 10px 10px 0;
-moz-border-radius: 0 10px 10px 0;
}
The problem I run into is that the left side of the card (which contains an image), can overflow onto the right. Instead of hiding this overflow, I would like to blend it into the div on the right, so that the text is not hidden and can be readable.
Would something like this be possible? I have tried to research combinations of floats, background image fades and divs but have been unsuccessful.
On a related note, what would be the steps needed to make such a card responsive?
I'm not sure I understand completely, but using the below code gives transparency allowing to see the text on top of the overflowed image. With a completely black background that's not an option.
.book_right {
width: 65%;
height: 300px;
float: left;
background: rgba(0,0,0, 0.5);
border-radius: 0 10px 10px 0;
-webkit-border-radius: 0 10px 10px 0;
-moz-border-radius: 0 10px 10px 0;
position: relative;
}
With regard to responsiveness, I would go for a flexbox instead of floats and use percentages instead of pixels for width and height.
#import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);
#import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
.book {
width: 450px;
height: 300px;
background: transparent;
position: static;
left: 0;
right: 0;
margin: auto;
top: 0;
bottom: 0;
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
box-shadow: 0 2px 1px 0 #777;
}
.book_left {
width: 35%;
height: 300px;
float: left;
overflow-x: visible;
background: transparent;
}
.book_left img {
width: auto;
height: 100%;
border-radius: 10px 0 0 10px;
-webkit-border-radius: 10px 0 0 10px;
-moz-border-radius: 10px 0 0 10px;
position: relative;
}
.book_right {
width: 65%;
height: 300px;
float: left;
background: rgba(0,0,0, 0.5);
border-radius: 0 10px 10px 0;
-webkit-border-radius: 0 10px 10px 0;
-moz-border-radius: 0 10px 10px 0;
position: relative;
}
.book_right h1 {
color: white;
font-family: 'Montserrat', sans-serif;
font-weight: 400;
text-align: left;
font-size: 20px;
margin: 30px 0 0 0;
padding: 0 0 0 40px;
letter-spacing: 1px;
}
.book_right_details ul {
list-style-type: none;
padding: 0 0 0 40px;
margin: 10px 0 0 0;
}
.book_right_details ul li {
display: inline;
color: #e3e3e3;
font-family: 'Montserrat', sans-serif;
font-weight: 400;
font-size: 14px;
padding: 0 40px 0 0;
}
.book_right_blurb p {
color: white;
font-family: 'Montserrat', sans-serif;
font-size: 12px;
padding: 0 40px 0 40px;
letter-spacing: 1px;
margin: 10px 0 10px 0;
line-height: 20px;
}
.book_right_blurb a {
text-decoration: none;
font-family: 'Montserrat', sans-serif;
font-size: 14px;
padding: 0 0 0 40px;
color: #2ecc71;
margin: 0;
}
.book_right_button {
padding: 0 0 0 40px;
margin: 15px 0 0 0;
}
.book_right_button a {
color: #2ecc71;
text-decoration: none;
font-family: 'Montserrat', sans-serif;
border: 2px solid #2ecc71;
padding: 5px 5px 5px 5px;
font-size: 12px;
border-radius: 5px;
-webkit-transition-property: all;
transition-property: all;
-webkit-transition-duration: .5s;
transition-duration: .5s;
}
.book_right_button a:hover {
color: #000000;
background-color: #2ecc71;
cursor: pointer;
-webkit-transition-property: all;
transition-property: all;
-webkit-transition-duration: .5s;
transition-duration: .5s;
}
<div class='book'>
<div class='book_left'>
<img src='http://images.gr-assets.com/books/1474171184l/136251.jpg'>
</div>
<div class='book_right'>
<h1>Harry Potter and the Deathly Hallows</h1>
<div class='book_right_details'>
<ul>
<li>JK Rowling</li>
<li>Fiction</li>
</ul>
<div class='book_right_blurb'>
<p>Harry meets his destiny in the final book of Rowling's acclaimed series.</p>
</div>
<div class='book_right_button'>
<a href='https://www.youtube.com/watch?v=ot6C1ZKyiME' target='_blank'>READ BOOK</a>
</div>
</div>
</div>
</div>
There's a few approaches to this problem but the simplest I can think of is something like applying a gradient background to the right hand box and setting .book's background to be black. So something like the following (will need some polishing of course)
#import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);
#import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
.book {
width: 450px;
height: 300px;
margin: auto;
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
box-shadow: 0 2px 1px 0 #777;
background: #000;
}
.book_left {
width: 35%;
height: 300px;
float: left;
}
.book_left img {
width: auto;
height: 100%;
border-radius: 10px 0 0 10px;
-webkit-border-radius: 10px 0 0 10px;
-moz-border-radius: 10px 0 0 10px;
/* No need for relative or z-indexes if our layers are in order (later in markup = "higher" layer for position: static) */
}
.book_right {
width: 65%;
height: 300px;
float: left;
border-radius: 0 10px 10px 0;
-webkit-border-radius: 0 10px 10px 0;
-moz-border-radius: 0 10px 10px 0;
/* Gradient that sits on left of right panel - black background has also been applied to .book so that if the image doesn't fit the width we won't end up with weird chunks of missing background */
/* Generated gradient via: http://colorzilla.com/gradient-editor/ then tweaked a little */
background: -moz-linear-gradient(left, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 10px, rgba(0,0,0,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 10px,rgba(0,0,0,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 10px,rgba(0,0,0,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00000000', endColorstr='#000000',GradientType=1 ); /* IE6-9 */
}
.book_right h1 {
color: white;
font-family: 'Montserrat', sans-serif;
font-weight: 400;
text-align: left;
font-size: 20px;
margin: 30px 0 0 0;
padding: 0 0 0 40px;
letter-spacing: 1px;
}
.book_right_details ul {
list-style-type: none;
padding: 0 0 0 40px;
margin: 10px 0 0 0;
}
.book_right_details ul li {
display: inline;
color: #e3e3e3;
font-family: 'Montserrat', sans-serif;
font-weight: 400;
font-size: 14px;
padding: 0 40px 0 0;
}
.book_right_blurb p {
color: white;
font-family: 'Montserrat', sans-serif;
font-size: 12px;
padding: 0 40px 0 40px;
letter-spacing: 1px;
margin: 10px 0 10px 0;
line-height: 20px;
}
.book_right_blurb a {
text-decoration: none;
font-family: 'Montserrat', sans-serif;
font-size: 14px;
padding: 0 0 0 40px;
color: #2ecc71;
margin: 0;
}
.book_right_button {
padding: 0 0 0 40px;
margin: 15px 0 0 0;
}
.book_right_button a {
color: #2ecc71;
text-decoration: none;
font-family: 'Montserrat', sans-serif;
border: 2px solid #2ecc71;
padding: 5px 5px 5px 5px;
font-size: 12px;
border-radius: 5px;
-webkit-transition-property: all;
transition-property: all;
-webkit-transition-duration: .5s;
transition-duration: .5s;
}
.book_right_button a:hover {
color: #000000;
background-color: #2ecc71;
cursor: pointer;
-webkit-transition-property: all;
transition-property: all;
-webkit-transition-duration: .5s;
transition-duration: .5s;
}
<div class='book'>
<div class='book_left'>
<img src='http://images.gr-assets.com/books/1474171184l/136251.jpg'>
</div>
<div class='book_right'>
<h1>Harry Potter and the Deathly Hallows</h1>
<div class='book_right_details'>
<ul>
<li>JK Rowling</li>
<li>Fiction</li>
</ul>
<div class='book_right_blurb'>
<p>Harry meets his destiny in the final book of Rowling's acclaimed series.</p>
</div>
<div class='book_right_button'>
<a href='https://www.youtube.com/watch?v=ot6C1ZKyiME' target='_blank'>READ BOOK</a>
</div>
</div>
</div>
</div>
Making it responsive you could set a % width on .book and probably float it.
The caveat to my approach is that if the image doesn't overflow it will have a hard edge so it may look strange next to ones that don't do overflow. You could attack this by also setting a percentage width on the images but you'd need to be cautious of images with largely different proportions and ensure that they always cover the 300px height. Alternatively you could set the images as a background image on .book_left and set background-size: cover
I'd usually suggest in this instance to crop images to consistent proportions to avoid the need for fading the overflow as it'll make your life a lot easier in the long run.
An alternate approach to the fade that might be more consistent would be to relatively position .book_left then place an absolutely positioned div within it with a gradient background which is layered on top of the image so something like a div with the following properties added within .book_left
position: absolute;
right: 0;
z-index: 1;
width: 10px;
background: -moz-linear-gradient .....
This combined with an image that fills the container should give you a more consistent look if you want the fade there

How to animate input box from page center to the top of the page on input focus in css?

I think this is very simple, but I'm not sure how it's implemented. So let's say I have an input field that is originally centered to the page (vertically & horizontally). However, I want to animate the input box to the top of the page when the user starts typing, how would this be implemented? My initial thought would be to assign the top:0 and transform it on focus. Is it more complex than that?
Please enlighten me.
input.input-student-search {
position: absolute;
top: 50%;
transform: translateY(0px);
padding: 27px 145px 27px 38px;
margin: 10px;
width: 100%;
border: none;
box-shadow: 0 10px 20px rgba(198, 198, 198, 0.02), 0 6px 6px rgba(221, 221, 221, 0.23);
border-radius: 6px;
text-align: left;
&:focus {
top: 0;
}
}
This is how I did it:
.txt {
position: relative;
text-align: center;
width: 90%;
margin: 0 20px 0 20px;
top: 200px;
transition: top 0.4s;
}
.txt:focus{
top:0;
}
Here is the JSFiddle demo
Just put top:0 in a :focus style:
input.input-student-search:focus {
top:0;
}
input.input-student-search {
background-color:#AAA;
position: absolute;
top: 50%;
transform: translateY(0px);
padding: 27px 145px 27px 38px;
margin: 10px;
width: 100%;
border: none;
box-shadow: 0 10px 20px rgba(198, 198, 198, 0.02), 0 6px 6px rgba(221, 221, 221, 0.23);
border-radius: 6px;
text-align: left;
transition:top 1s linear;
}
input.input-student-search:focus {
top:0;
}
<input class="input-student-search" type="text"/>

Css box shadow moving to the top and left

CSS & Html:
body {background:#ccc}
.box h3{
text-align:center;
position:relative;
top:80px;
}
.box {
width:70%;
height:200px;
background:#FFF;
margin:40px auto;
}
.effect3
{
position: relative;
}
.effect3:before
{
z-index: -1;
position: absolute;
content: "";
bottom: 15px;
left: 10px;
width: 50%;
top: 80%;
max-width:300px;
background: #777;
-webkit-box-shadow: 0 15px 10px #777;
-moz-box-shadow: 0 15px 10px #777;
box-shadow: 0 15px 10px #777;
-webkit-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
-ms-transform: rotate(-3deg);
transform: rotate(-3deg);
}
<div class="box effect3">
<h3>Effect 3</h3>
</div>
I am trying to decorate a box with a shadow.
The above css is for the shadow bottom and left (in the red circle).
What can be the css to apply to the top and left (red arrow)?
Please use these code for top left box-shadow:
.effect3:before {
z-index: -1;
position: absolute;
content: "";
bottom: 15px;
left: 3px;
width: 18%;
top: 24px;
max-width: 300px;
background: #777;
-webkit-box-shadow: -8px 15px 10px #777;
-moz-box-shadow: -8px 15px 10px #777;
-webkit-transform: rotate(87deg);
-moz-transform: rotate(87deg);
transform: rotate(87deg);
}
body {
background: #ccc
}
.box h3 {
text-align: center;
position: relative;
top: 80px;
}
.box {
width: 70%;
height: 200px;
background: #FFF;
margin: 40px auto;
}
.effect3 {
position: relative;
}
.effect3:before {
z-index: -1;
position: absolute;
content: "";
left: -46px;
width: 20%;
bottom: 15px;
top: 25%;
max-width: 300px;
height: 20px;
background: #777;
-webkit-box-shadow: 0 15px 10px #777;
-moz-box-shadow: 0 15px 10px #777;
box-shadow: -10px -5px 10px #777;
-webkit-transform: rotate(-93deg);
-moz-transform: rotate(-93deg);
-o-transform: rotate(-93deg);
-ms-transform: rotate(-93deg);
transform: rotate(-93deg);
}
I think this is what you asking...
-webkit-box-shadow: -6px -8px 5px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: -6px -8px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: -6px -8px 5px 0px rgba(50, 50, 50, 0.75);
Generated using http://css3gen.com/box-shadow/
Use an after and changing the before like so:
.effect3:before {
z-index: -1;
position: absolute;
content: "";
left: 15px;
width: 50%;
bottom: 15px;
top: 4%;
max-width: 300px;
height: 20px;
background: #777;
-webkit-box-shadow: 0 15px 10px #777;
-moz-box-shadow: 0 15px 10px #777;
box-shadow: -10px -5px 10px #777;
-webkit-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
-ms-transform: rotate(-3deg);
transform: rotate(3deg);
}
.effect3:after {
z-index: -1;
position: absolute;
content: "";
bottom: 15px;
left: 10px;
width: 50%;
top: 80%;
max-width: 300px;
background: #777;
-webkit-box-shadow: 0 15px 10px #777;
-moz-box-shadow: 0 15px 10px #777;
box-shadow: 0 15px 10px #777;
-webkit-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
-ms-transform: rotate(-3deg);
transform: rotate(-3deg);
}
Here is the JSFiddle demo

Glowing effect on orb/sphere/ball/globe in css

I have been attempting to make a glowing effect on a sphere in terms of internal 'shiny sphere' patterns, but have become stuck with the likes of positioning some aspects of the 'globe'.
As it currently stands, my css looks like:
.sphere {
height: 200px;
width: 200px;
background-color: red;
border-radius: 50%;
text-align: center;
vertical-align: middle;
line-height: 200px;
box-shadow: inset -10px -10px 100px #000, 10px 10px 20px black, inset 0px 0px 10px black;
}
.sphere::after {
background-color: rgba(255, 255, 255, 1);
content: '';
height: 15%;
width: 2%;
position: absolute;
top: 0.25%;
left: 3%;
border-radius: 50%;
transform: rotate(45deg);
}
.sphere2 {
height: 200px;
width: 200px;
background-color: yellow;
border-radius: 50%;
text-align: center;
vertical-align: middle;
line-height: 200px;
box-shadow: inset -10px -10px 100px #000, 10px 10px 20px black, inset 0px 0px 10px black;
}
.shine {
background-color: rgba(255, 255, 255, 0.5);
content: '';
height: 50%;
width: 15%;
left: 18%;
top: 0%;
position: relative;
border-radius: 50%;
transform: rotate(45deg);
}
<div class="sphere">High Importance</div>
<div class="sphere2">
<div class="shine"></div>
Important
</div>
CODEPEN
But the 'shine' effect on either sphere won't 'stay' in place. (Neither attempts full work).
Would anyone be able to point me in the right direction as to position these correctly (in the top left hand side, with a small margin)?
This will hopefully/eventually look similar to this (without the animated effect, that is)
Any advice would be much appreciated at this point (and i hope you can see where i'm going with this design, as i wish for it to be dynamically sized).
Just remember when you use absolute position you need to define the relative parent to position, this will be the closest with a non-static position defined. Try:
.sphere{
position:relative;
}
.sphere::after{
background-color: rgba(255,255,255,.5);
content:'';
height:50%;
width: 15%;
left:18%;
top:0%;
position:absolute;
border-radius:50%;
transform: rotate(45deg);
}
Codepen Updated
Position your .sphere and .sphere2 relatively and the ::after :pseudo-elements absolutely and give them same top and left values.
codepen
.sphere {
position: relative;
height: 200px;
width: 200px;
background-color: red;
border-radius: 50%;
text-align: center;
vertical-align: middle;
line-height: 200px;
box-shadow: inset -10px -10px 100px #000, 10px 10px 20px black, inset 0px 0px 10px black;
}
.sphere::after,
.sphere2::after {
background-color: rgba(255, 255, 255, 1);
content: '';
height: 40%;
width: 10%;
position: absolute;
top: 8%;
left: 14%;
border-radius: 50%;
transform: rotate(45deg);
}
.sphere2 {
height: 200px;
width: 200px;
position: relative;
background-color: yellow;
border-radius: 50%;
text-align: center;
vertical-align: middle;
line-height: 200px;
box-shadow: inset -10px -10px 100px #000, 10px 10px 20px black, inset 0px 0px 10px black;
}
.sphere2::after {
background-color: rgba(255, 255, 255, 0.5);
content: '';
position: absolute;
border-radius: 50%;
transform: rotate(45deg);
}
<div class="sphere">High Importance</div>
<div class="sphere2">
<div class="shine"></div>
Important
</div>