<% @page_title = "Flex Video" %>

<%= @page_title %>

If you're embedding a video from YouTube, Vimeo, or another site that uses iframe, embed or object elements, you can wrap your video in div.flex-video to create an intrinsic ratio that will properly scale your video on any device.

4:3 is the default size for the .flex-video element, and the assumption for .flex-video for chrome (controls) height is based on YouTube.

Because Vimeo places their chrome on the player itself, adding a class of .vimeo creates a container that is sized for the video only — no extra padding for the controls.


Build With Predefined HTML Classes

There are two ways to build flex-video containers in Foundation 4: with our predefined HTML classes or with our mixins. Building flex-video containers using our classes is simple, you'll just need to create a <div class="flex-video"> and apply the classes you want to style it appropriately.

The available class options:

  • widescreen: Will give the player a widescreen aspect ratio.
  • vimeo: This will ensure that we don't add extra padding since Vimeo has controls within the player, itself.
<%= code_example '
', :html %>

For these styles to come across, make sure you have the default Foundation CSS package or that you've selected flex-video from a custom package. These should be linked up following our default HTML page structure.


Build with our Mixins

We've included SCSS mixins used to style labels. To use the mixin, you'll need to have the extension installed or grab _foundation-global.scss and _flex-video.scss from Github and throw them into a Foundation folder in your project directory. From there, you can import the files at the top of your own SCSS stylesheet, like so:

<%= code_example ' @import "foundation/foundation-global", "foundation/flex-video"; ', :css %>

The markup is just like we showed you above, but you can apply the mixin to your own custom class or ID.

<%= code_example '
', :html %>
Quick Mixin

You can build your flex-video containers using our global mixin by including it on your custom class or ID in your own stylesheet. The defaults can be modified using the available variables. The global mixin looks like this:

<%= code_example ' /* Using the default styles */ .your-class-name { @include flex-video; }', :css %>
Default SCSS Variables
<%= code_example ' /* We use these to control video container padding and margins */ $flex-video-padding-top: emCalc(25px); $flex-video-padding-bottom: 67.5%; $flex-video-margin-bottom: emCalc(16px); /* We use this to control widescreen bottom padding */ $flex-video-widescreen-padding-bottom: 57.25%; ', :css %>

Note: emCalc(); is a function we wrote to convert px to em. It is included in _foundation-global.scss.

<%= render "_sidebar-components.html.erb" %>