Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>


 
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1000" height="700" xml:space="preserve"  id="ken-burns-plus" >
    <filter id="blur">
        <feGaussianBlur stdDeviation="0" />
    </filter>
  <style type="text/css">
    .front{
      animation: parallax-front 45s infinite ease-in-out;
      filter:url(#blur);
    }
    .mid{
      animation: parallax-mid 45s infinite ease-in-out;
    }
    .back{
      filter:url(#blur); 
    }
.front, .mid, .back{
      transform-origin: 50% 50%;
}
    
  
    @keyframes parallax-front { 
        0%,5%,95%,100%  {transform: scale(1);} 
        54%, 55% {transform: scale(1.45);} 
        } 

    
    
   @keyframes parallax-mid { 
        0%,5%,95%,100%  {transform: scale(1);} 
        54%, 55%  {transform: scale(1.2);} 
        
      }  


  </style>
    
 <g>   
  
   <!--<image class="back" xlink:href="https://i.ibb.co/yFTDtXQ/wilson-b-back.png " x="0" y="0" width="100%" height="100%"  /> Unblurred BG image -->
  <image class="back" xlink:href="https://images4.imagebam.com/74/85/25/MEK405J_o.jpeg" x="0" y="0" width="100%" height="100%"  />
  <image class="mid"  xlink:href="https://i.ibb.co/8gv3FVf/wilson-b-mid.png" x="0" y="0" width="100%" height="100%" />
  <image  class="front" xlink:href="https://i.ibb.co/b2fRNgm/wilson-b-front.png" x="0" y="0" width="100%" height="100%" />
  </g>
</svg>
 
  
  
  <h1 class="title">
    Woodrow Wilson Opens 1913 Season
  </h1>
  
</header>

<h2>Ken Burns Photo effect in SVG</h2>
<p>This effect it suited to a hero image on a news or history content site. Requires some manual setup with three layer separations but the animation can be quite standardized. </p>

<h4>Issues to consider:</h4>
<ul>
  <li>A standard 'Ken Burns effect' simply pans between (usually) two zoomed-in focal points within an image. This demo is a more complex  but less common 'layered parallax' Ken Burns effect that draws the user into a faux 3d experience of the 2d reference photo.</li>
  <li>There are three layers that need to be separated from the original reference photo. Naturally, this requires us to clone in new image behind the animated layers. This takes time and I don't think there's any shortcut around this.</li>
  <li>Perhaps SMIL will be more efficient than CSS?</li>
  <li>Using &lt;feGaussianBlur&gt; filter on the back layer adds controllable (even animatable) depth, but it does hurt CPU performance a little. It's probably best to manually PhotoShop blur the background layer and then JPG it.</li>
  <li>This version is an inline SVG linking to 3 externally hosted images via SVG's &lt;image&gt; tag. Would these images be blocked by XSS reasons in the real-world? Probably. XSS rules would definitely block the images if you made this into a standalone &lt;SVG&gt; file placed as an &lt;img&gt;. Embed the entire images inside the SVG to avoid these issues.</li>
  <li>In alternate demos I've embedded the images layers as raw inline PNG data is an SVG SYMBOL, and then manipulated that. This renders fine – I THINK even when placed as a IMG in HTML. But the lack of compression on the PNG code makes the final SVG file fat, slow, and unweildy to manage. I'd love a better solution.</li>
  <li> If you are inlining the image data, compress the image data as much as is practical. Smaller files animate more smoothly and are much easier to work with in your IDE. The back layer can even be a JPG as it doesn't need transparency. </li>
  <li> I prefer to use BoxySVG to import, position and inline the images to an SVG, before hand-coding the animations in VS Code. </li>
  <li>Two layers might be enough to make this effect work nicely. However, there was just such an obvious foreground element in this example.</li>
</ul> 

  

  
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;500&display=swap');

body{
  font-family: 'Montserrat', sans-serif;
  background: #efecee;
}

header {
  height: 450px;
  border: 6px #000 solid;
  overflow: hidden;
  position: relative;
  background:#222;
  svg {
    margin: -5% 0%;
    position: absolute;
  }
  h1{
    position: absolute; 
    bottom: 0 ;
    right: 2rem;
    font-family: 'Montserrat', sans-serif;
    color: #cccc22;
    width: 40%;
    text-shadow: 3px 3px 3px #000;
    text-align: right;
    font-size: 3rem
  }
}
p{font-weight: 300}
              
            
!

JS

              
                
              
            
!
999px

Console