Animate placeholder text: Go to side and loose opacity - html

I'm creating a search box, with the placeholder text getting animated on focus. I've implemented that using css. When it gets focused, the placeholder text gets moved over all the way to the right while loosing opacity. When it looses focus, it gets moved its original place and the opacity is applied again.
The problem is when you unfocus, (firs focus, then unfocus,) the searchbox gets a larger width. So if the parent div is set to overflow: auto, the x-axis scroll bar shows up. I can obviously do overflow-x: hidden, but that's sort of a hack.
How can I get the same animation without having an overflow?
JSFiddle
#wrapper {
width: 350px;
background-color: brown;
overflow: auto;
}
#search {
margin: 0 .5rem;
padding: .5rem;
width: 95%;
background-color: green;
color: white;
border: none;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
font-size: 1.15rem;
transition: translateX 6s ease-in;
margin-bottom: 15px;
}
#search:focus {
outline: none;
border: 1px solid rgba(255, 255, 255, 0.5);
}
#search:focus::-webkit-input-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search:focus::-webkit-input-placeholder:-moz-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search:focus::-webkit-input-placeholder::-moz-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search:focus::-webkit-input-placeholder:-ms-input-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search:focus::-webkit-input-placeholder::-ms-input-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search::-webkit-input-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
-webkit-transform-origin: 0 50%;
transform-origin: 0 50%;
}
#search:-moz-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
transform-origin: 0 50%;
}
#search::-moz-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
transform-origin: 0 50%;
}
#search:-ms-input-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
transform-origin: 0 50%;
}
#search::-ms-input-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
transform-origin: 0 50%;
}
<div id="wrapper">
<input type="search" placeholder="Search Me" id="search">
</div>

UPDATED
Plnker
:focus::-webkit-input-placeholder {
opacity: 0;
transform: translate(70%);
-webkit-transition: all 0.35s ease-in-out;
transition: all 0.35s ease-in-out;
}

Related

