Skip to content

Instantly share code, notes, and snippets.

@jerewall
Last active February 15, 2018 15:54
Show Gist options
  • Save jerewall/cb7d6453b90f3e4ba175e75b9cc7c86f to your computer and use it in GitHub Desktop.
Save jerewall/cb7d6453b90f3e4ba175e75b9cc7c86f to your computer and use it in GitHub Desktop.
Call to Action Section with icon flip using ACF
jQuery
------------
$('.hover').hover(function(){
$(this).addClass('flip');
},function(){
$(this).removeClass('flip');
});
-----------
the html / php
----------------------------------------------------------------------------------
<div class="cta-wrapper">
<div class="wrap">
<div class="webcom-container flex">
<?php if( have_rows( 'cta_section_1', 'option' ) ) : ?>
<?php while( have_rows( 'cta_section_1', 'option' ) ) : the_row(); ?>
<div class="cta-wrap">
<div class="hover panel">
<div class="front">
<div class="box1">
<div class="centerit">
<?php $image = get_sub_field( 'image'); ?> <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>">
<h3><?php echo get_sub_field('title');?></h3>
</div>
</div>
</div>
<div class="back">
<div class="box2">
<div class="centerit">
<h3><?php echo get_sub_field('flipside_title'); ?></h3>
<?php echo get_sub_field('flipside_text'); ?>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
</div>
------------------------------------------------------------------------------------
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Call to Action Section
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
.cta-wrapper {
background: url('images/cta1-bg.jpg') no-repeat top center;
min-height: 900px;
padding: 80px 0px;
.webcom-container {
@include justify-content (flex-start);
@include flexbox;
@include flex-wrap(wrap);
@include bp($tablet) {
@include bp($tablet) {
@include flex-direction(column);
@include flex-wrap(wrap);
}
}
}
.wrap {
max-width: 1125px;
}
.cta-wrap {
position: relative;
@include justify-content (center);
align-items: center;
max-width: 100%;
padding: 0 70px;
&:first-child {
padding-left: 0;
}
&:nth-child(3) {
padding-right: 0;
}
&:nth-child(4) {
padding-left: 181px;
}
&:last-child {
padding-right: 0;
}
@include bp($tablet) {
width: 100%;
}
.centerit {
position: absolute;
@include center();
width: 100%;
}
h3 {
font-size: 30px;
text-align: center;
color: $base;
margin: 0;
}
.widget-image {
overflow: hidden;
margin: 0px auto;
img {
display: block;
margin: 0px auto;
vertical-align: middle;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px transparent;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
&:hover {
-webkit-transform: scale(1.1);
transform: scale(1.1);
-webkit-transition-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);
transition-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);
}
}
}
.panel {
margin: 0 auto;
position: relative;
.front {
height: inherit;
top: 0;
z-index: 900;
text-align: center;
-webkit-transform: rotateX(0deg) rotateY(0deg);
-moz-transform: rotateX(0deg) rotateY(0deg);
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-transition: all .4s ease-in-out;
-moz-transition: all .4s ease-in-out;
-ms-transition: all .4s ease-in-out;
-o-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
* {
text-align: center;
}
}
.back {
height: inherit;
position: absolute;
top: 0;
z-index: 1000;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-transition: all .4s ease-in-out;
-moz-transition: all .4s ease-in-out;
-ms-transition: all .4s ease-in-out;
-o-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
* {
text-align: center;
}
}
&.flip {
.front {
z-index: 900;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
}
.back {
z-index: 1000;
-webkit-transform: rotateX(0deg) rotateY(0deg);
-moz-transform: rotateX(0deg) rotateY(0deg);
}
}
.box1 {
background-color: $accent2;
width: 220px;
height: 220px;
margin: 0 auto;
padding: 20px;
border-radius: 50%;
}
.box2 {
background-color: $accent1;
width: 220px;
height: 220px;
margin: 0 auto;
padding: 20px;
border-radius: 50%;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment