Transition effects Top vs. Bottom in CSS is not working - css

Well, this is my first topic here, so here it is!
I've just done a nice-simple :hover code where you can mouse over an image and the captions underneath it appears for complete. More specifically, in this code I have two types of captions, one above the image and one right underneath the image, which can be found when you mouse it over.
The :hover works pretty fine, however I need to add a simple effect, just a little linear transition. So I add the most basic transitions in the "a" tag, but it is not working at all! I guess the code is not recognizing the top:0px in the .featured-banner a class and the bottom:0px in the .featured-banner a:hover.
Does anyone have a solution for it? I appreciate you guys for helping me out!
Oh, just in case, the text inside the captions classes are written in portuguese but not very interesting, just an ad for Cancun! =P
Here is the HTML i'm using:
<div class="featured-banner">
<a href="#">
<div class="caption">
<p>Mega Oferta • Cancún • Carnaval 2014</p>
</div>
<img src="http://www.advtour.com.br/sample-cancun.jpg" />
<div class="under-caption">A partir de US$ 2.148 Ou entrada + 11x de R$ 358</div>
</a>
And here is the CSS:
.featured-banner {
width:930px;
height:350px;
background:#000;
font-family:sans-serif;
font-size:23px;
margin:14px 0px;
overflow:hidden;
position:relative;
}
.featured-banner a {
text-decoration:none;
position:absolute;
top:0;
-webkit-transition:all 1s ease;
-moz-transition:all 1s ease;
-ms-transition:all 1s ease;
-o-transition:all 1s ease;
transition:all 1s ease;
}
.featured-banner a:hover {
top:inherit;
bottom:0;
}
.caption {
width:100%;
height:350px;
color:#FFF;
text-transform:uppercase;
position:absolute;
top:0px;
z-index:98;
}
.caption p {
width:97%;
background:rgba(0,0,0, .4);
color:#FFF;
text-align:justify;
text-transform:uppercase;
background:rgba(0,0,0, .4);
padding:11px 14px;
position:absolute;
bottom:0px;
z-index:98;
}
.under-caption {
width:97%;
background:rgba(0,0,0, .4);
color:#FFF;
font-size:20px;
text-align:justify;
background:rgba(0,0,0, .4);
padding:11px 14px;
z-index:98;
}
Here is a demo

If you are going to transition the effect then you need to transition the same style. Going from top - bottom will cause no transition since it is changing the styles. If you did top: 0; to top: 100%; then you will see a transition.
Here is the css I changed:
.featured-banner a {
text-decoration:none;
position:absolute;
top:0;
-webkit-transition:all 1s ease;
-moz-transition:all 1s ease;
-ms-transition:all 1s ease;
-o-transition:all 1s ease;
transition:all 1s ease;
}
.featured-banner a:hover {
top:inherit;
top: -55px;
}
Finally, a fiddle: Demo

You can only transition the same attribute. Top and bottom aren't the same.
I worked out a fiddle, which shows how it could work.
.under-caption {
position: absolute;
width:97%;
background:rgba(0,0,0, .4);
color:#FFF;
font-size:20px;
text-align:justify;
background:rgba(0,0,0, .4);
padding:11px 14px;
z-index:98;
bottom: -3em;
-webkit-transition:bottom 1s ease;
-moz-transition:bottom 1s ease;
-ms-transition:bottom 1s ease;
-o-transition:bottom 1s ease;
transition:bottom 1s ease;
}
.featured-banner:hover .under-caption{
bottom: 1em;
}
http://jsfiddle.net/u3E5P/1/

Related

CSS Transform over layer that already has tansform

