html - Animating a "peek" effect with CSS only -


i'm trying create "peek" effect css animations.

what mean there little blurb of content in square, more detailed description underneath. when user hovers on square, new content slides bottom , fills in space contains.

i have javascript solution uses mouseenter , mouseleave calculate correct position of top based on heights of things area visible, , have css animation on that, i'm trying figure out way using css.

my attempt far this: http://jsfiddle.net/7yrwl/1/

this uses technique this:

.peek { max-height: 0; transition: max-height 1s; } .main:hover .peek { max-height: 300px; } /* i'd prefer if auto or 100% */ 

when hover on main, max-height changes , pushes peek content view.

however, problem since have use static px value max-height in order css transition work, animation looks takes different amount of time complete depending on how large peek text is. has noticeable delay when hover off of max-height transition "catches up" real height.

anyone know alternate ways (not using javascript)?

well, tricky, key use translation , take care titles height:

http://jsfiddle.net/coma/vzvxf/17/

html

<ul class="peeks">     <li>         <div>             <div>                 <div class="title">                     <h3>title</h3>                     <h4>subtitle</h4>                 </div>                 <div class="peek">                     <p>test peek test peek<br/>test peek</p>                 </div>             </div>         </div>     </li>     <li>         <div>             <div>                 <div class="title">                     <h3>title</h3>                     <h4>subtitle</h4>                 </div>                 <div class="peek">                     <p>test peek test peek<br/>test peek</p>                     <p>test peek test peek<br/>test peek</p>                     <p>test peek test peek<br/>test peek</p>                     <p>test peek test peek<br/>test peek</p>                     <p>test peek test peek<br/>test peek</p>                     <p>test peek test peek<br/>test peek</p>                     <p>test peek test peek<br/>test peek</p>                     <p>test peek test peek<br/>test peek</p>                 </div>             </div>         </div>     </li> </ul> 

css

ul.peeks {     list-style: none;     padding: 0;     margin: 0; }  ul.peeks:after {     content: "";     clear: both; }  ul.peeks > li {     width: 300px;     border: 10px solid orange;     margin: 0 5px 5px 0;     float: left;     background-color: orange;     color: #fff;     overflow: hidden; }  ul.peeks > li.large {     width: 600px; }  ul.peeks > li > div {     padding: 75px 10px 10px 10px;     background-color: red;     position: relative; }  ul.peeks > li > div:after {     content: "";     position: absolute;     bottom: 0;     left: 0;     right: 0;     height: 10px;     background-color: red; }  ul.peeks > li > div > div {     -moz-transform: translate(0, 100%);     -ms-transform: translate(0, 100%);     -o-transform: translate(0, 100%);     -webkit-transform: translate(0, 100%);     transform: translate(0, 100%);     -moz-transition: -moz-transform 0.5s;     -o-transition: -o-transform 0.5s;     -webkit-transition: -webkit-transform 0.5s;     transition: transform 0.5s }  ul.peeks > li:hover > div > div {     -moz-transform: translate(0, 0);     -ms-transform: translate(0, 0);     -o-transform: translate(0, 0);     -webkit-transform: translate(0, 0);     transform: translate(0, 0) }  ul.peeks div.title {     height: 0;     position: relative;     top: -65px; }  ul.peeks h3 {     font-size: 30px;     line-height: 1em;     margin: 0; }  ul.peeks h4 {     font-size: 20px;     line-height: 1em;     margin: 5px 0 10px 0; }  ul.peeks div.peek {     padding: 10px;     background-color: green; } 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -