Utilize a YouTube video as a background within a wrapper that is not set to a full 100

I am trying to set a Youtube video as the background of a container block that is not 100vw. I have attempted using a different approach with the following code snippet: https://codepen.io/daiaiai/pen/ygeyLG

$color_1:rgb(25,29,184);
$color_7:rgb(241,90,111);

* {
  vertical-align:top;
  box-sizing:border-box;
  margin:0;
  padding:0;
  height:auto;
  border:0;
}

.sw_header{
    height:92vh;
    width:100vw;
    overflow-x: hidden;
}

.sw_header-links{
    width:40%;
    height:100%;
    display: inline-block;
    background: $color_1;
    overflow: hidden;
}

.sw_header-links-videowrapper{
    //position: relative;
    top: 0;
    left: 0;
    //width: 100%;
    width: 100%;
    height:100%;
    pointer-events: none;
}

.sw_header-links-videowrapper iframe{
    //position: relative;
  top: 0;
  left: 0;
  height: 320%;
  width:180%;
  //height: 200%;
}

.sw_header-rechts{
    display: inline-block;
    width:50%;
    height:100%;
    background:$color_7;
    padding:50px;
}

Here is the HTML code for the setup:

<header class="sw_header">
<div class="sw_header-links">
<div class="sw_header-links-videowrapper">
<iframe src="https://www.youtube.com/embed/W0LHTWG-UmQ?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&playlist=W0LHTWG-UmQ" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<div class="sw_header-rechts">
<h4>The other content <br/> The other contentblock</h4></div>
</header>

However, I am facing an issue where I cannot achieve 100% fit of the video to the container, similar to a background-size:cover; property. Can someone suggest which values should be used for the video to meet the following requirements: - 100% height of the container - Correct scaling of the width while maintaining proportions - Left top alignment without any black backgrounds - Proper cropping of the video's width based on device dimensions.

Thank you for your input!

Answer №1

Include the following code snippet in your stylesheet:

iframe{
    width: 100% !important;
    height: 100% !important;
}

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

Is there a way to modify the color of specific words within a sentence in HTML without causing them to wrap to the next line?

Can someone help me with changing the color of specific words within a sentence? I've experimented with various methods, but I'm struggling to find a suitable solution. ...

Extract HTML href links that correspond to a specific string from a given list of strings using Beautiful Soup

I am currently working on extracting specific URLs from a webpage that contains a list of various links. My goal is to only retrieve the URLs that match certain strings in a predetermined list. These strings are a subset of the text found within the links ...

What is the best way to determine the value of margin-left in inline CSS using jQuery?

Here is the code snippet I am working with: <div class="ongoing" style="width: +728px; margin-left: +12480px"> I need to extract the value of the margin-left property for scrolling purposes. The technique I used to retrieve the width value does no ...

"Enforce a specific height on a div that is exclusively showing a background

I have been trying to use a div element to showcase a specific color, where the background color acts as the content. However, no matter what height or width settings I input, I am unable to achieve the desired size for the div. Even after experimenting w ...

if the checkbox is selected, navigate to the displayed section

In my scenario, I have a total of 5 checkboxes and corresponding to each checkbox, there are 5 div elements. The functionality that I need is that when a checkbox is checked, the associated div should be displayed; otherwise, it should be hidden. The check ...

Creating a website layout with two evenly sized columns, one of which can be scrolled through

I am facing a challenge with my HTML table that has one row and two columns. I want the two columns to have equal height, but achieving this has proven difficult using floats or flexbox. Therefore, I turned to using a HTML-table. The content in the left c ...

Customize the color of Bootstrap active tabs to have a unique and distinct hue for each tab

I have successfully managed to change the color of both active and non-active tabs as a group, but I am wondering if it is possible for the color to remain the same when moving to the next tab. Here is what I've tried: http://jsfiddle.net/pThn6/2031/ ...

Adjusting the height of a div container containing unordered lists in real-time

Is it necessary to manually set the height of a div that contains an unordered list? In my current setup, main1 and main2 divs overlap if I don't specify the height. Are there alternative methods to prevent this overlapping without setting a fixed he ...

Make sure that the equal sign is never utilized at the beginning of a form input field

Seeking a method to prevent the use of the "=" character in any input field within a form. <form> <input name="email" type="email" placeholder="Email" required=""> <input name="last name" type="text" placeholder="Last Name"> ...

Divs gracefully appear one after the other in a sequential manner

I am attempting to showcase a sequence of 4 divs in a row using the ease-in CSS transition feature. I came across this example that demonstrates what I am aiming for: http://jsfiddle.net/57uGQ/enter code here. However, despite my best efforts, I am unable ...

Having trouble connecting local stylesheet on server?

Currently, I am developing an HTML-based game with Node.js, focusing on enhancing the front-end interface. While trying to include a CSS stylesheet, I encountered an unusual issue. The structure of my folders is organized as follows: C:\Users\m ...

Show the HTML content fetched from the database using PHP

After pulling html source code from a database and storing it in a PHP variable, I noticed that the content consists of table rows structured like this: <tr><td>10:00 AM</td><td class="success">Available</td></tr> < ...

Organizing pictures within bootstrap columns

Having an issue with CSS while using Bootstrap. I am attempting to align the columns in a way that the bottom line of the images inside each column match, not the top line. Despite trying everything I can think of, I have not been successful. Is there an ...

Having difficulty choosing the third option in the dropdown menu

I'm facing an issue with the dropdown menu in my header file that I include on every page of my website. The dropdown list works fine up to the 2nd element, but then it becomes unclickable. I've checked the code for the dropdown list, and it seem ...

Steps to create a basic search form in Flask with mysqldb

My attempt at creating a search form to extract ISBN, author, year and title data from my local MySQL database has been challenging. Despite researching various websites and tutorials, I have not found an ideal solution. Currently, here is what I have acco ...

Retrieve several values with a limit of 1 in SQL

Consider the following table structure: ID | ident | product 1 | cucu1 | 99867 | 2 | kkju7 | 88987 | 3 | sjdu4 | 66754 | 4 | kjhu6 | 76654 | 5 | cucu1 | 98876 | Running the query: SELECT ident,COUNT(*) FROM sales WHERE status=? AND team=? AND DATE(da ...

"Efficiently handle online submissions: Use Django to submit a form and instantly display the outcome

I have an urgent task to develop a web page where users can input data, and the backend will perform calculations and display the result below the input field on the same page (similar to checking online air ticket prices). I am new to Django and HTML. Be ...

Arranging labels and values in line with one another

I'm fairly new to HTML and CSS, so I'm finding it difficult to align all semicolons like in the screenshot provided. PSD Preview: This is my current HTML markup <ul> <li>Name <span>: John Doe</span></li> ...

I am encountering an issue with my SVG where the linear gradient fill is not correctly applying the second stop color, and I am struggling to determine the cause of this issue

I'm experiencing an issue with my SVG where a linear gradient defined in CSS is not displaying properly. Even though the second color stop rule is correctly set to orange, only the first color is showing up in the rendered image. I've been trying ...

The complete guide to effectively concealing double arrows within a Bootstrap 4 custom-select component

If you're looking to hide the double arrow on the right of the bootstrap 4 custom-select field, there have been solutions provided here. However, even after implementing those changes, the text on the right-hand side still gets obscured by the opaque ...