I am trying to do an animation slider using only CSS. I have 3 pictures that I want to slide horizontally. My question is that I can add them transformation, but no animation The animation has to stop for a few seconds on each image. Anyone has ideas how to manage it? I use sass.
Code:
.slider {
position: relative;
height: 100vh;
// width: 100vw;
overflow: hidden;
display: block;
.slides {
position: absolute;
top: 0;
left: 0;
overflow: hidden;
display: flex;
transition-timing-function: ease-out;
animation: slide 3s steps(2) infinite;
.slide {
height: 100vh;
width: 100vw;
padding: 100px;
margin: 0 auto;
float: left;
text-align: center;
img {
margin: 0 auto;
border-radius: 50%;
height: 250px;
}
h1 {
color: #323232;
font-size: 32px;
line-height: 42px;
letter-spacing: 1px;
padding-bottom: 12px;
}
h4 {
font-weight: 200;
line-height: 32px;
letter-spacing: 0.9px;
display: flex;
}
}
//end .slide
&:after {
content: "";
clear: both;
display: block;
}
}
//end .slides
#keyframes slide {
to {
transform: translateX(-300vw);
}
}
}
}
<section class="slider">
<div class="slides">
<div class="slide">
<img src="images/testimonial-img-1.jpg" alt="" />
<h1>TANYA - Architect</h1>
<h4>Lorem ipsum dolor sit amet, maecenas eget vestibulum justo imperdiet, wisi risus purus augue vulputate voluptate neque, curabitur dolor libero sodales vitae elit massa.</h4>
</div>
<div class="slide">
<img src="images/testimonial-img-2.jpg" alt="" />
<h1>LINDA - City planner</h1>
<h4>Lorem ipsum dolor sit amet, maecenas eget vestibulum justo imperdiet, wisi risus purus augue vulputate voluptate neque, curabitur dolor libero sodales vitae elit massa.</h4>
</div>
<div class="slide">
<img src="images/testimonial-img-3.jpg" alt="" />
<h1>SANDAR - Developer</h1>
<h4>Lorem ipsum dolor sit amet, maecenas eget vestibulum justo imperdiet, wisi risus purus augue vulputate voluptate neque, curabitur dolor libero sodales vitae elit massa.</h4>
</div>
</div>
</section>
Try this:-
#outerbox{
width:700px;
overflow:hidden;
}
#sliderbox{
position:relative;
width:2800px;
animation:animation 20s infinite;
}
#sliderbox img{
float:left;
}
#keyframes animation{
0%{
left:0px;
}
100%{
left:-2800px;
}
}
<div id="outerbox">
<div id="sliderbox">
<img src="http://labs.qnimate.com/slider/1.jpg"/>
<img src="http://labs.qnimate.com/slider/2.jpg"/>
<img src="http://labs.qnimate.com/slider/3.jpg"/>
Ok try this
#outerbox{
width:700px;
}
#sliderbox{
position:relative;
width:2800px;
animation:animation 20s infinite;
}
#sliderbox img{
float:left;
}
#keyframes animation{
0%{
left:0px;
}
20%{
left:0px;
}
25%{
left:-700px;
}
45%{
left:-700px;
}
50%{
left:-1400px;
}
70%{
left:-1400px;
}
}
<div id="outerbox">
<div id="sliderbox">
<img src="http://labs.qnimate.com/slider/1.jpg"/>
<img src="http://labs.qnimate.com/slider/2.jpg"/>
<img src="http://labs.qnimate.com/slider/3.jpg"/>
</div>
</div>
Your css, fixed:
.slider{
position: relative;
height: 100vh;
// width: 100vw;
overflow: hidden;
display: block;
}
.slides{
position: absolute;
top: 0;
left: 0;
overflow: hidden;
display: flex;
animation: slide 3s ease-out infinite;
}
.slide{
height: 100vh;
width: 100vw;
padding: 100px;
margin: 0 auto;
float: left;
text-align: center;
}
img{
margin: 0 auto;
border-radius: 50%;
height: 250px;
}
h1{
color: #323232;
font-size: 32px;
line-height: 42px;
letter-spacing: 1px;
padding-bottom: 12px;
}
h4{
font-weight: 200;
line-height: 32px;
letter-spacing: 0.9px;
display: flex;
}
&:after{
content: "";
clear: both;
display: block;
}
The closing } were wrong. you can't have a css rule inside another.
Also the transition timing wasn't doing anything if you are using animation, you can add it to the animation declaration. Transition and animation are two different things. Both have timing function which you can declare on a single line or separately.
Related
I'm creating a dating site to learn web dev and I don't know how to make background-color work, it just doesn't on specific divs. What should I change? I tried a lot of things but nothing happened.
Adding lorem ipsum so I can ask this question... just skip this
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ut felis magna. Cras lectus sapien, porttitor quis elit id, lacinia pellentesque urna. Fusce gravida felis sit amet purus mattis, sed faucibus turpis hendrerit. Integer convallis sagittis pulvinar. Curabitur tristique faucibus lorem iaculis egestas. Vivamus vitae lacus placerat, efficitur diam et, volutpat augue. Cras at purus vitae neque ultricies iaculis. Maecenas pellentesque ipsum nisi.
My code:
* {
padding: 0;
margin: 0;
color: black;
}
body {
overflow: hidden;
}
.container {
margin-left: auto;
margin-right: auto;
margin-top: 10px;
width: 95%;
height: 750px;
}
nav {
display: flex;
justify-content: space-between;
font-family: 'Pattaya', sans-serif;
font-size: 39px;
}
.logo {
cursor: pointer;
margin-top: auto;
margin-bottom: auto;
}
.menu {
margin-top: auto;
margin-bottom: auto;
}
nav ul {
list-style-type: none;
}
nav ul li {
padding: 30px;
display: inline-block;
}
nav ul li a {
text-decoration: none;
}
nav ul li a:hover {
background-color: #ede;
border-radius: 10px;
}
.circle {
z-index: -2;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #ede;
clip-path: circle(600px at right 800px);
}
.circlebig {
z-index: -2;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #ede;
clip-path: circle(940px at left);
}
.content {
display: flex;
justify-content: space-between;
font-family: 'Rubik', sans-serif;
font-size: 56px;
}
.text {
transform: translateY(25%);
}
.love {
font-size: 70px;
background-image: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: move 400s linear infinite;
}
#keyframes move {
to {
background-position: 4500vh;
}
.freeplan {
z-index: 3;
display: block;
background-color: #666 !important;
}
.paidplan {
z-index: 3;
display: block;
background-color: #35f !important;
}
<link href="https://fonts.googleapis.com/css2?family=Pattaya&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Rubik:ital,wght#1,300&display=swap" rel="stylesheet">
<main>
<div class="container">
<nav>
<div class="logo">
<img src="img/logo.png">
</div>
<div class="menu">
<ul>
<li> ⁣ ⁣ Plans ⁣ ⁣ </li>
<li> ⁣ ⁣ About ⁣ ⁣ </li>
<li> ⁣ ⁣ Login ⁣ ⁣ </li>
</ul>
</div>
</nav>
<section class="content">
<div class="freeplan">
Freeplan
<img src="img/kiss.png">
</div>
<div class="paidplan">
Paidplan
<img src="img/kiss.png">
</div>
<img src="img/kiss.png">
</section>
<div class="circle"></div>
<div class="circlebig"></div>
</div>
</main>
You didn't close the curly brackets:
#keyframes move {
to {
background-position: 4500vh;
} // <==
}
I think you may miss the '#keyframes' curly bracket. please replace the #keyframes' as like my code.
#keyframes move {
to {
background-position: 4500vh;
}
}
This question already has answers here:
Flexbox responsive row column layout
(3 answers)
Converting desktop layout to single-column mobile layout
(1 answer)
Closed 1 year ago.
I am working on a website.
I have a container, that has two columns. On the left, I have a product image, that when you hover on it, it shows that product in use.
To the right, I have a title, description, tech drawings.
I want it so that when the screen is resized to a mobile format, or even if the browser is shrunk, the columns will stack on top of one another.
Right now the image just gets smaller and smaller until you cannot see it.
I tried several attempts at using FlexBox. Did not have any luck. Here was the guide/rules I was following: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Here is a quick JSfiddle I made up to see what I am talking about. This does not have any "attempt" code in it. Just the base code for the containing div, left and right columns, with some example images and text. https://jsfiddle.net/fmcdLxa4/1/
.container {
max-width: 1200px;
margin: 0 auto;
display: flex;
padding: 15px;
}
/* Columns */
.left-column {
float: left;
width: 50%;
padding: 10px;
position: relative;
border-bottom: 1px solid #E1E8EE;
}
.right-column {
float: left;
width: 50%;
padding: 10px;
}
/* Left Column */
.left-column img {
display: block;
margin-left: auto;
margin-right: auto;
vertical-align: auto;
}
/* Right Column */
/* Product Description */
.product-description {
border-bottom: 1px solid #E1E8EE;
}
.product-description span {
font-size: 12px;
color: #358ED7;
letter-spacing: 1px;
text-transform: uppercase;
text-decoration: none;
}
.product-description h1 {
font-weight: 300;
font-size: 52px;
color: #43484D;
letter-spacing: -2px;
}
.product-description p {
font-size: 16px;
font-weight: 300;
color: #86939E;
line-height: 24px;
}
.product-description a {
color: #358ED7;
}
.flip-box {
background-color: transparent;
width: 100%;
height: 100%;
perspective: 1000px;
}
.flip-box-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-box:hover .flip-box-inner {
transform: rotateY(180deg);
}
.flip-box-front,
.flip-box-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.flip-box-front {
background-color: transparent;
}
.flip-box-back {
background-color: transparent;
transform: rotateY(180deg);
}
<div class="container">
<!-- Left Column -->
<div class="left-column">
<p> </p>
<div height="15"></div>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<img src="https://dogtowndogtraining.com/wp-content/uploads/2012/06/300x300-061-e1340955308953.jpg" style="max-width: 100%">
</div>
<div class="flip-box-back">
<img src="http://www.deepdiveintel.com/wp-content/uploads/2013/09/Owl-Eye-art-300x300.jpg" style="max-width: 100%">
</div>
</div>
</div>
</div>
<!-- Right Column -->
<div class="right-column">
<!-- Product Description -->
<div class="product-description">
<span>Lorem ipsum dolor sit amet</span>
<h1>Lorem ipsum dolo</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi arcu sem, bibendum id tellus ac, aliquam faucibus massa. Nulla facilisi. Fusce vel condimentum velit. Praesent nec ultricies erat. Sed ante lectus, ultrices ut laoreet id, tincidunt
a augue.</p>
<p>Technical drawings: 7/0 | 8/0
<p />
</div>
</div>
</div>
Any help would be awesome!
flex can wrap if you set it so. Also, one of your card's image needs to remain in the flow, so it can size its container. then flex:1 1 XX% will do the job.
https://codepen.io/gc-nomade/pen/MWpxYZw
.container {
max-width: 1200px;
margin: 0 auto;
display: flex;
flex-wrap:wrap;
padding: 15px;
}
/* Columns */
.left-column {
flex:1 1 40%;
padding: 10px;
position: relative;
border-bottom: 1px solid #E1E8EE;
min-width:320px;
}
.right-column {
flex:1 1 40%;
padding: 10px;
}
/* Left Column */
.left-column img {
display: block;
margin-left: auto;
margin-right: auto;
vertical-align: auto;
}
/* Right Column */
/* Product Description */
.product-description {
border-bottom: 1px solid #E1E8EE;
}
.product-description span {
font-size: 12px;
color: #358ED7;
letter-spacing: 1px;
text-transform: uppercase;
text-decoration: none;
}
.product-description h1 {
font-weight: 300;
font-size: 52px;
color: #43484D;
letter-spacing: -2px;
}
.product-description p {
font-size: 16px;
font-weight: 300;
color: #86939E;
line-height: 24px;
}
.product-description a {
color: #358ED7;
}
.flip-box {
background-color: transparent;
width: 100%;
height: 100%;
perspective: 1000px;
}
.flip-box-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-box:hover .flip-box-inner {
transform: rotateY(180deg);
}
.flip-box-back{
position: absolute;
top:0;
}
.flip-box-front,
.flip-box-back {
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.flip-box-front {
background-color: transparent;
}
.flip-box-back {
background-color: transparent;
transform: rotateY(180deg);
}
<div class="container">
<!-- Left Column -->
<div class="left-column">
<p> </p>
<div height="15"></div>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<img src="https://picsum.photos/id/1003/300/300" style="max-width: 100%">
</div>
<div class="flip-box-back">
<img src="https://picsum.photos/id/10/300/300" style="max-width: 100%">
</div>
</div>
</div>
</div>
<!-- Right Column -->
<div class="right-column">
<!-- Product Description -->
<div class="product-description">
<span>Lorem ipsum dolor sit amet</span>
<h1>Lorem ipsum dolo</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi arcu sem, bibendum id tellus ac, aliquam faucibus massa. Nulla facilisi. Fusce vel condimentum velit. Praesent nec ultricies erat. Sed ante lectus, ultrices ut laoreet id, tincidunt
a augue.</p>
<p>Technical drawings: 7/0 | 8/0
<p />
</div>
</div>
</div>
Good afternoon,
I've been using HTML and CSS for a couple of weeks now and recently came across a problem that I have no clue about how to fix. Before I added a background-image, the contact id worked just fine and the CSS loaded properly. But after adding the image in the pages class, the CSS contact id didn't work anymore. Also in the element inspector the properties of the contact id were not there.
So I'm not sure If I missed something in between the link of HTML and CSS or that I coded it in the wrong order. The code below is after the contact id stopped working.
.pages {
background-image: url("img/background.png");
}
#contact {
position: absolute;
right: 0;
bottom: 0;
left: 0;
padding: 1px;
background-color: #171717;
text-align: right;
}
.sidebar {
font-family: 'Yanone Kaffeesatz', sans-serif;
position: fixed;
top: 0;
bottom: 0;
left: 0;
margin: auto;
background-color: #212121;
width: 100px;
transition: all ease 0.5s;
}
ul {
position: relative;
top: 50%;
transform: translateY(-50%);
list-style: none;
padding: 0;
margin: 0;
}
li, a {
text-decoration: none;
position: relative;
display: block;
}
i.fa {
display: block;
text-align: center;
padding: 30px 10px;
font-size: 30px;
background-color: #565656;
color: #212121;
z-index:1;
}
span {
color: #fff;
font-size: 18px;
position: absolute;
top: 0;
bottom: 0;
left: -100%;
margin: auto;
display: block;
height: 100%;
padding: 0px 10px;
text-align: center;
z-index: -1;
background-color: #000000;
transition:all ease 0.5s;
line-height: 90px;
&::after {
content:"";
position: absolute;
left: 100%;
top: 0;
bottom: 0;
margin: auto;
border: 45px solid transparent;
border-left-color: #000;
height: 0;
width: 0;
}
}
&:hover {
i.fa {
background-color: #000;
}
span {
left: 100%;
}
}
<!DOCTYPE html>
<html>
<head>
<title>sidebar</title>
<link rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"
integrity="sha384-
mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU"
crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz"
rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="sidebar">
<ul>
<li><a href="#"><i class="fa fa-graduation-cap"></i>
<span>Opleiding</span></a></li>
<li><a href="#"><i class="fa fa-briefcase"></i>
<span>Werkervaring</span></a></li>
<li><a href="#"><i class="fa fa-lightbulb"></i>
<span>Vaardigheden</span></a></li>
</ul>
</div>
<div class="pages">
</div>
<div class="footer">
contact
</div>
</body>
</html>
Thanks for your time and hope you guys and women can help me out. By the way English isn't my native language so I hope I explained it clearly.
Dirk van Houten
I will consider CSS grid, hope it will be much more organized
If you think grid is okay for you, it can indeed avoid the use of position and sides effects.
example:
/* grid instead position: */
body {
margin:0;
display: grid;
height: 100vh;
grid-template-columns: 100px 1fr;
grid-template-rows: 1fr 20px;
}
.sidebar {
display: flex;
align-items: center;
}
.footer {
grid-row: 2;
grid-column: 1 / span 3;
}
.pages {
overflow: auto;
}
/* end grid system */
/* position and coordonates, so transform are removed from codes */
.pages {
background-image: url("http://dummyimage.com/50x50");
}
#contact {
padding: 1px;
background-color: #171717;
text-align: right;
}
.sidebar {
font-family: "Yanone Kaffeesatz", sans-serif;
background-color: #212121;
width: 100px;
transition: all ease 0.5s;
}
ul {
list-style: none;
padding: 0;
margin: 0;
min-width: 100%;
overflow: visible;
}
.sidebar a {
position: relative;
}
li,
a {
text-decoration: none;
z-index: 1;
display: block;
}
i.fa {
display: block;
text-align: center;
padding: 30px 10px;
font-size: 30px;
background-color: #565656;
color: #212121;
z-index: 1;
}
a span {
color: #fff;
font-size: 18px;
position: absolute;
top: 0;
bottom: 0;
left: -100%;
margin: auto;
display: block;
height: 100%;
padding: 0px 10px;
text-align: center;
z-index: -1;
background-color: #000000;
transition: all ease 0.5s;
line-height: 90px;
}
a span::after {
content: "";
position: absolute;
left: 100%;
top: 0;
bottom: 0;
margin: auto;
border: 45px solid transparent;
border-left-color: #000;
height: 0;
width: 0;
overflow: hidden;
}
:hover i.fa {
background-color: #000;
}
a:hover span {
left: 100%;
}
<link rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"
integrity="sha384-
mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU"
crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz"
rel="stylesheet">
<div class="sidebar">
<ul>
<li><a href="#"><i class="fa fa-graduation-cap"></i>
<span>Opleiding</span></a></li>
<li><a href="#"><i class="fa fa-briefcase"></i>
<span>Werkervaring</span></a></li>
<li><a href="#"><i class="fa fa-lightbulb"></i>
<span>Vaardigheden</span></a></li>
</ul>
</div>
<div class="pages">
<h1>HTML Ipsum Presents</h1>
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.</p>
<h2>Header Level 2</h2>
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ol>
<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>
<h3>Header Level 3</h3>
<ul>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ul>
<pre><code>
#header h1 a {
display: block;
width: 300px;
height: 80px;
}
</code></pre>
</div>
<div class="footer">
contact
</div>
This question already has answers here:
What does + mean in CSS? [duplicate]
(4 answers)
What does the ">" (greater-than sign) CSS selector mean?
(8 answers)
What does the "~" (tilde/squiggle/twiddle) CSS selector mean?
(3 answers)
What does a space mean in a CSS selector? i.e. What is the difference between .classA.classB and .classA .classB? [duplicate]
(3 answers)
Closed 4 years ago.
On parent div hover, I want it's two child div's to move position via translate.
I've tried to form my code based on this approach, but when applying the code to practise, it doesn't work for me, wondering why?
/* HOVER DEFINED HERE */
.cta-wrapper:hover + .cta-image {
transform: translate(20px, 5px);
}
.cta-wrapper:hover ~ .cta-text {
transform: translate(-10px, -10px);
}
/************************/
.cta-wrapper {
position: relative;
padding-right: 15px;
padding-left: 15px;
width: 98.33333%;
transition: all 0.3s;
max-width: 1220px;
padding: 0 20px 80px;
margin: 0 auto;
}
.cta-wrapper a {
text-decoration: none;
text-align: left;
color: #fff;
}
.cta-image {
transition: all 0.2s;
z-index: 100;
position: relative;
}
.cta-text {
width: 295px;
text-align: left;
padding: 30px;
transform: translate(10px, -10px);
transition: all 0.2s;
background-color: #404262;
}
.card {
display: block;
border: none;
}
<div class="cta-wrapper">
<a href="#" class="card inverse-text">
<div class="cta-image"><img src="https://cdn2.hubspot.net/hubfs/548247/Tomorrow%20People/Landing%20Page/Template%20Build/GC_Jan_2017_137.png?t=1530188524021"></div>
</a>
<div class="cta-text">
<a href="#" class="card inverse-text">
<h3>Nam quis dolor id justo aliquet cursus in malesuada ante.</h3>
<p>Morbi vel efficitur orci, sit amet gravida dui. Integer dapibus ac mi a volutpat. Sed sed augue pulvinar, dignissim mauris non.</p>
</a>
<div class="fake-button">Read more <i class="arrow"></i></div>
</div>
</div>
Your selectors are incorrect for the hover. The selectors you've got aren't targeting child elements, they're targeting elements after the wrapper.
This should work:
/* HOVER DEFINED HERE */
.cta-wrapper:hover .cta-image {
transform: translate(20px, 5px);
}
.cta-wrapper:hover .cta-text {
transform: translate(-10px, -10px);
}
/************************/
.cta-wrapper {
position: relative;
padding-right: 15px;
padding-left: 15px;
width: 98.33333%;
transition: all 0.3s;
max-width: 1220px;
padding: 0 20px 80px;
margin: 0 auto;
}
.cta-wrapper a {
text-decoration: none;
text-align: left;
color: #fff;
}
.cta-image {
transition: all 0.2s;
z-index: 100;
position: relative;
}
.cta-text {
width: 295px;
text-align: left;
padding: 30px;
transform: translate(10px, -10px);
transition: all 0.2s;
background-color: #404262;
}
.card {
display: block;
border: none;
}
<div class="cta-wrapper">
<a href="#" class="card inverse-text">
<div class="cta-image"><img src="https://cdn2.hubspot.net/hubfs/548247/Tomorrow%20People/Landing%20Page/Template%20Build/GC_Jan_2017_137.png?t=1530188524021"></div>
</a>
<div class="cta-text">
<a href="#" class="card inverse-text">
<h3>Nam quis dolor id justo aliquet cursus in malesuada ante.</h3>
<p>Morbi vel efficitur orci, sit amet gravida dui. Integer dapibus ac mi a volutpat. Sed sed augue pulvinar, dignissim mauris non.</p>
</a>
<div class="fake-button">Read more <i class="arrow"></i></div>
</div>
</div>
Because of .cta-image and .cta-text being children, you're using the wrong selectors to target them.
/* HOVER DEFINED HERE */
.cta-wrapper:hover .cta-image {
transform: translate(20px, 5px);
}
.cta-wrapper:hover .cta-text {
transform: translate(-10px, -10px);
}
/************************/
.cta-wrapper {
position: relative;
padding-right: 15px;
padding-left: 15px;
width: 98.33333%;
transition: all 0.3s;
max-width: 1220px;
padding: 0 20px 80px;
margin: 0 auto;
}
.cta-wrapper a {
text-decoration: none;
text-align: left;
color: #fff;
}
.cta-image {
transition: all 0.2s;
z-index: 100;
position: relative;
}
.cta-text {
width: 295px;
text-align: left;
padding: 30px;
transform: translate(10px, -10px);
transition: all 0.2s;
background-color: #404262;
}
.card {
display: block;
border: none;
}
<div class="cta-wrapper">
<a href="#" class="card inverse-text">
<div class="cta-image"><img src="https://cdn2.hubspot.net/hubfs/548247/Tomorrow%20People/Landing%20Page/Template%20Build/GC_Jan_2017_137.png?t=1530188524021"></div>
</a>
<div class="cta-text">
<a href="#" class="card inverse-text">
<h3>Nam quis dolor id justo aliquet cursus in malesuada ante.</h3>
<p>Morbi vel efficitur orci, sit amet gravida dui. Integer dapibus ac mi a volutpat. Sed sed augue pulvinar, dignissim mauris non.</p>
</a>
<div class="fake-button">Read more <i class="arrow"></i></div>
</div>
</div>
1. I have a 4 column row of divs that move a little when hovered (with margin and padding). How can I keep this movement from moving the content that is below it without adding a fixed height. It is in a fluid layout so with a fixed height that allows enough room for the movement, the content below starts to get too far away as the window width is reduced and the images scale down.
2. For the bounty you need to make the jsFiddle work.
It seems that even though I have transition: all, all of the padding-bottom gets added instantly while the margin-top transitions for 300ms. Shouldn't the padding transition also? I think that would get rid of the jump. I tried transitioning height on hover for the same effect but it had the same exact issue. the height just got added instead of transitioning.
I made a jsFiddle to play with.
HTML:
<header class="sectionTitle lightboxes clearfix">
<h3><i class="i-small icon-folder-open"></i><strong>Portfolio</strong></h3>
</header>
<article id="row2fluid" role="presentation">
<section id="row2col1"> <a class="slider" href="#"><img src="http://mtctinc.com/images/folioImg1.jpg" alt="porfolio 1" />
<div class="caption">
<h3>Example 1</h3>
<span>Slider/Slideshow</span>
</div>
</a>
</section>
<section id="row2col2"> <a class="youtube" href="#"><img src="http://mtctinc.com/images/folioImg2.jpg" alt="portfolio 2" />
<div class="caption">
<h3>Example 2</h3>
<span>Youtube</span>
</div>
</a>
</section>
<section id="row2col3"> <a href="#" class="clearfix"><img src="http://mtctinc.com/images/folioImg3.jpg" alt="porfolio 3" />
<div class="caption">
<h3>Example 3</h3>
<span>Flash</span>
</div>
</a>
</section>
<section id="row2col4"> <a href="#" class="clearfix"><img src="http://mtctinc.com/images/folioImg4.jpg" alt="portfolio 4" />
<div class="caption">
<h3>Example 4</h3>
<span>HTML</span>
</div>
</a>
</section>
</article>
<div id="moreContent">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget nulla laoreet, blandit massa eu, mollis tellus. Duis pellentesque dui nec diam ullamcorper, ac dignissim sapien interdum. Proin in libero nec neque fermentum varius. Integer hendrerit, justo feugiat porttitor iaculis, nisl purus luctus neque, non ultrices magna quam et magna. Proin porttitor, metus sed commodo pharetra, lacus eros aliquet diam, eu auctor nisi diam quis felis.</div>
CSS:
.sectionTitle {
border-bottom: 3px solid #e9e9e9;
width:100%;
}
.sectionTitle h3 {
font-size:11px;
text-transform:uppercase;
font-weight:bold;
border-bottom: 3px solid #3b3b3b;
display:table;
margin-bottom: -2px;
float: left;
width: 100%;
min-height: 33px;
line-height: 19px;
padding-bottom: 10px;
}
.sectionTitle strong {
display: inline-block;
padding-left:10px;
line-height:14px;
}
.lightboxes {
position: relative;
clear:both;
padding-top: 30px;
}
#row2fluid {
text-align: center;
position: relative;
float: left;
width: 100%;
}
#row2fluid img {
opacity: .8;
border: none;
-webkit-transition:all 300ms;
-o-transition:all 300ms;
-moz-transition:all 300ms;
transition:all 300ms;
}
#row2fluid a:hover img {
opacity: 1;
margin-top: -16px;
}
#row2fluid a:hover .caption h3 {
color: #F15A2B;
}
#row2fluid .caption {
border-bottom: 1px solid #E9E9E9;
margin: 0px 3px;
line-height: .7em;
padding: 14px 0 30px;
}
#row2fluid a:hover .caption {
border-bottom: 1px solid #F15A2B;
background-color: #f7f7f7;
padding-bottom: 46px;
}
#row2fluid .caption span {
font-style: italic;
font-size: 12px;
color: #ACACAC;
}
#row2col1 {
clear: both;
float: left;
margin-left: 0;
width: 24.1758%;
display: inline-block;
padding-top: 40px;
margin-top: -1px;
}
#row2col2 {
clear: none;
float: left;
margin-left: 1.0989%;
width: 24.1758%;
display: inline-block;
padding-top: 40px;
margin-top: -1px;
}
#row2col3 {
clear: none;
float: left;
margin-left: 1.0989%;
width: 24.1758%;
display: inline-block;
padding-top: 40px;
margin-top: -1px;
}
#row2col4 {
clear: none;
float: left;
margin-left: 1.0989%;
width: 24.1758%;
display: inline-block;
padding-top: 40px;
margin-top: -1px;
}
#row2col1:hover {
border-top: 3px solid #F15A2B;
padding-top: 37px;
}
#row2col2:hover {
border-top: 3px solid #F15A2B;
padding-top: 37px;
}
#row2col3:hover {
border-top: 3px solid #F15A2B;
padding-top: 37px;
}
#row2col4:hover {
border-top: 3px solid #F15A2B;
padding-top: 37px;
}
#moreContent {
clear: both;
position: relative;
float: left;
margin-left: 0;
width: 100%;
display: block;
padding-top: 20px;
}
You just need to add
-webkit-transition:all 300ms;
-o-transition:all 300ms;
-moz-transition:all 300ms;
transition:all 300ms;
to the caption as well.
See here
http://jsfiddle.net/ZuU8V/4/