Jump to content

Responsive Video Sizing

Recommended Posts

Site URL: https://www.thefabricant.com/

Hi,

I have a video on our home page as Code Injection atm. I would love to include a part in the code to make the video responsive to the size of the browser window. This is easy to do with the video block and Vimeo link, however I need to be able to do it with the Code Injection.

 

Below is the code I'm using now. 

<center>
<iframe src="https://player.vimeo.com/video/680815668??autoplay=1&loop=1&autopause=0&background=1&color=ffffff&controls=2&portrait=0" width="1170" height= "600"  frameborder="0" allow="autoplay; fullscreen"allowfullscreen></iframe>
</center>

 

Here's the embed code I'm getting from Vimeo

<div style="padding:50% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/680815668?h=b5fa6fda37&amp;badge=0&amp;autopause=0&amp;player_id=0&amp;app_id=58479" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen style="position:absolute;top:0;left:0;width:100%;height:100%;" title="The Fabricant - Digital Fashion House"></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>

 

What do I need to change in the original code to get the responsiveness in it?

AND bonus question. Can I add text on top of the video?

Link to comment
  • Replies 3
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

use this new code

<center>
  <h3> Add text here </h3>
<iframe src="https://player.vimeo.com/video/680815668??autoplay=1&loop=1&autopause=0&background=1&color=ffffff&controls=2&portrait=0" width="1170" height= "600"  frameborder="0" allow="autoplay; fullscreen"allowfullscreen></iframe>
</center>
<style>
  @media screen and (max-width:767px) {
  iframe[src*="vimeo"] {
    width: 100% !important;
    height: auto;
}
  }
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 4 months later...
20 hours ago, MikaylaNelson said:

Hello, This was very helpful to stop the bleed but now the height dimensions on my video for mobile are way too short. 

Is there a way to make both width and height responsive so the video stays proportionate?

You can change this line

Quote
 height: auto;

replace auto with px, eg: height: 250px;

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.