I have left and right sliding panels that are animated with TranslateX.
I am also using the headroom jQuery plugin which drops down a top nav when the user scrolls up using Translate Y.
The issue is the header is not visible when the page scrolls up if the transform is declared on the wrapper div.
If transform: translateX(0px); is removed from wrapper in firebug, the header is fixed when the page scrolls up. If it is present, the header seems to be static at the top of the page despite having a position: fixed attribute.
BASIC HTML:
<div id="wrapper">
<header>
</header>
</div>
CSS FOR SIDEBARS AND WRAPPER:
#left-sidebar{
background-color:#8BA6BC;
position:fixed;
top:0;left:0;
width:80%;
height:100%;
z-index:20;
overflow:auto;
transform:translateX(-100%);
-moz-transform:translateX(-100%);
-webkit-transform:translateX(-100%);
transition:-moz-transform .25s ease-in-out;
-moz-transition:-moz-transform .25s ease-in-out;
-webkit-transition:-webkit-transform .25s ease-in-out;
}
#left-sidebar-handler.open ~ #left-sidebar{
transform:translateX(0);
-moz-transform:translateX(0);
-webkit-transform:translateX(0);
}
#right-sidebar{
background-color:#8BA6BC;
position:fixed;
top:0;
right:0;
width:80%;
height:100%;
z-index:20;
overflow:auto;
transform:translateX(100%);
-moz-transform:translateX(100%);
-webkit-transform:translateX(100%);
transition:-moz-transform .25s ease-in-out;
-moz-transition:-moz-transform .25s ease-in-out;
-webkit-transition:-webkit-transform .25s ease-in-out;
}
#right-sidebar-handler.open ~ #right-sidebar{
transform:translateX(0);
-moz-transform:translateX(0);
-webkit-transform:translateX(0);
}
#wrapper{
display:block;
position:relative;
min-height:100%;
height:auto !important;
height:100%;
margin-bottom:-45px;
z-index:5;
transform:translateX(0);
-moz-transform:translateX(0);
-webkit-transform:translateX(0);
transition:-moz-transform .25s ease-in-out;
-moz-transition:-moz-transform .25s ease-in-out;
-webkit-transition:-webkit-transform .25s ease-in-out;
}
#left-sidebar-handler.open ~ #wrapper{
transform:translateX(80%);
-moz-transform:translateX(80%);
-webkit-transform:translateX(80%);
}
#right-sidebar-handler.open ~ #wrapper{
transform:translateX(-80%);
-moz-transform:translateX(-80%);
-webkit-transform:translateX(-80%);
}
CSS FOR HEADER:
html.signed-in header{
position:fixed;
z-index:999;
top:0;
left:0;
width:100%;
min-height:46px;
line-height:46px;
background-color:#8BA6BC;
color:#fff;
}
html.signed-in header.headroom{
-webkit-transition:-webkit-transform 200ms linear;
-moz-transform 200ms linear;
transition:transform 200ms linear;
}
html.signed-in header.headroom--pinned{
-webkit-transform:translateY(0%);
-ms-transform:translateY(0%);
-moz-transform:translateY(0%);
transform:translateY(0%);
}
html.signed-in header.headroom--unpinned{
-webkit-transform:translateY(-100%);
-ms-transform:translateY(-100%);
-moz-transform:translateY(-100%);
transform:translateY(-100%);
}

Recreate jQuery link effect in CSS3

Does anyone know how to recreate this link effect that is done in jQuery in pure CSS3?
The effect can be seen at: http://www.yuhong-ng.com/
Same html :
<a href="#" id="liveshows" style="margin-top: -40px;">
<span class="top">Live Shows</span>
<span class="bottom">Live Shows</span>
</a>
Same base CSS :
#navigation li a {
height:80px;
font-size: 18px;
font-family: 'PT Sans Narrow';
font-weight: bold;
}
#navigation li,#navigation li a {
float: left;
}
#navigation li a span {
display:block;
height:32px;
padding:8px 20px 0 20px;
cursor:pointer;
}
An some new CSS3 stuff :
#navigation li a {
-webkit-transition: margin-top 500ms linear;
-moz-transition: margin-top 500ms linear;
transition: margin-top 500ms linear;
}
#navigation li a:hover {
margin-top: -40px;
}
So, what happens here ?
On hover, your JavaScript animates the margin property to -40px. Simple stuff.
So, in CSS, you need a transition property and, on :hover, change the margin. Same stuff.
A better version would use 3dtransforms, because it avoids repainting. It depends really if this effect is alone on your page (then transition on margin is fine) or if the website is "effect rich" (then repaints are to be tracked and eliminated.)
#navigation li a {
-webkit-transition: -webkit-transform 500ms linear;
-moz-transition: -moz-transform 500ms linear;
transition: -ms-transform 500ms linear;
transition: transform 500ms linear;
}
#navigation li a:hover {
-webkit-transform: translate3d(0,-40px,0px);
-moz-transform: translate3d(0,-40px,0px);
-ms-transform: translate3d(0,-40px,0px);
transform: translate3d(0,-40px,0px);
}
More about repaints (must see video) : http://www.youtube.com/watch?v=x0VR3lUOpdc

