css - Text appear from left to right -
i want caption of image (which not necessary real caption) appear when image hovered. text should appear left right it's container should grow on x axis image hovered. have been able make text appear on hover transition effect stuck.
have tried:
css:
.morbid { display: none; margin-left:10px; } a:hover + .morbid { position:relative; display: block; }
html:
<a> <img src='.../goals/sia.png'> </a> <div class="morbid"> text appear hover mouse on image. </div>
actually whole div
must grow, text remaining static , want text hidden unless image hovered.
you cannot transition display
property's change of value. full list of properties can animated available in spec.
for content grow , appear need transition max-width
(or width
, if can set fixed width element) done in below snippet.
.morbid { width: auto; max-width: 0%; white-space: nowrap; overflow: hidden; transition: max-width 1s linear; } a:hover + .morbid { max-width: 100%; }
<a href="#"> <img src='http://lorempixel.com/400/200'> </a> <div class="morbid"> text appear hover mouse on image. </div>
alternately, if want text grow center can make use of absolute positioning transform
in below snippet.
.container { position: relative; width: 400px; } .morbid { position: absolute; left: 50%; max-width: 0%; white-space: nowrap; overflow: hidden; transform: translatex(-50%); transition: max-width 1s linear; } a:hover + .morbid { max-width: 100%; }
<div class="container"> <a href="#"> <img src='http://lorempixel.com/400/200'> </a> <div class="morbid"> text appear hover mouse on image. </div> </div>
Comments
Post a Comment