So I am trying to create a text reveal / text-slide-in animation.
I've created this:
#keyframes slide {
0% {
left: 0;
}
100% {
left: 105%;
}
}
.text-slide-in:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 105%;
animation: slide 1.5s ease infinite;
background: white;
box-shadow: 0 0 15px white, 0 0 10px white, 0 0 5px white;
}
<h1 class="text-slide-in">Lorem ipsum dolor, sit amet consectetur adipisicing elit.</h1>
And that is precisely the effect/animation I am after. The problem is that this basically creates an uneccesary width. You can see the horizontal scrollbar on the snippet.
The other problem with this approach becomes clear when adding a background-color to the parent element:
.site-wrap {
max-width: 700px;
margin: 0 auto;
}
section {
padding: 4rem;
border-radius: 8px;
background-color: red;
}
#keyframes slide {
0% {
width: 100%;
}
100% {
width: 0;
}
}
.text-slide-in {
position: relative;
}
.text-slide-in:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
top: 0;
right: 0;
animation: slide 1.5s ease infinite;
background: white;
box-shadow: 0 0 15px white, 0 0 10px white, 0 0 5px white;
}
<div class="site-wrap">
<section>
<h1 class="text-slide-in">
Lorem ipsum dolor, sit amet consectetur adipisicing elit.
</h1>
</section>
</div>
As you can see, it will not work when a background-color is set.
I've also tried doing this with transform & translateX css properties, but I cannot get that to work either.
What would be a solid solution in this case?
Use clip-path:
#keyframes slide {
0% {
clip-path: inset(0 100% 0 0);
}
100% {
clip-path: inset(0 0 0 0);
}
}
.text-slide-in {
animation: slide 1.5s ease infinite;
}
body {
background:linear-gradient(90deg,red,lightblue);
}
<h1 class="text-slide-in">Lorem ipsum dolor, sit amet consectetur adipisicing elit.</h1>
You could animate the width and start your position on the right instead of animating the left:
#keyframes slide {
0% {
width: 100%;
}
100% {
width: 0;
}
}
.text-slide-in:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
top: 0;
right: 0;
animation: slide 1.5s ease infinite;
background: white;
box-shadow: 0 0 15px white, 0 0 10px white, 0 0 5px white;
}
<h1 class="text-slide-in">Lorem ipsum dolor, sit amet consectetur adipisicing elit.</h1>
Related
I've noticed that some websites now days have the ability to have a type of element filler on a page where data is located before it loads or fetches it from the server.
In some cases it flashes a little bit or is slightly animated, to show that data is filling in that area of the page.
What is this, are there packages for it, etc?
Is there a name for it so I can google it?
And just to be clear, I'm not talking about spinners
ex. Airbnb uses this method when you load up pages on their site. I also see it on Okcupid.com
Are you looking for this type of things? I have found a link that explains a bit on that, you should see. View their demo on this codepen also.
As per I know there were no libraries for this effect. They are custom made thing. You can Google it by typing " Content placeholder effect ". Also you can refer this link for detailed information : https://cloudcannon.com/deconstructions/2014/11/15/facebook-content-placeholder-deconstruction.html
const cardImage = document.querySelector('.card-image');
const cardTitle = document.querySelector('.card-title');
const cardDesc = document.querySelector('.card-description');
const renderCard = () => {
cardTitle.textContent = 'Card Title Yo!';
cardDesc.textContent = 'Lorem ipsum dolor, sit amet consectetur adipisicing elit. Vero dicta repellat quibusdam assumenda at distinctio similique eos? Officiis voluptatem accusamus, id odit, quos eaque nemo, dicta quidem eum eligendi veritatis.';
createImage();
cardTitle.classList.remove('loading');
cardDesc.classList.remove('loading');
cardImage.classList.remove('loading');
};
function createImage() {
const img = new Image();
img.classList.add("image");
img.setAttribute('alt', 'A cloud day at a mountain base');
img.setAttribute('src', 'https://images.unsplash.com/photo-1516646255117-f9f933680173?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=dc874984018a4253ba7d2a3c53387135');
cardImage.appendChild(img);
}
setTimeout(() => {
renderCard();
}, 5000);
// window.addEventListener('load', () => {
// renderCard();
// });
body {
background: #f4f4f4;
margin: 0;
padding: 0;
font-family: system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue;
color: #333;
}
.container {
margin: 2rem auto;
max-width: 800px;
display: -webkit-box;
display: flex;
-webkit-box-pack: center;
justify-content: center;
}
.card {
overflow: hidden;
background: white;
border-radius: .25rem;
max-width: 380px;
width: 380px;
box-shadow: 0 15px 30px 0 rgba(0, 0, 0, 0.05), 0 5px 15px 0 rgba(0, 0, 0, 0.05);
-webkit-transition: ease box-shadow 0.3s;
transition: ease box-shadow 0.3s;
}
.card:hover {
box-shadow: 0 15px 60px 0 rgba(0, 0, 0, 0.08), 0 5px 25px 0 rgba(0, 0, 0, 0.08);
}
.card-detail {
padding: .5rem 1rem;
}
.card-detail h3 {
font-size: 1.5rem;
margin-bottom: none;
line-height: .09;
}
.card-detail p {
line-height: 1.3rem;
}
.card-image {
margin: 0;
padding: 0;
height: 200px;
overflow: hidden;
}
.card-image img {
max-width: 100%;
height: auto;
}
.loading {
position: relative;
background-color: #E2E2E2;
}
.loading.card-image {
border-radius: 0;
}
.loading::after {
display: block;
content: '';
position: absolute;
width: 100%;
height: 100%;
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
background: -webkit-gradient(linear, left top, right top, from(transparent), color-stop(rgba(255, 255, 255, 0.2)), to(transparent));
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
-webkit-animation: loading 1.5s infinite;
animation: loading 1.5s infinite;
}
#-webkit-keyframes loading {
100% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
}
#keyframes loading {
100% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
}
.card-title.loading {
height: 1.8rem;
}
.card-image.image {
max-width: 100%;
height: auto;
}
.card-description.loading {
height: 80px;
}
<div class="container">
<section class="card">
<figure class="card-image loading"></figure>
<div class="card-detail">
<h3 class="card-title loading"></h3>
<p class="card-description loading"></p>
</div>
</section>
</div>
Css will be used for the loading animation !!!
While fetching the data animation keeps on running.
Once the data is fetched then stop the animation
https://loading.io/css/
Here is a simple animation
<div class="lds-dual-ring"></div>
.lds-dual-ring {
display: inline-block;
width: 80px;
height: 80px;
}
.lds-dual-ring:after {
content: " ";
display: block;
width: 64px;
height: 64px;
margin: 8px;
border-radius: 50%;
border: 6px solid #fff;
border-color: #fff transparent #fff transparent;
animation: lds-dual-ring 1.2s linear infinite;
}
#keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
I am developing a typewritter effect with SCSS, here is the Codepen. To achieve the effect, I animate the width, to 0 to 30rem. I am trying to achieve a more modular workaround, which works in any desired width, no matter the width of the content.
For the moment, I have been only to think with a kind of #mixin which get the width (or max-width) value of the content, but it's not what I am looking for.
I have also tried with a flex container and flex-grow content but I had no luck.
How can achieve this? I am also looking for a way to improve and refactor my code, so I am open to any advice that you could give me.
Here is the snippet (this is CSS, not SCSS as my pen shows):
#import url(https://fonts.googleapis.com/css?family=Anonymous+Pro);
body {
background-color: #1a1a1a;
color: rgba(255, 255, 255, 0.75);
font-size: 16px;
font-family: 'Anonymous Pro', monospace; }
body .typewriter-text {
margin: 4rem auto 0 auto;
white-space: nowrap;
overflow: hidden;
border-right: 1px solid rgba(255, 255, 255, 0.75);
width: 0;
border-right: 1px solid rgba(255, 255, 255, 0.75); }
.line-1 {
animation: blink 1s step-end 7 backwards, type 2s 2s steps(30, end) forwards, blink 1s 3.6s step-end 7, remove-blink 1s 6.3s step-end forwards; }
.line-2 {
animation: remove-blink 0s 0s step-end forwards, type 3s 7.5s steps(40, end) forwards, remove-blink 0s 10.5s forwards; }
.line-3 {
animation: remove-blink 0s 0s step-end forwards, type 3s 10.5s steps(40, end) forwards, blink 1s 14s infinite alternate; }
#keyframes type {
0% {
width: 0;
border-right: 1px solid rgba(255, 255, 255, 0.75); }
100% {
width: 20rem;
border-right: 1px solid rgba(255, 255, 255, 0.75); } }
#keyframes blink {
50% {
border-color: transparent; } }
#keyframes remove-blink {
to {
border-color: transparent; } }
<div class="typewritter-wrapper">
<h1 class="typewriter-text line-1">Lorem Ipsum D</h1>
<p class="typewriter-text line-2">Lorem ipsum dolor sit amet, consectetur adipiscing
elit.</p>
<p class="typewriter-text line-3">Donec vitae est commodo, imperdiet nulla at.</p>
</div>
Thanks!
CSS doesn't have a method to calculate and adjust one element according to another, which would be needed here.
What one can do though, is to use transform, where one cover the text with a pseudo and then move the text element to the left and the pseudo to the right, revealing the text.
The downside, not being able to calculate width's, is that with wider content it will go faster and narrower slower, and the only reasonable way to solve that is to either calculate the text length server side and set the steps/duration using inline style, or client side using a script.
Note, in below sample I removed the "blinking" effect to simplify the code.
Stack snippet
#import url(https://fonts.googleapis.com/css?family=Anonymous+Pro);
body {
background-color: #1a1a1a;
color: rgba(255, 255, 255, 0.75);
font-size: 16px;
text-align: center;
font-family: 'Anonymous Pro', monospace;
}
.typewriter-wrapper {
overflow: hidden;
display: inline-block;
}
.typewriter-text {
display: none;
position: relative;
margin: 2rem auto;
white-space: nowrap;
overflow: hidden;
display: inline-block;
transform: translateX(50%);
padding: 0 2px;
}
.typewriter-text::after {
content: '';
position: absolute;
left: 2px;
top: 0;
right: 0;
bottom: 0;
background: #1a1a1a;
border-left: 1px solid white;
}
.line-1 {
animation: type 2s 0.5s steps(30, end) forwards;
}
.line-1::after {
animation: type2 2s 0.5s steps(30, end) forwards;
}
#keyframes type {
0% {
transform: translateX(50%);
}
100% {
transform: translateX(0);
}
}
#keyframes type2 {
0% {
transform: translateX(0);
}
100% {
transform: translateX(calc(100% - 1px));
}
}
<div class="typewriter-wrapper">
<h1 class="typewriter-text line-1">Lorem Ipsum Dolor</h1>
</div>
<hr>
<div class="typewriter-wrapper">
<p class="typewriter-text line-1">Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor</p>
</div>
Updated.
I also found a solution at CSS Tricks using width, cleverly combined with Flexbox, though the typing faster/slower for short/long text issue applies here too.
Stack snippet
#import url(https://fonts.googleapis.com/css?family=Anonymous+Pro);
body {
background-color: #1a1a1a;
color: rgba(255, 255, 255, 0.75);
font-size: 16px;
text-align: center;
font-family: 'Anonymous Pro', monospace;
}
.typewriter-wrapper {
display: flex;
justify-content: center;
}
.typewriter-text {
position: relative;
margin: 2rem auto;
white-space: nowrap;
overflow: hidden;
width: 0;
border-right: 1px solid white;
}
.line-1 {
animation: type 3s 0.5s steps(30, end) forwards,
blink .5s step-end infinite;
}
#keyframes type {
0% {
width: 0;
}
100% {
width: 100%;
}
}
#keyframes blink {
0%,
100% {
border-color: transparent
}
50% {
border-color: white
}
}
<div class="typewriter-wrapper">
<div>
<h1 class="typewriter-text line-1">Lorem Ipsum Dolor</h1>
</div>
</div>
<hr>
<div class="typewriter-wrapper">
<div>
<p class="typewriter-text line-1">Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor</p>
</div>
</div>
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I finally have this animation matching the proto my designer came up with, except one thing, the hover state flashes right before the animation plays. Check out my CodePen: http://codepen.io/sinrise/pen/rxvjyx/
<style type="text/css">
#keyframes bounceInUp {
from, 60%, 75%, to {
-webkit-animation-timing-function: cubic-bezier(0.8, 0.6, 0.5, 1.000);
animation-timing-function: cubic-bezier(0.8, 0.6, 0.5, 1.000);
}
from {
-webkit-transform: translate3d(0, 390px, 0);
transform: translate3d(0, 390px, 0);
}
60% {
-webkit-transform: translate3d(0, -5px, 0);
transform: translate3d(0, -5px, 0);
}
75% {
-webkit-transform: translate3d(0, 1px, 0);
transform: translate3d(0, 1px, 0);
}
to {
opacity: 1;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
.small-hero {
position: relative;
width: 100%;
max-height: 385px;
min-height: 385px;
overflow-y: hidden;
margin-bottom: 15px;
}
.small-hero::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(0,0,0,0.0), rgba(0,0,0,0.6));
content: "";
}
.small-hero h3, .small-hero p, .small-hero a {
position: absolute;
top: 0;
margin: 0 auto;
color: #fff;
z-index: 1;
text-align: center;
}
.small-hero img { width: 100%; }
.small-hero .small-hero-hover-bg {
position: absolute;
top: 390px;
left: 0;
width: 100%;
height: 100%;
background: rgba($tmi-orange, 0.8);
z-index: 2;
}
.small-hero .small-hero-hover-h3, .small-hero .small-hero-hover-p, .small-hero .small-hero-hover-a {
position: absolute;
top: 390px;
z-index: 2;
left: 0;
right: 0;
max-width: 500px;
text-shadow: 2px 2px 10px rgba(0,0,0,0.5);
}
.small-hero .small-hero-hover-a { max-width: 200px; }
.small-hero .small-hero-hover-p { font-size: 18px; }
.small-hero:hover .small-hero-hover-bg {
top: 0;
transition: top 0.4s, opacity 0.4s;
}
.small-hero:hover .small-hero-hover-h3, .small-hero:hover .small-hero-hover-p, .small-hero:hover .small-hero-hover-a {
animation: bounceInUp 0.5s 1;
}
.small-hero:hover .small-hero-hover-h3 {
top: 100px;
}
.small-hero:hover .small-hero-hover-p {
top: 150px;
animation-delay: 0.05s;
}
.small-hero:hover .small-hero-hover-a {
top: 250px;
animation-delay: 0.1s;
}
</style>
<div class="small-hero">
<img src="http://placehold.it/500x350" />
<div class="small-hero-hover-bg"></div>
<h3>Title</h3>
<h3 class="small-hero-hover-h3">Title</h3>
<p class="small-hero-hover-p">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elit nec nisl imperdiet efficitur. Ut ut mauris non sapien elementum tempor.</p>
Get a Quote
</div>
http://codepen.io/anon/pen/rxvjQW
Fixed with opacity:0; on .small-hero h3, .small-hero p, .small-hero a
and animation: bounceInUp 0.5s 1 forwards; on the hovers.
forwards makes it so that your element will stay at its last frame of the animation. opacity:0;makes it so that it starts, well, with 0 opacity.
Here's some documentation on animation-fill-mode.
I'm having trouble making a smoothly animated striped div, like a progress bar.
CSS:
.animationStripes{
width: 300px;
height: 50px;
background-image: repeating-linear-gradient(-45deg, rgb(0, 0, 0), rgb(0, 0, 0) 25px, blue 25px, blue 50px);
-webkit-animation:progress 2s linear infinite;
-moz-animation:progress 2s linear infinite;
-ms-animation:progress 2s linear infinite;
animation:progress 2s linear infinite;
}
#keyframes progress{
0% {
background-position: 0 0;
}
100% {
background-position: -70px 0px;
}
}
http://plnkr.co/edit/4wPv1ogKNMfJ6rQPhZdJ?p=preview
The problem is that there is a weird misalignment on the very right side of the background image gradient. How do i fix this misalignment?
Have you seen this tutorial on CSS Tricks?
#import url(https://fonts.googleapis.com/css?family=Ropa+Sans);
body {
padding: 20px;
font-family: 'Ropa Sans', sans-serif;
}
.product {
width: 376px;
padding: 15px;
position: relative;
float: left;
margin: 0 20px 0 0;
}
.product>img {
display: block;
position: relative;
}
.product:hover .product-hover,
.product:active .product-hover {
opacity: 1;
}
.product-hover {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
transition: opacity 0.3s ease;
background-size: 30px 30px;
background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
animation: barberpole 0.5s linear infinite;
}
#keyframes barberpole {
from {
background-position: 0 0;
}
to {
background-position: 60px 30px;
}
}
.product-info {
position: absolute;
bottom: 30px;
right: 30px;
background: white;
width: 150px;
padding: 10px 10px 50px 10px;
}
.subhead {
color: #f00;
text-transform: uppercase;
font-weight: bold;
}
.product-name {
color: #990033;
text-transform: uppercase;
font-weight: bold;
margin: 0;
letter-spacing: -1px;
}
.price {
position: absolute;
bottom: 10px;
right: 10px;
}
.amount {
color: red;
font-size: 150%;
}
.amount>span {
font-size: 75%;
}
h1 {
font-size: 72px;
margin: 2px 0 0 0;
}
VIEW SCSS CODE
<div class="product">
<div class="product-hover"></div> <img src="http://fillmurray.com/300/300" />
<div class="product-info">
<div class="subhead">Sale</div>
<h2 class="product-name">Fleece</h2>
<p class="product-description">Beat the chill and get cozy.</p>
<div class="price"> <span class="from">from</span> <span class="amount"> <span>$</span>9.90 </span>
</div>
</div>
</div>
Well I managed to fix it just by adding one thing and making no alterations to my original code. Simply adding background-size: 150% 100%; kept the image from clipping awkwardly on the right side.
http://plnkr.co/edit/4wPv1ogKNMfJ6rQPhZdJ?p=preview
Make the linear gradient with percentage values, not with pixel. apply background-size, in your case i'd say background-size:50px 50px; and in keyframes, move the background as much, as is the background size background-position: -50px 0px;
Also an example
http://plnkr.co/edit/HrSxkhYZaWp81fAQEaJn?p=preview
If the answer suits you, then mark it as answered and have a good day :)
I have an easy question for CSS guru that is ruining my weekend.
Basically I have a div with an image on the left and some text on the right.
I need that the box height is the same of the content text so for example in the image below the last line is outside the box while I need that the box is height like the content.
I cannot use fixed height due to the text can change inside the box, I need only a min-height already defined.
Some guru can help me?
<a href="#" class="myClass">
<div class="postImageUrl" style="overflow:hidden; z-index: 10; max-width: 100%;">
<div class="imgUrl" style="background-image:url(http://cdn8.openculture.com/wp-content/uploads/2015/03/17231820/Lorem-Ipsum.jpg);">
</div>
</div>
<div class="centered-text-area clearfix">
<div class="centered-text">
<div class="myClass-content">
<div class="ctaText" style="float:left;">
UpNeXt
</div>
<div style="clear:both;"></div>
<div class="postTitle" style="float:left;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat
</div>
</div>
</div>
</div>
</a>
And this is the <style>
.myClass
, .myClass .postImageUrl
, .myClass .imgUrl
, .myClass .centered-text-area {
min-height: 100px;
position: relative;
}
.myClass
, .myClass:hover
, .myClass:visited
, .myClass:active {
border:0!important;
}
.myClass {
display: block;
transition: background-color 250ms;
webkit-transition: background-color 250ms;
width: 100%;
opacity: 1;
transition: opacity 250ms;
webkit-transition: opacity 250ms;
background-color: #eaeaea;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
}
.myClass:active
, .myClass:hover {
opacity: 1;
transition: opacity 250ms;
webkit-transition: opacity 250ms;
background-color: #FFFFFF;
}
.myClass .postImageUrl
, .myClass .imgUrl {
background-position: center;
background-size: cover;
float: left;
margin: 0;
padding: 0;
}
.myClass .postImageUrl {
width: 30%;
}
.myClass .imgUrl {
width: 100%;
}
.myClass .centered-text-area {
float: right;
width: 70%;
}
.myClass .centered-text {
display: table;
min-height: 100px;
left: 0;
position: absolute;
top: 0;
}
.myClass .myClass-content {
display: table-cell;
margin: 0;
padding: 0 74px 0 18px;
position: relative;
vertical-align: middle;
width: 100%;
}
.myClass .ctaText {
border-bottom: 0 solid #fff;
color: #34495E;
font-size: 13px;
font-weight: bold;
letter-spacing: .125em;
margin: 0;
padding: 0;
text-decoration: underline;
}
.myClass .postTitle {
color: #000000;
font-size: 18px;
font-weight: 600;
margin: 0;
padding: 0;
}
.myClass .ctaButton {
background-color: #FFFFFF;
margin-left: 10px;
position: absolute;
right: 0;
top: 0;
}
.myClass:hover .imgUrl {
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-o-transform: scale(1.2);
-ms-transform: scale(1.2);
transform: scale(1.2);
}
.myClass .imgUrl {
-webkit-transition: -webkit-transform 0.4s ease-in-out;
-moz-transition: -moz-transform 0.4s ease-in-out;
-o-transition: -o-transform 0.4s ease-in-out;
-ms-transition: -ms-transform 0.4s ease-in-out;
transition: transform 0.4s ease-in-out;
}
You can find the problem here http://jsfiddle.net/L26s1vc5/
This is what I see now
While this is what I expect to have:
The min-height is 100px.
I already tested with height:100%, overflow-y:auto, height:auto without success :(
Thanks for your help, Alex.
You have two issues causing your problem. You have a clearing issue and an absolute positioning issue. Inside of .myClass you have two floated divs. That alone would cause the issue you are having. You've even attempted to fix it in two places. You added a class of clearfix in one place (which would only work if you had a css rule to match). You also have an empty div with an inline styling of clear: both;, though for that to work you would need to have it as the third div in your link.
Still, even if either of the above were working properly the issue wouldn't have been fixed. This is because of your absolute positioning on .centered-text. When you absolutely position something you take it out of the flow of your document. This means that it's parent has no idea the size of what's inside of it. All of your sizing was coming from your liberal use of min-height: 100px. If you remove the absolute positioning on .centered-text and use the clearfix properly then your code works just fine.
.myClass,
.myClass .postImageUrl,
.myClass .imgUrl,
.myClass .centered-text-area {
min-height: 100px;
position: relative;
}
.myClass,
.myClass:hover,
.myClass:visited,
.myClass:active {
border: 0!important;
}
.myClass {
display: block;
transition: background-color 250ms;
webkit-transition: background-color 250ms;
width: 100%;
opacity: 1;
transition: opacity 250ms;
webkit-transition: opacity 250ms;
background-color: #eaeaea;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
}
.myClass:active,
.myClass:hover {
opacity: 1;
transition: opacity 250ms;
webkit-transition: opacity 250ms;
background-color: #FFFFFF;
}
.myClass .postImageUrl,
.myClass .imgUrl {
background-position: center;
background-size: cover;
float: left;
margin: 0;
padding: 0;
}
.myClass .postImageUrl {
width: 30%;
}
.myClass .imgUrl {
width: 100%;
}
.myClass .centered-text-area {
float: right;
width: 70%;
}
.myClass .centered-text {
display: table;
min-height: 100px;
/* Removed absolute positioning*/
}
.myClass .myClass-content {
display: table-cell;
margin: 0;
padding: 0 74px 0 18px;
position: relative;
vertical-align: middle;
width: 100%;
}
.myClass .ctaText {
border-bottom: 0 solid #fff;
color: #34495E;
font-size: 13px;
font-weight: bold;
letter-spacing: .125em;
margin: 0;
padding: 0;
text-decoration: underline;
}
.myClass .postTitle {
color: #000000;
font-size: 18px;
font-weight: 600;
margin: 0;
padding: 0;
}
.myClass .ctaButton {
background-color: #FFFFFF;
margin-left: 10px;
position: absolute;
right: 0;
top: 0;
}
.myClass:hover .imgUrl {
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-o-transform: scale(1.2);
-ms-transform: scale(1.2);
transform: scale(1.2);
}
.myClass .imgUrl {
-webkit-transition: -webkit-transform 0.4s ease-in-out;
-moz-transition: -moz-transform 0.4s ease-in-out;
-o-transition: -o-transform 0.4s ease-in-out;
-ms-transition: -ms-transform 0.4s ease-in-out;
transition: transform 0.4s ease-in-out;
}
/* Added clearfix class here so that it can work properly*/
.clearfix:after {
content: "";
display: block;
clear: both;
}
<a href="#" class="myClass clearfix"><<!-- moved clearfix here so it can take effect for the necessary area -->>
<div class="postImageUrl" style="overflow:hidden; z-index: 10; max-width: 100%;">
<div class="imgUrl" style="background-image:url(http://cdn8.openculture.com/wp-content/uploads/2015/03/17231820/Lorem-Ipsum.jpg);">
</div>
</div>
<div class="centered-text-area">
<div class="centered-text">
<div class="myClass-content">
<div class="ctaText" style="float:left;">
UpNeXt
</div>
<div class="postTitle" style="float:left;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet
dolore magna aliquam erat volutpat
</div>
</div>
</div>
</div>
</a>
All I did remove said absolute positioning (it wasn't doing anything that I could tell), moved your clearfix to the proper place, removed your extra div (also a clearfix attempt) and added a clearfix class to the end of your css.
It looks like you've tried to do a lot of things to make this code work. You may want to go through and see what's doing what, a lot of it looks like it's not doing anything at all.
https://jsfiddle.net/dixalex/ojoevj1k/
The fiddle has the solution done via jQuery using the .height() call and JavaScript using the setInterval call. Every 50 milliseconds, the function will check to see if the image height is the same height as the container with the text. If they are not equal in pixel height, CSS is applied directly to make them equal.
Since this is dynamic, I did not have to change any of your CSS.
var makeSameHeight = setInterval( function() {
var currentTextHeight = $('div.myClass-content').height() + "px";
var imgDivHeight = $('div.imgUrl').height() + "px";
if (currentTextHeight === imgDivHeight)
{
var doNothing = "";
} else {
$('div.imgUrl, div.postImageUrl, a.myClass').css("height", currentTextHeight);
}
}, 50);
Only add overflow:hidden;
.myClass .myClass-content {
display: table-cell;
margin: 0;
padding: 0 74px 0 18px;
position: relative;
vertical-align: middle;
width: 100%;
overflow:hidden;
}
If isn't set height:XXpx; the container will fit to the content.