I am animating a background to move but as expected using Background-position results in poor performance.
I am unable to alter or change the HTML or add any scripts
I have attempted using translate but this moves the entire div element rather than just the background, As mentioned I am not able to create a separate div for the background alone resulting in this roadblock.
.wm-outer-div {
width: auto !important;
min-width: 400px !important;
max-width: 500px !important;
padding: 0 !important;
-moz-box-sizing: border-box !important;
box-sizing: border-box !important;
border-radius: 15px !important;
box-shadow: rgba(50, 50, 50, 0.45) 0px 0px 10px 0px;
background-color: rgb(255, 255, 255);
padding: 18px 22px 20px;
position: absolute;
width: 304px;
color: rgb(55, 55, 55);
font-family: walkme-opensans, sans-serif;
display: block;
margin: 0px;
vertical-align: baseline;
border-collapse: inherit;
background-image: none;
line-height: normal;
height: 300px;
text-indent: inherit;
letter-spacing: normal;
text-transform: none;
text-shadow: none;
border-style: none;
border-width: medium;
transition: none 0s ease 0s;
box-sizing: content-box;
direction: ltr;
z-index: 2147483632;
opacity: 1;
}
.wm-outer-div:after {
content: "" !important;
z-index: -1 !important;
background-color: #1E365E !important;
background-image: url("https://www.dropbox.com/s/zrzzbsa5b39w8ra/image.jpg dl=1") !important;
position: absolute !important;
top: 0;
left: 0;
width: 100% !important;
height: 100% !important;
animation: slide 120s linear infinite !important;
repeat: repeat !important;
-moz-box-sizing: border-box !important;
box-sizing: border-box !important;
border-radius: 15px !important;
}
#keyframes slide {
from {
transform: translateY(0);
}
to {
transform: translateY(-187%);
}
}
<div class="wm-outer-div wm-shoutout wm-shoutout-165013 wm-template-bg wm-template-small-corner wm-ltr wm-chrome wm-design-template-207418 wm-position-center" id="wm-shoutout-165013"></div>
Is there a way to target the background image separately to use translate without the addition of another div/wrapper so only the background moves and not the entire div element?
Failing that is there another option that could improve the performance of the background animation?
Make the pseudo element bigger to be sure you will cover the needed area when translating:
.wm-outer-div {
min-width: 400px !important;
max-width: 500px !important;
padding: 0 !important;
-moz-box-sizing: border-box !important;
box-sizing: border-box !important;
border-radius: 15px;
box-shadow: rgba(50, 50, 50, 0.45) 0px 0px 10px 0px;
background-color: rgb(255, 255, 255);
padding: 18px 22px 20px;
width: 304px;
color: rgb(55, 55, 55);
height: 300px;
z-index: 0;
position:relative;
overflow:hidden;
}
.wm-outer-div:after {
content: "";
z-index: -1;
background-color: #1E365E !important;
background-image:url(https://i.stack.imgur.com/DpyrV.jpg);
background-size:cover;
position: absolute;
top: -100%;
left: -100%;
width: 300% ;
height: 300%;
animation: slide 2s linear infinite alternate;
box-sizing: border-box;
}
#keyframes slide {
from {
transform: translateY(33%);
}
to {
transform: translateY(-33%);
}
}
<div class="wm-outer-div wm-shoutout wm-shoutout-165013 wm-template-bg wm-template-small-corner wm-ltr wm-chrome wm-design-template-207418 wm-position-center" id="wm-shoutout-165013"></div>
.wm-outer-div {
width: auto !important;
min-width: 400px !important;
max-width: 500px !important;
padding: 0 !important;
-moz-box-sizing: border-box !important;
box-sizing: border-box !important;
border-radius: 15px !important;
box-shadow: rgba(50, 50, 50, 0.45) 0px 0px 10px 0px;
background-color: rgb(255, 255, 255);
padding: 18px 22px 20px;
position: absolute;
width: 304px;
color: rgb(55, 55, 55);
font-family: walkme-opensans, sans-serif;
display: block;
margin: 0px;
vertical-align: baseline;
border-collapse: inherit;
background-image: none;
line-height: normal;
height: 300px;
text-indent: inherit;
letter-spacing: normal;
text-transform: none;
text-shadow: none;
border-style: none;
border-width: medium;
transition: none 0s ease 0s;
box-sizing: content-box;
direction: ltr;
z-index: 2147483632;
opacity: 1;
overflow: hidden
}
.wm-outer-div:after {
content: "";
background-image: url("https://thumbs-prod.si-cdn.com/c3phl1TZgQ92bLQugItmtovLZhs=/fit-in/1600x0/https://public-media.si-cdn.com/filer/54/10/5410da58-2295-4e3a-a847-fecd41cdcdd9/scarlet_tanager.jpg") !important;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: translateX(-150px) translateY(150px)
}
<div class="wm-outer-div wm-shoutout wm-shoutout-165013 wm-template-bg wm-template-small-corner wm-ltr wm-chrome wm-design-template-207418 wm-position-center" id="wm-shoutout-165013"></div>
Related
I found this nice button on CodePen that inverts the button color with a ripple effect, using a radial-gradient animation.
I need it to have a 28px border radius, but then a jagged border appears as shown here.
html {
box-sizing: border-box;
height: 100%;
font-size: 10px;
}
*, *::before, *::after {
box-sizing: inherit;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #57bd84;
}
input[type=checkbox] {
height: 0;
width: 0;
visibility: hidden;
}
input[type=checkbox]:checked + label:after {
transform: scale(4.2);
}
label {
outline: none;
user-select: none;
color: #000;
font-family: 'Lato', sans-serif;
font-size: 2.5rem;
letter-spacing: 0.04rem;
padding: 1.5rem 3rem;
cursor: pointer;
border-radius: 28px;
border: 0.3rem solid #000;
background: #fff;
position: relative;
overflow: hidden;
box-shadow: 0 3px 0 0 #000;
}
label::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
transform: scale(0);
transition: transform 0.3s ease-in;
mix-blend-mode: difference;
background: radial-gradient(circle at center, #fff 24%, #000 25%, #000 100%);
}
label:active {
top: 3px;
box-shadow: none;
}
<input type="checkbox" id="cb1" /><label for="cb1">Toggle me</label>
I would do it differently using the other pseudo element where I will have the border to avoid this bad effect. I will also replace the scale transition with a background-size effect
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-size: 10px;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #57bd84;
margin:0;
}
input[type=checkbox] {
height: 0;
width: 0;
visibility: hidden;
}
label {
outline: none;
user-select: none;
color: #000;
font-family: 'Lato', sans-serif;
font-size: 2.5rem;
letter-spacing: 0.04rem;
padding: 1.5rem 3rem;
cursor: pointer;
border-radius: 28px;
background: #fff;
position: relative;
}
label::before,
label::after{
content: '';
position: absolute;
border-radius: inherit;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
label::after {
border:3px solid #000;
box-shadow:0 3px 0 0 #000;
}
label::before {
mix-blend-mode: difference;
background:
radial-gradient(circle at center, #fff 24%, #000 25%, #000 100%)
center/0% 0% no-repeat;
transition: background-size 0.3s ease-in;
}
input[type=checkbox]:checked+label:before {
background-size:400% 400%;
}
label:active {
transform:translateY(3px);
}
label:active::after {
box-shadow:0 0 0 0 #000;
}
<input type="checkbox" id="cb1" /><label for="cb1">Toggle me</label>
I have an element with background set as color
On hover background is set as radial-gradient
I want to make transition between colors on hover but it creates weird effect where my element disappear for a second.
Here is link
Link
Is it possible to switch between color and gradient without this problem?
.link {
display: block;
position: absolute;
bottom: 20%;
padding: 0 25px;
height: 42px;
line-height: 42px;
border-radius: 8px;
font-size: 15px;
font-weight: 700;
background: red;
color: white;
transition: all 0.3s ease-in-out;
}
.link:hover {
text-decoration: none;
background: radial-gradient(98px 98px at center center, red 0%, #0088b5 100%);
}
You can play with background-size:
.link {
display: inline-block;
padding: 0 25px;
line-height: 42px;
border-radius: 8px;
font-size: 15px;
font-weight: 700;
background-image: radial-gradient(circle,red 0%, #0088b5 100%);
background-position:center;
background-size:600% 600%; /*a big size to see only the red*/
color: white;
text-decoration: none;
transition: all 0.3s ease-in-out;
}
.link:hover {
background-size:150% 150%; /* reduce the size to see the gadient effect*/
}
<div class="link">Link</div>
You can use the :before pseudo-element along with a transition on the opacity of the background color to get this effect.
Credit: Dave Lunny.
Also, check out this previous question.
.link {
display: block;
position: absolute;
bottom: 20%;
padding: 0 25px;
height: 42px;
line-height: 42px;
border-radius: 8px;
font-size: 15px;
font-weight: 700;
background: rgba(255, 0, 0, 1);
color: white;
opacity: 1;
transition: all 0.3s ease-in-out;
}
.link:before {
border-radius: inherit;
content: '';
display: block;
height: 100%;
position: absolute;
top: 0; left: 0;
width: 100%;
z-index: -100;
background: radial-gradient(98px 98px at center center, red 0%, #0088b5 100%);
}
.link:hover {
text-decoration: none;
background: rgba(255, 0, 0, 0);
}
<a class="link" href="#">Hover Me!</a>
how can I make this effect of the inner side of the lines?This is the menu bar I am trying to make: http://i.stack.imgur.com/Mvuer.jpg I cant do the effect between the lines. This is my code: https://jsfiddle.net/ivailo/3q6ej7cc/4/
.button {
position: relative;
display: inline-block;
padding: .5em 1em;
font-size: 18px;
font-family: Arial, 'Arial Unicode MS', Helvetica, Sans-Serif;
border: 1px solid rgba(122, 112, 82, 0.2);
color: #877B5A;
text-align: center;
text-decoration: none;
outline: none;
overflow: hidden;
border-radius: 7px;
}
.button::after {
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
color #fffff;
display: block;
content: '';
width: 15em;
height: 15em;
border-radius: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transition: all 0s;
}
.button:hover::after {
box-shadow: inset 0 0 0 10em rgba(242, 189, 99, .2);
}
.button:hover {
color: #000000;
}
.button1 {
position: relative;
display: inline-block;
padding: .5em 1em;
font-size: 18px;
font-family: Arial, 'Arial Unicode MS', Helvetica, Sans-Serif;
border: 1px solid rgba(122, 112, 82, 0.2);
color: #877B5A;
text-align: center;
text-decoration: none;
outline: none;
overflow: hidden;
border-radius: 7px;
}
.button1::after {
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
display: block;
content: '';
width: 15em;
height: 15em;
transform: translate(-50%, -50%);
transition: all 0s;
}
.button1:hover::after {
box-shadow: inset 0 0 0 10em rgba(242, 189, 99, .2);
}
.button1:hover {
color: #000000;
}
.theborder {
text-align: center;
width: 600px;
padding: 20px 25px;
}
.theborder:after {
content: "";
height: 1px;
background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(160, 160, 160, .7) 50%, rgba(0, 0, 0, 0) 100%);
display: block;
margin: 10px 0px;
}
.theborder:before {
content: "";
height: 1px;
background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(160, 160, 160, .7) 50%, rgba(0, 0, 0, 0) 100%);
display: block;
margin: 10px 0px;
}
Step 1: The inner glow
You can achieve this effect by using a variant of the curved drop-shadow trick. That trick is explained here:
http://nicolasgallagher.com/css-drop-shadows-without-images/demo/
But instead of putting the shadow behind, we can:
make it white
leave it in front
set overflow: hidden on the menu to hide the parts of the "shadow" we don't want to see.
This produces the interior glow effect that you want.
BODY {
background-color: tan;
}
.menu {
background-color: tan;
width: 500px;
height: 60px;
position: relative;
overflow: hidden;
}
.menu::before {
content: "";
position: absolute;
top: -50%;
bottom: 100%;
left: 10%;
right: 10%;
border-radius: 50% / 30%;
box-shadow: 0 0 50px rgba(255,255,255,0.8);
}
.menu::after {
content: "";
position: absolute;
top: 100%;
bottom: -50%;
left: 10%;
right: 10%;
border-radius: 50% / 30%;
box-shadow: 0 0 40px rgba(255,255,255,0.7);
}
<div class="menu">
</div>
You can see more clearly how it works if you remove the overflow: hidden from the menu rule.
Step 2: The fading top border
To make this we can just add a new <div> element at the top that is 1px height and has a CSS gradient background.
The final result:
BODY {
background-color: tan;
}
.menu {
background-color: tan;
width: 500px;
height: 60px;
position: relative;
overflow: hidden;
}
.menu::before {
content: "";
position: absolute;
top: -50%;
bottom: 100%;
left: 10%;
right: 10%;
border-radius: 50% / 30%;
box-shadow: 0 0 50px rgba(255,255,255,0.8);
}
.menu::after {
content: "";
position: absolute;
top: 100%;
bottom: -50%;
left: 10%;
right: 10%;
border-radius: 50% / 30%;
box-shadow: 0 0 40px rgba(255,255,255,0.7);
}
.topborder {
width: 100%;
height: 1px;
background: linear-gradient(to right, rgba(0,0,0,0) 0%,rgba(0,0,0,0.5) 25%,rgba(0,0,0,0.5) 75%,rgba(0,0,0,0) 100%);
}
<div class="menu">
<div class="topborder"></div>
</div>
Note: in both of the above examples I have simplified things by just using the unprefixed CSS properties. These should work on the latest Chrome and FF at least. But if you need to support older browser versions, you should add the prefixed versions of the CSS properties as well.
For example for the gradients, you might want to add -moz-linear-gradient and -webkit-linear-gradient, plus the fallback filter gradients for older versions of IE.
See: full version of this gradient
I can't seem to get the bottom of the buttons to show, I tried increasing padding on the span, setting it to display: block, and increasing the height of the A and SPAN elements to no avail.
JS Fiddle Link: http://jsfiddle.net/7tcrz38r/
CSS:
/* Menu */
div#menu{
float: right;
margin-top: [[setting:menuMarginTop]];
}
div#menu ul{
list-style: none;
margin: 0;
padding: 0;
}
div#menu>ul>li{
float: left;
padding: 0;
}
div#menu li.has-sub>ul{
background: #FFFFFF;
border-top: 4px solid [[setting:color1]] !important;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
height: 110px;
display: none;
height: auto;
margin: -12px 0 0 16px;
padding: 0px;
position: absolute;
width: 170px;
z-index: 2000;
}
div#menu li.has-sub>ul>li{
border-bottom: 1px solid #EEEEEE;
border-left: 1px solid #DDDDDD;
border-right: 1px solid #DDDDDD;
padding: 10px;
}
div#menu li.has-sub>ul>li>a{
color: #949494;
font-size: 12px !important;
text-decoration: none;
}
div#menu li.has-sub>ul>li>a:hover{
color: [[setting:color1]];
}
div#menu li:hover ul {
display: block;
}
div#menu>ul>li>a {
color: #868787;
display: inline-block;
font-size: 18px !important;
font-weight: lighter;
letter-spacing: 1px !important;
margin: 17px 15px !important;
outline: none;
position: relative;
text-decoration: none;
text-shadow: 0 0 1px rgba(255,255,255,0.3);
}
/*div#menu>ul>li>a.active{
color: [[setting:color1]] !important;
background-color: #c3d9e3;
border: 2px solid #abd1eb;
border-radius: 5px;
}*/
div#menu>ul>li:last-child>a{
margin: 17px 0 17px 15px !important
}
div#menu>ul>li:last-child>a{
margin-right: 0 !important;
}
div#menu>ul>li>a:hover,
div#menu>ul>li>a:focus {
outline: none;
}
div#menu>ul>li>a{
overflow: hidden;
padding: 0 !important;
height: 1.3em !important;
}
div#menu>ul>li>a>span {
display: block;
position: relative;
border: 2px solid #eef3f5;
/*-webkit-transition: -webkit-transform 0.3s;
-moz-transition: -moz-transform 0.3s;
transition: transform 0.3s;*/
}
div#menu>ul>li>a>span::before {
position: absolute;
top: 100%;
content: attr(data-hover);
/*-webkit-transform: translate3d(0,0,0);
-moz-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);*/
}
div#menu>ul>li>a:hover span,
div#menu>ul>li>a:focus span {
/* background-color: #c3d9e3;
border: 1px solid #abd1eb;
border-radius: 25%;*/
background-color: #c3d9e3;
border: 2px solid #abd1eb;
border-radius: 5px;
/*-webkit-transform: translateY(-100%);
-moz-transform: translateY(-100%);
transform: translateY(-100%);
color: [[setting:color1]];*/
}
/*
div#menu>ul>li>a.menuactive{
color: [[setting:color1]];
}*/
HTML:
<div id="menu">
<ul><li >
<span data-hover="Home">Home</span></li><li >
<span data-hover="Classes">Classes</span></li><li >
<span data-hover="Pricing">Pricing</span></li><li >
<span data-hover="About Us">About Us</span></li><li >
<span data-hover="Log In">Log In</span></li> </ul>
</div>
You are setting a fixed height(1.3em !important;) for A which is causing this issue.
Please check this updated working fiddle:http://jsfiddle.net/7tcrz38r/2/
you have this declaration:
div#menu>ul>li>a {
overflow: hidden;
padding: 0 !important;
height: 1.3em !important;
}
which, by the way, is repeated since it's declared some lines above
div#menu>ul>li>a {
color: #868787;
display: inline-block;
font-size: 18px !important;
font-weight: lighter;
letter-spacing: 1px !important;
margin: 17px 15px !important;
outline: none;
position: relative;
text-decoration: none;
text-shadow: 0 0 1px rgba(255, 255, 255, 0.3);
}
Anyways, just remove that overflow:hidden property. However, you'll have the menu items showing twice because of that data-hover span you have. I don't know why are you using that, so consider if you need it or not. Of course, you can simply remove that "height: 1.3em !important;" as well, but I assume it's better to have a height than an overflow. anyways, it's a a decision you'll have to ponder
Anyone have any idea why this is happening? I've been hitting my head on the desk for the last 2 hours, trying to figure out why the cursor gets displaced on the iPad. Check out my video to see it:
http://tinypic.com/r/20k6338/7
Here is my CSS:
#newroar-ipad {
position: fixed;
display: block;
opacity: 0;
left: 5px;
top: 0px;
height: 480px !important;
width: 550px !important;
margin-top: 30px;
pointer-events: none;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#CCCCCC));
z-index: 4;
-webkit-border-radius: 5px;
-webkit-box-shadow: 0px 4px 5px #000;
-webkit-transition: -opacity 0.0s ease-out;
-webkit-transition-duration: .4s;
-webkit-transform: translate(0px, -20px);
}
#newroar-ipad.show {
opacity: 1.0;
pointer-events: auto;
z-index: 4;
-webkit-transition-duration: .4s;
-webkit-transform: translate(0px, 15px);
}
#newroar-ipad-content-header {
margin-top: 10px;
z-index: 4;
width: 548px;
height: 55px;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EBEBEB), to(#CCC));
border: 1px solid #CCC;
}
#newroar-ipad-content {
margin-top: 0px;
margin-left: 2px;
background: none;
top: 0;
width: 542px;
height: 400px;
z-index: 4;
}
.newroar-inputfield {
-webkit-appearance: none;
height: 20px !important;
width: 90%;
margin-left: 18px;
margin-bottom: 10px;
background: #FFF;
color: #666;
font-size: 12px;
border-style: none;
padding: 10px;
-webkit-border-radius: 5px !important;
}
.newroar-textarea {
-webkit-appearance: none;
width: 90%;
height: 120px;
margin-left: 18px;
margin-bottom: 10px;
background: #FFF;
color: #666;
font-size: 12px;
border-style: none !important;
border: none !important;
padding: 10px;
-webkit-border-radius: 5px !important;
-webkit-box-shadow: none !important;
outline: none !important;
}
.newroar-selectfield {
font-size: 14px !important;
height: 30px !important;
width: 300px !important;
margin-left: 18px !important;
margin-top: 25px !important;
margin-bottom: 25px !important;
}
You can see I have tried using !important in case it was bringing styling for other form elements in the CSS document, and I tried the -webkit-appearance to see if it would fix it... with no avail. =(
Thanks for any advice you may have!
can you try using position:absolute , rather than fixed
#newroar-ipad {
position: absolute;
/* other style codes */
}
Because ios usually move the input box in focus , to just above the keypad. Seems like the position:fixed code is bringing it back to its original position.