Incorporate Vimeo video with full-width display

When embedding a Vimeo video on my website, I use the following code:

<div class="fys-fp-content-wrapper">
<div id="fys-fp-video">
</div>
</div>

#fys-fp-video {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 600px;
}
#fys-fp-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 600px;
}

The Vimeo iFrame is inserted into #fys-fp-video.

Despite the original width of the video being only 640px, I want it to always be displayed at 100% width, ensuring that it covers the entire width while maintaining the 600px height. Any suggestions on how to achieve this look?

Appreciate any help!

Answer №1

Implementing a responsive video using Bootstrap is quite simple. Here's how:

<!-- Achieving a 16:9 aspect ratio -->
<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item" src="..."></iframe>
</div>

For more information on this feature in Bootstrap 4, visit https://getbootstrap.com/docs/4.0/utilities/embed/.

To update to Bootstrap 5 and utilize the new helper classes for aspect ratios, check out the guide at: https://getbootstrap.com/docs/5.0/helpers/ratio/#example

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />

<div class="embed-responsive embed-responsive-16by9">
  <iframe lass="embed-responsive-item" src="https://player.vimeo.com/video/54596361" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
</div>

Answer №2

In my opinion, the solution to your problem lies in using vw (viewport width). When you set width:100%, it means 100% width of the parent element. On the other hand, width:100vw signifies 100% of the screen width. I recommend implementing the following code:

#fys-fp-video {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 600px;
}
#fys-fp-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 600px;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Storing User Information in Cookies using jQuery

My current jQuery script is linked to a button and it functions by toggling font styles on a website by enabling or disabling a stylesheet upon clicking the button. Now, I want to enhance this functionality by saving user preference to a cookie so that the ...

Adjust the navigation height to be proportional to the main content size

I've been attempting to make my navigation menu take up the entire page, but I have yet to achieve success: My goal is for the green menu section to extend down to the footer. Here is the HTML code: <div ...

Creating a Form in a Popup with Bootstrap

I have implemented Bootstrap on my website. Check it out at: hubb.tekkkz.com I am facing an issue where, when clicking on the login/register button on the right, the modal pops up. However, the user input elements within the modal are not taking up the ful ...

Effortlessly switch between CSS animation styles while adjusting animation settings

My HTML element with animation is defined as follows: <div id="box"></div> The box starts by moving 200 pixels to the right, taking 4 seconds to complete. .anim { animation-name: anim; animation-duration: 4s; animation-t ...

Guide to customizing the CSS styles of various components within a Material UI Dialog

Let's take a look at this snippet for creating a Material Dialog in code: <Dialog open={this.props.open} onClose={this.props.closeAtParent} PaperProps={{ style: { minHeight: '75vh', minWidth: '75vw', ...

Update the form field with today's date in a JHipster application

In our current project in JHipster, we are facing a challenge with setting the default value of a form field as the current date. JHipster offers a moment format for dates, which is essentially an ngbdatepicker. However, when attempting to change the inpu ...

Expanding the width of the textfield is not possible in CSS styling

My current search bar design features an input area that does not match my expectations. The input length is restricted and starts from the center rather than the black border I had envisioned. If you'd like to see the code and design in action, chec ...

Change the content of a selectbox dynamically with the help of jQuery and AJAX

Currently, I am exploring the best approach for a specific challenge: I have various categories, subcategories, sub-subcategories, and so on, that I need to display in separate select boxes. For instance, initially, the options may look like this: <sel ...

Prevent Overflow with Hidden Setting, Use Cover for Background Image, and Optimize for Anchors and

I'm currently working on a page that is designed not to scroll vertically. If you'd like to see the page with the issue I'm encountering for reference, you can visit Everything has been running smoothly except for two specific issues: W ...

Utilizing CSS to Select Specific Sections

I'm curious about how to target a section element with a specific id like #dress in CSS3. Here is my code snippet: <section id="dress"> <p>Lorem Ipsum..................................of Lorem Ipsum.<> </section> Here's ...

SQL - Extracting Information from HTML in a Column

I have a column named "Content". Within this column, there is HTML code containing various data. My task is to extract specific information from this HTML code and split it into five different columns: "Name", "Surname", "Email", "Telephone", and "Message" ...

Python makes sure that HTML values remain constant even after a button is clicked by Selenium

I am currently utilizing Soup and Selenium to access a particular page . My objective is to extract a comprehensive list of pricing and ratings for different types of packaging available on this webpage. Displayed below is the code I have composed: impor ...

Having trouble deciphering mathematical formulas while editing content on ckeditor

While using math formulas in CKEditor, I noticed that when I insert new content via textarea, the formulas are displayed correctly. However, when I go back to edit the content, the text formulas do not display as before. This is the source code I am using ...

Generate a dynamic animation by combining two images using jQuery

My attempt to animate two images is not working. I received some help on Stack Overflow but still facing issues with my CSS and HTML code. This is the code I am using: $(document).ready(function() { $(".animar").click(function() { $("#img4" ...

How can I effectively retrieve the JWT in a node environment?

I've successfully set up JWT authentication using Node.js. After the user signs in, Node.js generates a JWT and sends it back to be stored in the localStorage. However, I've encountered an issue when trying to access this token within the express ...

What is the best way to import my json information into an HTML table and customize the rows as radio buttons using only Javascript?

I am facing an issue with processing a JSON response: var jsondata = dojo.fromJson(response); There is also a string that I am working with: var jsonString = jsondata.items; The variable jsonString represents the JSON data in the file: jsonString="[ ...

What is the best way to align two items where one is centered and the other is positioned to the left?

In an attempt to customize a chat call to action, I am looking to have an icon aligned to the left and some centered text. Here is an example of how I envision it: [ @ Text aligned in center ] Here is what I have tried so far: .icon{ justify-self: ...

Is it advisable to consolidate all of my JavaScript files into a single file?

Is it necessary for me to combine all my JavaScript files into one single file and then include that file in a folder? I currently have 10 separate JS files within a "javascript" folder - is this bad for the website, or is it okay? P.S. I am new to web de ...

Placing a gradient background in front of two divs

I have created two divs with gradients: .container_middle_page{ margin: auto; height: 100%; display: flex; flex-direction: column; } .container_middle_page_up{ background-image: linear-gradient(to top, #F28118,white); height: ...

React does not support having two :focus selectors on a single JSX element

I'm working with a React script that includes a specific element. I want to apply more than one :focus-within selector in CSS, but for some reason only the dropdown selector is being expressed when I focus on the element. Here's the code: React J ...