Positioned element is off when on Safari`

I have a button with arrows that is supposed to appear and move down when moused over. On Chrome and Firefox it works fine but when I open it up on Safari the arrows are too low- they aren't positioned correctly. I have heard about people specifying "top" and :left" but that doesn't seem to work for me. I don't know why this is but it seems to be due to the position: relative.
Code:
<a class="details" href="#scroll"> <span class="details__border--bottom">More Details</span>
</a>
<div class="top-portion__arrows">
<span class="top-portion__arrows--hide"></span>
<span class="top-portion__arrows--hide"></span>
<span class="top-portion__arrows--hide"></span>
</div>
a.details {
border: 2.5px solid white;
padding: 8px 62px;
padding-top: 11px;
font-family: 'Roboto', sans-serif;
font-size: 1.75rem;
background-color: rgba(214, 128, 0, 0.45);
color: white;
cursor: pointer;
position: relative;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
left: 50%;
top: 5%;
z-index: 1;
display: inline-block;
}
a.details:hover,
a.details:focus {
background-color: rgba(231, 147, 21, 0.25);
-webkit-transition: .5s ease-in;
-o-transition: .5s ease-in;
transition: .5s ease-in;
}
a.details:hover,
a.details:focus {
border: 3.5px solid white;
-webkit-transition: .15s;
-o-transition: .15s;
transition: .15s;
}
a.details:active {
background-color: rgba(247, 195, 100, 0.75);
-webkit-transition: .15s;
-o-transition: .15s;
transition: .15s;
}
.details__border--bottom {
display: inline-block;
padding: 2px 0px 4px;
margin: 0px 8px 0px;
position: relative;
}
.details__border--bottom:before {
content: '';
position: absolute;
width: 100%;
height: 0px;
border-bottom: 2.5px solid white;
bottom: 2px;
-webkit-transform: scaleX(0);
-ms-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: -webkit-transform 0.25s ease-in-out;
-webkit-transition: -webkit-transform 0.45s ease-in-out;
transition: -webkit-transform 0.45s ease-in-out;
-o-transition: transform 0.45s ease-in-out;
transition: transform 0.45s ease-in-out;
transition: transform 0.45s ease-in-out, -webkit-transform 0.45s ease-in-out;
}
a:hover .details__border--bottom:before,
a:focus .details__border--bottom:before {
-webkit-transform: scaleX(1);
-ms-transform: scaleX(1);
transform: scaleX(1);
}
.top-portion__arrows {
position: relative;
width: 0%;
top: 10%;
left: 51.5%;
}
.top-portion__arrows .top-portion__arrows--hide {
opacity: 0;
display: block;
width: 120px;
height: 120px;
border-bottom: 3px solid white;
border-right: 3px solid white;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
margin: -85px;
}
a.details:hover + .top-portion__arrows .top-portion__arrows--hide,
a.details:focus + .top-portion__arrows .top-portion__arrows--hide {
opacity: 1;
-webkit-animation: animate .65s ease;
animation: animate .65s ease;
}
.top-portion__arrows .top-portion__arrows--hide:hover .details__border--full,
.top-portion__arrows .top-portion__arrows--hide:focus .details__border--full {
border: 2.5px solid white;
-webkit-transition: .2s ease-in;
-o-transition: .2s ease-in;
transition: .2s ease-in;
}
#-webkit-keyframes animate {
0%{
opacity: 0;
-webkit-transform: rotate(45deg) translate(-10px,-10px);
transform: rotate(45deg) translate(-10px,-10px);
}
50%{
opacity: .5;
}
100%{
opacity: 1;
-webkit-transform: rotate(45deg) translate(0px,0px);
transform: rotate(45deg) translate(0px,0px);
}
}
#keyframes animate {
0%{
opacity: 0;
-webkit-transform: rotate(45deg) translate(-10px,-10px);
transform: rotate(45deg) translate(-10px,-10px);
}
50%{
opacity: .5;
}
100%{
opacity: 1;
-webkit-transform: rotate(45deg) translate(0px,0px);
transform: rotate(45deg) translate(0px,0px);
}
}
You can detect whether a user is browsing on safari with some javascript and then if they are browsing on safari, style the buttons a certain way by changing the margin-left and margin-top. Here is the code to detect whether the user is on safari:
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari') != -1) {
if (ua.indexOf('chrome') > -1) {
alert("chrome") // Chrome
} else {
alert("safari") // Safari
}
}
Edit: Your full code:
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari') != -1) {
if (ua.indexOf('chrome') > -1) {
} else {
document.getElementById("btn1").style.marginTop = "80%"; }
}

Button hover animation background color not filled fully

When you hover over the button on left & right side same space is visible. How can we fix that?
Here is image when you hover on button this is how it looks.
Here is jsfiddle link
https://jsfiddle.net/vct5acc0/1/
Css code is here :-
body {
background-color: #4F4BFA;
}
.btn1 {
border: 2px solid #fff;
}
.btn-cmn {
width: 175px;
height: 52px;
background-color: transparent;
border-radius: 26px;
font-size: 18px;
font-weight: 700;
line-height: 28px;
cursor: pointer;
}
Here is my solution, inspired by Kuba's first proposition:
(the one which added an inset shadow on the hover, not the updated one!)
See my comments in the CSS code, only 2 modifications.
body {
background-color: #4F4BFA;
}
.btn1 {
border: none; /* Modified */
box-shadow: inset 0px 0px 0px 2px #fff; /* Added */
}
.btn-cmn {
width: 175px;
height: 52px;
background-color: transparent;
border-radius: 26px;
font-size: 18px;
font-weight: 700;
line-height: 28px;
cursor: pointer;
}
.button-hover-effect {
position: relative;
overflow: hidden;
border-color: #000;
color: #000;
transition: color .4s cubic-bezier(.4, 0, .2, 1);
-webkit-transition: color .4s cubic-bezier(.4, 0, .2, 1);
-moz-transition: color .4s cubic-bezier(.4, 0, .2, 1);
-o-transition: color .4s cubic-bezier(.4, 0, .2, 1);
-ms-transition: color .4s cubic-bezier(.4, 0, .2, 1);
}
.btn-hfix1 {
height: 53px;
}
.button-hover-effect.white {
border-color: #fff;
color: #fff;
}
.button-hover-effect.white:hover {
color: #000;
}
.button-hover-effect::before {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
content: "";
background-color: #000;
z-index: 1;
border-radius: 26px;
transition: transform .4s cubic-bezier(.4, 0, .2, 1);
-webkit-transition: -webkit-transform .4s cubic-bezier(.4, 0, .2, 1);
-moz-transition: -moz-transform .4s cubic-bezier(.4, 0, .2, 1);
-o-transition: -o-transform .4s cubic-bezier(.4, 0, .2, 1);
-ms-transition: -ms-transform .4s cubic-bezier(.4, 0, .2, 1);
transform: scale(0, 1);
-webkit-transform: scale(0, 1);
-moz-transform: scale(0, 1);
-o-transform: scale(0, 1);
-ms-transform: scale(0, 1);
transform-origin: right center;
-webkit-transform-origin: right center;
-moz-transform-origin: right center;
-o-transform-origin: right center;
-ms-transform-origin: right center;
}
.button-hover-effect:hover::before {
transform: scale(1, 1);
-webkit-transform: scale(1, 1);
-moz-transform: scale(1, 1);
-o-transform: scale(1, 1);
-ms-transform: scale(1, 1);
transform-origin: left center;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
-ms-transform-origin: left center;
}
.button-hover-effect.white::before {
background-color: #fff;
}
.button-hover-effect .str {
position: relative;
z-index: 2;
}
<button class="btn-cmn btn1 button-hover-effect white btn-hfix1">
<span class="str">Know more</span>
</button>
I've only set the border to none, and then added an inset box-shadow.
I hope it helps.
Quick and "dirty". Remove the original border on hover and add an inset shadow (as a border) to see still a border while the transformation.
Updated:
.btn1 {
border:none; /*changed*/
box-shadow: inset 0px 0px 0px 2px #fff; /*added*/
}
body {
background-color: #4F4BFA;
}
.btn1 {
border: none;
box-shadow: inset 0px 0px 0px 2px #fff;
}
.btn-cmn {
width: 175px;
height: 52px;
background-color: transparent;
border-radius: 26px;
font-size: 18px;
font-weight: 700;
line-height: 28px;
cursor: pointer;
}
.button-hover-effect {
position: relative;
overflow: hidden;
border-color: #000;
color: #000;
transition: color .4s cubic-bezier(.4,0,.2,1);
-webkit-transition: color .4s cubic-bezier(.4,0,.2,1);
-moz-transition: color .4s cubic-bezier(.4,0,.2,1);
-o-transition: color .4s cubic-bezier(.4,0,.2,1);
-ms-transition: color .4s cubic-bezier(.4,0,.2,1);
}
.btn-hfix1 {
height: 53px;
}
.button-hover-effect.white {
border-color: #fff;
color: #fff;
}
.button-hover-effect.white:hover {
color: #000;
border:0px solid #fff;
box-shadow: inset 0px 0px 0px 2px #fff;
}
.button-hover-effect::before {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
content: "";
background-color: #000;
z-index: 1;
border-radius: 26px;
transition: transform .4s cubic-bezier(.4,0,.2,1);
-webkit-transition: -webkit-transform .4s cubic-bezier(.4,0,.2,1);
-moz-transition: -moz-transform .4s cubic-bezier(.4,0,.2,1);
-o-transition: -o-transform .4s cubic-bezier(.4,0,.2,1);
-ms-transition: -ms-transform .4s cubic-bezier(.4,0,.2,1);
transform: scale(0,1);
-webkit-transform: scale(0,1);
-moz-transform: scale(0,1);
-o-transform: scale(0,1);
-ms-transform: scale(0,1);
transform-origin: right center;
-webkit-transform-origin: right center;
-moz-transform-origin: right center;
-o-transform-origin: right center;
-ms-transform-origin: right center;
}
.button-hover-effect:hover::before {
transform: scale(1,1);
-webkit-transform: scale(1,1);
-moz-transform: scale(1,1);
-o-transform: scale(1,1);
-ms-transform: scale(1,1);
transform-origin: left center;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
-ms-transform-origin: left center;
border:5px solid #fff;
}
.button-hover-effect.white::before {
background-color: #fff;
}
.button-hover-effect .str {
position: relative;
z-index: 2;
}
<button class="btn-cmn btn1 button-hover-effect white btn-hfix1">
<span class="str">Know more</span>
</button>
body {
background-color: #4F4BFA;
}
.btn1 {
border: 2px solid #fff;
}
.button-hover-effect.white:hover {
border-color: #fff;
color: #fff;
}
.btn-cmn {
width: 175px;
height: 52px;
background-color: transparent;
border-radius: 26px;
font-size: 18px;
font-weight: 700;
line-height: 28px;
cursor: pointer;
}
.btn-cmn:hover {
width: 175px;
height: 52px;
background-color: #fff;
border-radius: 26px;
font-size: 18px;
font-weight: 700;
line-height: 28px;
cursor: pointer;
}
.button-hover-effect {
position: relative;
overflow: hidden;
border-color: #000;
color: #000;
transition: color .4s cubic-bezier(.4,0,.2,1);
-webkit-transition: color .4s cubic-bezier(.4,0,.2,1);
-moz-transition: color .4s cubic-bezier(.4,0,.2,1);
-o-transition: color .4s cubic-bezier(.4,0,.2,1);
-ms-transition: color .4s cubic-bezier(.4,0,.2,1);
}
.btn-hfix1 {
height: 53px;
}
.button-hover-effect.white {
border-color: #fff;
color: #fff;
}
.button-hover-effect.white:hover {
color: #000;
}
.button-hover-effect::before {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
content: "";
background-color: #000;
z-index: 1;
border-radius: 26px;
transition: transform .4s cubic-bezier(.4,0,.2,1);
-webkit-transition: -webkit-transform .4s cubic-bezier(.4,0,.2,1);
-moz-transition: -moz-transform .4s cubic-bezier(.4,0,.2,1);
-o-transition: -o-transform .4s cubic-bezier(.4,0,.2,1);
-ms-transition: -ms-transform .4s cubic-bezier(.4,0,.2,1);
transform: scale(0,1);
-webkit-transform: scale(0,1);
-moz-transform: scale(0,1);
-o-transform: scale(0,1);
-ms-transform: scale(0,1);
transform-origin: right center;
-webkit-transform-origin: right center;
-moz-transform-origin: right center;
-o-transform-origin: right center;
-ms-transform-origin: right center;
}
.button-hover-effect:hover::before {
transform: scale(1,1);
-webkit-transform: scale(1,1);
-moz-transform: scale(1,1);
-o-transform: scale(1,1);
-ms-transform: scale(1,1);
transform-origin: left center;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
-ms-transform-origin: left center;
}
.button-hover-effect.white::before {
background-color: #fff;
}
.button-hover-effect .str {
position: relative;
z-index: 2;
}
<button class="btn-cmn btn1 button-hover-effect white btn-hfix1">
<span class="str">Know more</span>
</button>
Have updated the fiddle. Please check
.button-hover-effect.white:hover {
color: #000;
border: none;
}
https://jsfiddle.net/vct5acc0/8/

Is there a way to bypass overflow:hidden so an absolute positioned div could appear outside of it?

I have a menu, and on each <li> there's a class making it overflow: hidden; so I can achieve an animation on it. The thing is on one of these list-item's there's a sub-menu. This sub-menu is position: absolute;. The overflow is making it so you can't see it when it's being clicked on. If I remove overflow: hidden; the animation breaks. I'm not sure what to do. Unless there's a way to bypass, I'm thinking for my sub-menu to appear I'd have to scrap the animation entirely.
Animation
/* Wayra */
.wayra {
overflow: hidden;
-webkit-transition: border-color 0.3s, color 0.3s;
transition: border-color 0.3s, color 0.3s;
-webkit-transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
}
/*.wayra.contact-item {
overflow: visible;
}*/
.wayra::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 150%;
height: 100%;
background: #281879;
/*z-index: -1;*/
-webkit-transform: rotate3d(0, 0, 1, -45deg) translate3d(0, -3em, 0);
transform: rotate3d(0, 0, 1, -45deg) translate3d(0, -3em, 0);
-webkit-transform-origin: 0% 100%;
transform-origin: 0% 100%;
-webkit-transition: -webkit-transform 0.3s, opacity 0.3s, background-color 0.3s;
transition: transform 0.3s, opacity 0.3s, background-color 0.3s;
}
.wayra a {
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.wayra a:hover {
color: #fff;
}
.wayra:hover::before {
opacity: 1;
background-color: #281879;
-webkit-transform: rotate3d(0, 0, 1, 0deg);
transform: rotate3d(0, 0, 1, 0deg);
-webkit-transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
}
Dropdown
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
font-size: 14px;
text-align: left;
list-style: none;
background-color: #fff;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
box-shadow: 0 6px 12px rgba(0,0,0,.175);
}
Here's a link to a demo.
How about adding that effect to a instead of li? Let's translate:
.wyara should get overflow:visible,
.wyara > a should get overflow:hidden,
.wayra::before becomes .wayra > a::before,
.wayra:hover::before becomes .wyara:hover > a::before, .wayra.open > a::before
Just tried it with Stylish, looks good.
Yes, you can override it when hovering over the element:
.wayra:hover {
overflow: visible;
}
I strongly believe that is not possible. But there have to be other methods to do something like this. If you want to have an animation, you will have to rewrite your menu from scratch.

Text not getting center aligned in a CSS button

.button {
text-align: left;
background-color: #012839;
text-decoration: none;
text-transform: uppercase;
font-family: 'Exo 2', sans-serif;
font-weight: 200;
font-size: 30px;
display: inline-block;
position: relative;
margin-top: 50px;
margin-left: 20px;
text-align: center;
width: 50px;
color: #00c7ec;
border: 1px solid #00c7ec;
border-radius: 5px;
line-height: 3em;
padding-left: 5em;
padding-right: 5em;
box-shadow: 0 0 0 0 transparent;
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.button:hover {
color: white;
box-shadow: 0 0 30px 0 rgba(0, 199, 236, 0.5);
background-color: #00c7ec;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.button:hover:before {
-webkit-animation: shine 0.5s 0s linear;
-moz-animation: shine 0.5s 0s linear;
animation: shine 0.5s 0s linear;
}
.button:active {
box-shadow: 0 0 0 0 transparent;
-webkit-transition: box-shadow 0.2s ease-in;
-moz-transition: box-shadow 0.2s ease-in;
transition: box-shadow 0.2s ease-in;
}
.button:before {
content: '';
display: block;
width: 0px;
height: 86%;
position: absolute;
top: 7%;
left: 0%;
opacity: 0;
background: white;
box-shadow: 0 0 15px 3px white;
-webkit-transform: skewX(-20deg);
-moz-transform: skewX(-20deg);
-ms-transform: skewX(-20deg);
-o-transform: skewX(-20deg);
transform: skewX(-20deg);
}
#-webkit-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#-moz-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
Gallery
I wanted to use this button in my personal project but the problem I am having is that the text in the button i.e. "Gallery" is not getting center aligned even after I put the "text-align:"center" in the button class.
Because of you define width 50px; now do this
add width: auto; or remove width: 50px;
as like this
.button {
text-align: left;
background-color: #012839;
text-decoration: none;
text-transform: uppercase;
font-family: 'Exo 2', sans-serif;
font-weight: 200;
font-size: 30px;
display: inline-block;
position: relative;
margin-top: 50px;
margin-left: 20px;
text-align: center;
color: #00c7ec;
border: 1px solid #00c7ec;
border-radius: 5px;
line-height: 3em;
padding-left: 5em;
padding-right: 5em;
box-shadow: 0 0 0 0 transparent;
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.button:hover {
color: white;
box-shadow: 0 0 30px 0 rgba(0, 199, 236, 0.5);
background-color: #00c7ec;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.button:hover:before {
-webkit-animation: shine 0.5s 0s linear;
-moz-animation: shine 0.5s 0s linear;
animation: shine 0.5s 0s linear;
}
.button:active {
box-shadow: 0 0 0 0 transparent;
-webkit-transition: box-shadow 0.2s ease-in;
-moz-transition: box-shadow 0.2s ease-in;
transition: box-shadow 0.2s ease-in;
}
.button:before {
content: '';
display: block;
width: 0px;
height: 86%;
position: absolute;
top: 7%;
left: 0%;
opacity: 0;
background: white;
box-shadow: 0 0 15px 3px white;
-webkit-transform: skewX(-20deg);
-moz-transform: skewX(-20deg);
-ms-transform: skewX(-20deg);
-o-transform: skewX(-20deg);
transform: skewX(-20deg);
}
#-webkit-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#-moz-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
Gallery
Add .button { width: auto; } to get your result
change
padding-left : 5em to 2.5em
I had removed padding and added min-width:220px:
.button {
text-align: left;
background-color: #012839;
text-decoration: none;
text-transform: uppercase;
font-family: 'Exo 2', sans-serif;
font-weight: 200;
font-size: 30px;
display: inline-block;
position: relative;
margin-top: 50px;
margin-left: 20px;
text-align: center;
color: #00c7ec;
min-width: 220px; /*Here you can give any value other then 220px*/
border: 1px solid #00c7ec;
border-radius: 5px;
line-height: 3em;
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.button:hover {
color: white;
box-shadow: 0 0 30px 0 rgba(0, 199, 236, 0.5);
background-color: #00c7ec;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.button:hover:before {
-webkit-animation: shine 0.5s 0s linear;
-moz-animation: shine 0.5s 0s linear;
animation: shine 0.5s 0s linear;
}
.button:active {
box-shadow: 0 0 0 0 transparent;
-webkit-transition: box-shadow 0.2s ease-in;
-moz-transition: box-shadow 0.2s ease-in;
transition: box-shadow 0.2s ease-in;
}
.button:before {
content: '';
display: block;
width: 0px;
height: 86%;
position: absolute;
top: 7%;
left: 0%;
opacity: 0;
background: white;
box-shadow: 0 0 15px 3px white;
-webkit-transform: skewX(-20deg);
-moz-transform: skewX(-20deg);
-ms-transform: skewX(-20deg);
-o-transform: skewX(-20deg);
transform: skewX(-20deg);
}
#-webkit-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#-moz-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
Gallery

I am trying to implement a hover effect using CSS3 Transitions

What I am trying to achieve is make a hover effect that when the cursor is hovering the icons the caption will slide from left. Making it seem like it is replacing the icon itself.
The Image below is what I am currently working on. I can't figure out which part on the CSS is making it not fit inside.
I am trying to implement this while using Twitter Bootstrap. The hover effect is found here.
HTML
<div class="content">
<div class="container row">
<!-- Icon row -->
<div class="view view-fifth span1">
<img src="images/bahay-dito.png" />
<div class="mask">
<h2>Bahay Dito</h2>
View
</div>
</div>
</div>
</div>
CSS
.view {
float: left;
overflow: hidden;
position: relative;
text-align: center;
-webkit-box-shadow: 1px 1px 2px #e6e6e6;
-moz-box-shadow: 1px 1px 2px #e6e6e6;
box-shadow: 1px 1px 2px #e6e6e6;
cursor: default;
}
.view .mask,.view .content {
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.view h2 {
color: red;
text-align: center;
position: relative;
font-size: 15px;
padding: 10px;
background: red;
margin: 20px 0 0 0;
}
.view p {
font-family: Georgia, serif;
font-style: italic;
font-size: 12px;
position: relative;
color: #fff;
padding: 10px 20px 20px;
text-align: center;
}
.view a.info {
display: inline-block;
text-decoration: none;
padding: 7px 14px;
background: #000;
color: #fff;
text-transform: uppercase;
-webkit-box-shadow: 0 0 1px #000;
-moz-box-shadow: 0 0 1px #000;
box-shadow: 0 0 1px #000;
}
.view a.info: hover {
-webkit-box-shadow: 0 0 5px #000;
-moz-box-shadow: 0 0 5px #000;
box-shadow: 0 0 5px #000;
}
Styles for the 5th Effect
.view-fifth img {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.view-fifth .mask {
background-color: rgba(146,96,91,0.3);
-webkit-transform: translateX(-300px);
-moz-transform: translateX(-300px);
-o-transform: translateX(-300px);
-ms-transform: translateX(-300px);
transform: translateX(-300px);
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.view-fifth h2 {
background: rgba(255, 255, 255, 0.5);
color: #000;
-webkit-box-shadow: 0px 1px 3px rgba(159, 141, 140, 0.5);
-moz-box-shadow: 0px 1px 3px rgba(159, 141, 140, 0.5);
box-shadow: 0px 1px 3px rgba(159, 141, 140, 0.5);
}
.view-fifth p {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
color: #333;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.view-fifth:hover .mask {
-webkit-transform: translateX(0px);
-moz-transform: translateX(0px);
-o-transform: translateX(0px);
-ms-transform: translateX(0px);
transform: translateX(0px);
}
.view-fifth:hover img {
-webkit-transform: translateX(300px);
-moz-transform: translateX(300px);
-o-transform: translateX(300px);
-ms-transform: translateX(300px);
transform: translateX(300px);
}
.view-fifth:hover p {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
}
is this what you want?
http://jsfiddle.net/9DLmb/1/
.container {
width:238px;
height:198px;
overflow:hidden;
}
.view {
float: left;
overflow: hidden;
position: relative;
text-align: center;
-webkit-box-shadow: 1px 1px 2px #e6e6e6;
-moz-box-shadow: 1px 1px 2px #e6e6e6;
box-shadow: 1px 1px 2px #e6e6e6;
cursor: default;
}
.view .mask, .view .content {
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.view h2 {
color: red;
text-align: center;
position: relative;
font-size: 15px;
padding: 10px;
background: red;
margin: 20px 0 0 0;
}
.view p {
font-family: Georgia, serif;
font-style: italic;
font-size: 12px;
position: relative;
color: #fff;
padding: 10px 20px 20px;
text-align: center;
}
.view a.info {
display: inline-block;
text-decoration: none;
padding: 7px 14px;
background: #000;
color: #fff;
text-transform: uppercase;
-webkit-box-shadow: 0 0 1px #000;
-moz-box-shadow: 0 0 1px #000;
box-shadow: 0 0 1px #000;
}
.view a.info: hover {
-webkit-box-shadow: 0 0 5px #000;
-moz-box-shadow: 0 0 5px #000;
box-shadow: 0 0 5px #000;
}
.view-fifth img {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.view-fifth .mask {
background-color: rgba(146, 96, 91, 0.3);
-webkit-transform: translateX(-300px);
-moz-transform: translateX(-300px);
-o-transform: translateX(-300px);
-ms-transform: translateX(-300px);
transform: translateX(-300px);
-ms-filter:"progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
width:238px;
height:203px;
}
.view-fifth h2 {
background: rgba(255, 255, 255, 0.5);
color: #000;
-webkit-box-shadow: 0px 1px 3px rgba(159, 141, 140, 0.5);
-moz-box-shadow: 0px 1px 3px rgba(159, 141, 140, 0.5);
box-shadow: 0px 1px 3px rgba(159, 141, 140, 0.5);
}
.view-fifth p {
-ms-filter:"progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
color: #333;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.view-fifth:hover .mask {
-webkit-transform: translateX(0px);
-moz-transform: translateX(0px);
-o-transform: translateX(0px);
-ms-transform: translateX(0px);
transform: translateX(0px);
}
.view-fifth:hover img {
-webkit-transform: translateX(300px);
-moz-transform: translateX(300px);
-o-transform: translateX(300px);
-ms-transform: translateX(300px);
transform: translateX(300px);
}
.view-fifth:hover p {
-ms-filter:"progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
}
Is this what you wanted?