CSS3 transition difference between browsers in coverflow like slideshow

See: http://jsfiddle.net/nweBD/
I'm trying to create a Coverflow like slideshow using CSS3 transitions, but I'm getting different results from different browsers:
FF; shows wanted behaviour (right slide animates from right to center).
CHROME; first positions right slide at left side, then animates to center.
IE10; does nothing
HTML:
<div class="left">left</div>
<div class="middle">middle</div>
<div class="right">right</div>
CSS:
div{
position:absolute;
width: 300px;
height:100px;
background-color: yellow;
margin-left: -150px;
left: 50%;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.middle{
text-align:center;
z-index:2;
height:120px;
}
.left{
text-align:left;
left: 0;
right: auto;
margin-left: 0;
background-color:green;
}
.right{
cursor:pointer;
text-align:right;
right: 0;
left: auto;
margin-left:0;
background-color:red;
}
The problem here is indeed that browsers have no, or at best, various results for animating to and from 'auto'.
To fix this, I have re-written the CSS to not use left:auto; right:0; but left:100%; margin-left:-300px. This means I only have to animate the left and margin-left property, and I don't need to reset them to the default auto. The negative margin is the same amount as the width of the element, which pulls it back to the desired position, giving the same result as right:0;.
Here's an updated fiddle: http://jsfiddle.net/nweBD/3/

100% width in bootstrap for iPhone

I'm using bootstrap for a simple HTML5, CSS3 website.(see here: http://skyfistudio.com/project/fsc/ ) .there are three divs that should be 100% width.
It's looking good in desktop and all browsers. But in iPhone , it shows aligned left(Please see the attached image). I want it to stretch 100%. The iPhone view is here:
http://skyfistudio.com/project/fsc/hosting/
Here is the code for first navigation:
ul.fnav
{
list-style-type:none;
margin:0 auto;
padding:0;
padding-top:8px;
padding-bottom:8px;
text-align:center;
margin-top:0px;
background-color:#3B5998;
width:100%;
}
ul.fnav li
{
display:inline;
}
ul.fnav a:link,ul.fnav a:visited
{
font-weight:normal;
color:#fff;
margin-left:10px;
font-size:13px;
text-align:center;
padding:6px;
margin-right:55px;
text-decoration:none;
text-transform:uppercase;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
ul.fnav a:hover,a:active
{
color:#ccc;
}
Place them inside a <div class="container-fluid">...</div>
Make Both and the image div in one div so that bot come in one row-fluid and also check with #media-queries in custom.css

CSS animating button issue - during fade in animation of hover the rest of the buttons move

I am creating a vertical navigation and have already made the CSS properties for the buttons.
The hover properties are faded in using:
-webkit-transition:all .1s;
-moz-transition:all .1s;
-o-transition:all .1s;
-ms-transition:all .1s;
However, because the hover button is larger than the static button, during the animation the stack of buttons move. is there anything I can do to stop this?
The full code looks like this:
<div id="nav">
<form method="post" action="">
<a>Home</a>
<a>link 2</a>
<a>link 3</a>
</form>
</div>
#nav {
position:absolute;
margin-top:96px;
margin-left:30px;
height: 450px;
width: 140px;
font-family:"Book Antiqua";}
#nav a {
background:url(Images/Button.png);
height:28px;
width:130px;
font-size:14px;
text-align:center;
color:#C60;
text-decoration:none;
background-position:center;
margin:auto;
display:block;
position:relative;
line-height:190%;
}
#nav a:hover {
background:url(Images/Button%20Hover.png);
height:34px;
width:140px;
font-size:16px;
text-align:center;
color:#C60;
text-decoration:none;
margin:-3px;
z-index:2;
line-height:220%;
text-indent:-10px;
-webkit-transition:all .1s;
-moz-transition:all .1s;
-o-transition:all .1s;
-ms-transition:all .1s;}
#nav a:active {
background:url(Images/Button%20Hover.png);
height:34px;
width:140px;
font-size:16px;
text-align:center;
color:#C60;
text-decoration:none;
margin:-3px;
z-index:2;
line-height:210%;
text-indent:-10px;}
Use CSS transform method instead of scaling with font-size, margin or line-height: http://jsfiddle.net/tovic/KSZsH/4/

Resources