Related
I have a card with a flip effect when hovering it. The card has a background image, and each side has a color to transparent gradient.
When the card flips, the background-image position is on top, over gradient and div content. Without background-image the effect is fine.
How can I solve this issue and put the image under content and gradient?
Here is a codepen with the code https://codepen.io/ramonsan/pen/QJpgrv
.flip-card {
perspective: 1000px;
height: 400px;
width: 300px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
padding: 1em;
padding-top: 5rem;
}
.flip-card-front {
background: -moz-linear-gradient(top, rgba(100, 153, 210, 1) 28%, rgba(109, 165, 218, 1) 55%, rgba(125, 185, 232, 0) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(100, 153, 210, 1) 28%, rgba(109, 165, 218, 1) 55%, rgba(125, 185, 232, 0) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(100, 153, 210, 1) 28%, rgba(109, 165, 218, 1) 55%, rgba(125, 185, 232, 0) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6499d2', endColorstr='#007db9e8', GradientType=0);
/* IE6-9 */
color: white;
}
.flip-card-back {
transform: rotateY(180deg);
background: -moz-linear-gradient(top, rgba(255, 255, 255, 1) 1%, rgba(255, 255, 255, 1) 10%, rgba(255, 255, 255, 0.5) 80%, rgba(255, 255, 255, 0) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 1) 1%, rgba(255, 255, 255, 1) 10%, rgba(255, 255, 255, 0.5) 80%, rgba(255, 255, 255, 0) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 1%, rgba(255, 255, 255, 1) 10%, rgba(255, 255, 255, 0.5) 80%, rgba(255, 255, 255, 0) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff', GradientType=0);
/* IE6-9 */
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
<div class="flip-card col-6 col-md-4 pb-4 mb-0">
<div class="flip-card-inner" style="background-image: url(https://images.wallpaperscraft.com/image/glare_circles_spots_background_dots_bright_61905_240x400.jpg);">
<div class="flip-card-front">
<h1>FRONT</h1>
</div>
<div class="flip-card-back">
<h2>Back</h2>
</div>
</div>
</div>
Consider using the background image inside the inner divs. I used a CSS variable to make it easy to handle and avoid defining the image within the CSS so you can keep adjusting it through the inline style.
.flip-card {
perspective: 1000px;
height: 400px;
width: 300px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
padding: 1em;
padding-top: 5rem;
}
.flip-card-front {
background:
linear-gradient(to bottom, rgba(100, 153, 210, 1) 28%, rgba(109, 165, 218, 1) 55%, rgba(125, 185, 232, 0) 100%),
var(--i);
color: white;
}
.flip-card-back {
transform: rotateY(180deg);
background:
linear-gradient(to bottom, rgba(255, 255, 255, 1) 1%, rgba(255, 255, 255, 1) 10%, rgba(255, 255, 255, 0.5) 80%, rgba(255, 255, 255, 0) 100%),
var(--i);
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
<div class="flip-card col-6 col-md-4 pb-4 mb-0">
<div class="flip-card-inner" style="--i: url(https://images.wallpaperscraft.com/image/glare_circles_spots_background_dots_bright_61905_240x400.jpg);">
<div class="flip-card-front">
<h1>FRONT</h1>
</div>
<div class="flip-card-back">
<h2>Back</h2>
</div>
</div>
</div>
how to make a button with an obtuse angle?
I would like to happen like this
I got here so
My code - Fiddle
*{
box-sizing: border-box;
}
.btn{
display: inline-block;
padding: 16px 30px;
color: #fff;
border: 1px solid #4A803C;
position: relative;
border-radius: 3px;
background: rgb(74,168,28); /* Old browsers */
background: -moz-linear-gradient(top, rgba(74,168,28,1) 0%, rgba(63,155,19,1) 100%, rgba(56,146,12,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(74,168,28,1) 0%,rgba(63,155,19,1) 100%,rgba(56,146,12,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(74,168,28,1) 0%,rgba(63,155,19,1) 100%,rgba(56,146,12,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4aa81c', endColorstr='#38920c',GradientType=0 );
}
.btn > span{
position:relative;
z-index: 1;
}
.btn:after {
content: "";
width: 35px;
height: 35px;
display: block;
position: absolute;
top: 7px;
right: -18px;
border: 1px solid #4A803C;
border-left: none;
border-bottom: none;
border-radius: 3px;
-webkit-transform: rotate(47deg) skew(5deg);
transform: rotate(47deg) skew(5deg);
background-image: -moz-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -webkit-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -ms-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
}
.btn:hover{
background: rgb(56,146,12); /* Old browsers */
background: -moz-linear-gradient(top, rgba(56,146,12,1) 0%, rgba(63,155,19,1) 0%, rgba(74,168,28,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(56,146,12,1) 0%,rgba(63,155,19,1) 0%,rgba(74,168,28,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(56,146,12,1) 0%,rgba(63,155,19,1) 0%,rgba(74,168,28,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#38920c', endColorstr='#4aa81c',GradientType=0 );
}
.btn:hover:after{
background-image: -moz-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -webkit-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -ms-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
}
<a href="#" class="btn">
<span>Умножитель матрицы</span>
</a>
I would be glad of any help.
Thank you
A simple solution would be to add a rotateY(Xdeg) to the .btn:after element. This would make the element's Y-axis get rotated and thus would make it look narrower than it actually is.
Rotation angle can be modified as required. It can be any value below 90 degrees depending on how wide or narrow the arrow should be. Higher the value the narrower the arrow would be.
* {
box-sizing: border-box;
}
.btn {
display: inline-block;
padding: 16px 30px;
color: #fff;
border: 1px solid #4A803C;
position: relative;
border-radius: 3px;
background: rgb(74, 168, 28);
background: linear-gradient(to bottom, rgba(74, 168, 28, 1) 0%, rgba(63, 155, 19, 1) 100%, rgba(56, 146, 12, 1) 100%);
}
.btn > span {
position: relative;
z-index: 1;
}
.btn:after {
content: "";
width: 35px;
height: 35px;
display: block;
position: absolute;
top: 7px;
right: -18px;
border: 1px solid #4A803C;
border-left: none;
border-bottom: none;
border-radius: 3px;
transform: rotateY(45deg) rotate(47deg) skew(5deg);
background-image: linear-gradient(143deg, rgb(74, 168, 28) 0%, rgb(63, 155, 19) 100%);
}
.btn:hover {
background: rgb(56, 146, 12);
background: linear-gradient(to bottom, rgba(56, 146, 12, 1) 0%, rgba(63, 155, 19, 1) 0%, rgba(74, 168, 28, 1) 100%);
}
.btn:hover:after {
background-image: linear-gradient(-47deg, rgb(74, 168, 28) 0%, rgb(63, 155, 19) 100%);
}
<a href="#" class="btn">
<span>Умножитель матрицы</span>
</a>
I have a div with some content that I want the text fade effect at the bottom. In order to do that I have to use position: fixed; inside a div with overflow-y:scroll
The div that gives the fade effect does not appear. I have tried different solutions but none have worked inside a div.
Here is a jsFiddle example of the code
I would try using absolute positioning. Something like:
JS Fiddle
.outer {
height: 200px;
border: 2px solid black;
position: relative;
overflow: hidden;
}
.content {
height: 100%;
overflow: scroll;
}
.fadeout {
width: 100%;
height: 40px;
position: absolute;
display: block;
bottom: 0;
left: 0;
z-index: 1;
background: -moz-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 90%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(95%, rgba(255, 255, 255, 1)));
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 90%);
background: -o-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 90%);
background: -ms-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 90%);
background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 90%);
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff', GradientType=0);
}
Note that I put overflow: scroll on .content instead of .outer to keep the blur from scrolling.
Using fixed positing will place the blur at the bottom of the user's viewport, rather than the element.
I'm attempting to create a button style for a client, and cannot seem to get it working using the after pseudo-class.
<style>
$varBase: 40px;
$imsblue: #012169;
$imsgrey: #012169;
body {
background:grey;
}
.btn {
position: relative;
float: left;
height: $varBase;
font-family: sans-serif;
text-align: center;
line-height: $varBase;
color: white;
white-space: nowrap;
text-transform: uppercase;
background: $imsblue;
&:before {
float: left;
content:"";
width: ($varBase/4);
height: ($varBase/2);
}
&:after {
position: absolute;
content:"";
height: ($varBase/2);
border-left: ($varBase/2) solid $imsblue;
border-bottom: ($varBase/2) solid transparent;
}
a {
color: white;
text-decoration:none;
padding: ($varBase/4) ($varBase/2);
margin-right: -10px;
}
}
.btn3 {
display: inline;
color: white;
background: linear-gradient(135deg, rgba(1,33,105,1) 0%, rgba(1,33,105,1) 93%, rgba(30, 87, 153, 0) 93%, rgba(30, 87, 153, 0) 100%);
outline: 0;
border: 0;
padding: 10px 0px;
a {
color: inherit ;
text-transform: uppercase;
text-decoration:none;
padding: ($varBase/4) $varBase;
}
}
</style>
<div class="btn">Click to Submit</div>
<div class="btn3">Click to Submit</div>
I can get it to show using two DIVs, but I need this to work with just one class. Can someone help me see what I'm doing wrong?
It's supposed to look like this (barring color and size of course):
I believe the key element missing is that you need to include a content:"" in your :after pseudoclass. See the example below.
.btn {
height: 40px;
background: red;
width: 128px;
float:left;
}
.btn:after {
width: 0px;
height: 20px;
border-left: 20px solid red;
border-bottom: 20px solid white;
float:right;
content:"";
}
<div class="btn">Button</div>
This will work - I had to convert your SCSS to CSS, but it's clear enough.
.btn {
height: 40px; width: 200px;
background: red;
position: relative; /* work as container */
}
.btn:after {
content: ''; /* needed */
display: block;
position: absolute; /* position to container */
right: 0; bottom: 0;
border-left: 20px solid red;
border-bottom: 20px solid white;
}
<div class="btn">Button</div>
Unfortunately, you can't have "transparent" overlay, it just wont work. I had to use white for it.
I found a solution that works where the "cut" is transparent. You can use regular background or image background for the button:
http://jsfiddle.net/q45w2f78/
<div class="buttoncut gon">My button</div>
CSS:
.gon {
width: 220px;
height: 220px;
background: darkblue;
background-size: 220px 220px;
/* Text styling */
line-height: 220px;
text-align: center;
font-family: sans-serif;
font-size: 15px;
font-weight: bold;
letter-spacing: 6px;
color: beige;
}
.gon:hover {
color: #fff;
text-shadow: 0 0 10px white;
}
.buttoncut {
height: 200px;
-webkit-clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%);
-moz-clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%);
-ms-clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%);
clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%);
}
I used this generator to get the correct polygon css: http://bennettfeely.com/clippy/
Gradients:
You could use gradients in order to achieve this, and that way you can apply it to any element (this one's done with a button element):
html,body{
background:red;
}
button {
background: -moz-linear-gradient(-45deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, rgba(30, 87, 153, 1)), color-stop(89%, rgba(30, 87, 153, 1)), color-stop(90%, rgba(30, 87, 153, 0)), color-stop(100%, rgba(30, 87, 153, 0)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* IE10+ */
background: linear-gradient(135deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1e5799', endColorstr='#001e5799', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
outline:0;
border:0;
padding:5px;
}
<button>PressMe</button>
Pseudo Element (not great for gradient/image backgrounds)
div {
position: relative;
display:inline-block;
padding:5px;
background:gray;
}
div:after{
content:"";
position:absolute;
border-bottom:10px solid blue;
border-left:10px solid transparent;
bottom:0;
right:0;
}
html,body{
background:blue;
}
<div>Press Me!</div>
Clip Path
button {
padding: 10px;
height: 60px;
width: 60px;
-webkit-clip-path: polygon(0% 0%, 100% 0, 100% 75%, 75% 100%, 0% 100%);
clip-path: polygon(0% 0%, 100% 0, 100% 75%, 75% 100%, 0% 100%);
}
html,body{
background:green;
}
<button>press me!!!</button>
Dynamic length
by using the following snippet, you can make a great button, which isn't affected by length!
button {
position: relative;
border: 0;
outline: 0;
height: 20px;
background: gray;
}
button:after {
position: absolute;
content: "";
right: -10px;
width: 0px;
height: 0px;
bottom: 0;
border-bottom: 10px solid transparent;
border-left: 10px solid gray;
}
button:before {
position: absolute;
content: "";
right: -10px;
width: 10px;
height: 10px;
top: 0;
background: gray;
}
html,
body {
background: red;
}
/*HOVER EFFECTS*/
button:hover,
button:hover:before {
background: yellow;
}
button:hover:after {
border-left: 10px solid yellow;
}
<button>press me and plus i can get really long!</button>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to create the following Banner:
http://schuub.net/banner.png
My question is,
how can I create this gardient from white to transparent which overlays the image partially on the left.
My html can be found here:
http://schuub.net/banner.html
<!doctype html>
<html lang="en">
<head>
<style>
body {
margin: 0 auto;
width: 1024px;
}
.my-banner {
background-repeat: no-repeat;
background-position: right -175px;
background-image: url("http://sphotos-c.ak.fbcdn.net/hphotos-ak-ash3/s720x720/3755_4323318453951_692396489_n.jpg");
height: 200px;
width: 100%;
position: relative;
border:solid 1px;
}
.banner-data {
position: absolute;
left: 0;
top: 0;
width: 70%;
height: 100%;
background: -ms-linear-gradient(left, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* IE10+ */
border:solid 1px;
}
</style>
</head>
<body>
<div class="my-banner">
<div class="banner-data">
</div>
</div>
</body>
</html>
Cheers,
Stefan
Try this:
FIDDLE
HTML
<div class="my-banner"></div>
CSS
body {
margin: 0 auto;
width: 1024px;
}
.my-banner {
background-repeat: no-repeat;
background-position: right -175px;
background-image: url("http://sphotos-c.ak.fbcdn.net/hphotos-ak-ash3/s720x720/3755_4323318453951_692396489_n.jpg");
height: 200px;
width: 1024px;
background: url('http://648290826.r.cdn77.net/wp-content/uploads/2013/02/slider2.jpg') no-repeat;
}
.my-banner:after {
content:" ";
height: 200px;
width: 1024px;
position: absolute;
z-index: 1;
top: 0;
left: 0;
border: 1px solid black;
background: -moz-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 0) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(33%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(255, 255, 255, 0)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 0) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 0) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 0) 100%);
/* IE10+ */
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 0) 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#00ffffff', GradientType=1);
/* IE6-9 */
}
Either use graphic design software such as Photoshop and use an image, or use the following resource: http://www.colorzilla.com/gradient-editor/
This will automatically create the CSS required for the gradient.