What is the best way to bridge the distance between a shrunken iframe and the following element?

https://i.sstatic.net/AZ7T4.png

My iframe was resized to 65%, but the containing "div" still occupies the original iframe size, creating a large gap between the iframe and the next element. I'm not sure how to remove this gap. I want the next element to be directly below the embedded iframe. Here is the HTML code:

@media only screen and (min-width:768px){
  .container-iframe{
    -moz-transform: scale(0.65, 0.65); 
    -webkit-transform: scale(0.65, 0.65); 
    -o-transform: scale(0.65, 0.65);
    -ms-transform: scale(0.65, 0.65);
    transform: scale(0.65, 0.65); 
    -moz-transform-origin: center;
    -webkit-transform-origin: center;
    -o-transform-origin: center;
    -ms-transform-origin: center;
    transform-origin: center;
  }
  .iframe-responsive{
    bottom: 0;
    float: center;
    height: 100%;
    left: 0;
    position:absolute;
    right: 0;
    top: 0;
    width: 100%;
  }
}
<div class="container-iframe">
    <iframe class="iframe-responsive" src="https://www.youtube.com/embed/chw2oMUrh4U"></iframe>
</div>  
<div class="row">
  <div class="col" style="text-align: center;">
    <h1>Something 1</h1> 
  </div>
</div>
<div class="row">
  <div class="col" style="text-align: center;">
    <h1>Something 2</h1>
  </div>
</div>

Answer №1

Adding a fixed height to your .container-iframe will solve the issue. The current problem is that the container lacks a height, causing the iframe to have no reference for the 100% height you assigned to it.

@media only screen and (min-width:768px){
  .container-iframe{
    -moz-transform: scale(0.65, 0.65); 
    -webkit-transform: scale(0.65, 0.65); 
    -o-transform: scale(0.65, 0.65);
    -ms-transform: scale(0.65, 0.65);
    transform: scale(0.65, 0.65); 
    -moz-transform-origin: center;
    -webkit-transform-origin: centeer;
    -o-transform-origin: center;
    -ms-transform-origin: center;
    transform-origin: center;
    height: 150px;
  }
  .iframe-responsive{
    bottom: 0;
    float: center;
    height: 100%;
    left: 0;
    position:absolute;
    right: 0;
    top: 0;
    width: 100%;
  }
}
<div class="container-iframe">
    <iframe class="iframe-responsive" src="https://www.youtube.com/embed/chw2oMUrh4U"></iframe>
</div>  
<div class="row">
  <div class="col" style="text-align: center;">
    <h1>Something 1</h1> 
  </div>
</div>
<div class="row">
  <div class="col" style="text-align: center;">
    <h1>Something 2</h1>
  </div>
</div>

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

Using JavaScript to generate a <style> element and accessing the cssRules

After spending countless hours trying to solve this problem, I'm hoping that my question isn't too foolish. This is a continuation of a previous question about creating a style tag with JavaScript on Stack Overflow. The solutions provided by Tom ...

What is the best way to center a grid item in Material-UI within a React application?

I'm struggling with centering a grid element in MUI v5 and aligning a long paragraph to the left side while adding horizontal margin for big screens. Can anyone help me out with this? Thank you. <Box style={{ backgroundColor:" ...

How to Filter Fields in AngularJS Based on a Start Date and End Date?

Hey everyone, I'm trying to filter items based on the start and end dates using the daterange functionality in my meanjs app. I've tried multiple approaches but haven't found a solution yet. If anyone knows how to do this, please help me out ...

The concept of CSS background-position

Hey there, I have a query regarding a sprite image that contains icons with both normal and hover effects. Here is the current CSS code I am using: .wi{ background-image:url(images/icons/small/wi.png); background-repeat:no-repeat; display:blo ...

Generating a div element within another div element

I have been attempting to add a new div inside an existing one using append, after, etc., but so far I have not been successful. The structure of the code is as follows: <div class="row"> <div class="col-xs-12" id="element-container"> &l ...

Adding multiple styles using ngStyle is currently not possible

When using ngStyle to add height and width styles to an img element, I encountered a strange issue: <img class="image-full-view" [ngStyle]="{'height': selectedImage.heightSize, 'width': selectedImage.widthSize}" [src]="selectedImage ...

Blazor Shared CSS File

Currently, I have successfully implemented 2 pages in my Blazor app: Login.razor located in the Auth folder AddPerson.razor situated in the Profile directory At this point, I have managed to integrate a CSS file specifically for the AddPerson.razor page ...

Providing data from a javascript xml file upon page initialization

I am aiming to extract multiple values from an XML file as soon as an HTML page is loaded. The XML file remains constant and will not change over time. It will be stored in the same directory as the HTML page. The purpose of this XML file is to fill severa ...

Retrieve a value for a textbox by comparing the values of two separate combo boxes

Hey there, I'm brand new to javascript and could really use some assistance. I've got a form with two combo boxes, one for Pass Type and the other for Duration. I'm trying to set a value in a text box based on the user's selections f ...

Retrieving script data from a webpage

I found a link that I want to extract content from, here is the link: https://www.whatever.com/getDescModuleAjax.htm?productId=32663684002&t=1478698394335 However, when I try to open it using Selenium, it doesn't work. It opens as plain text wit ...

Is there a potential white-space issue with jQuery CSS in Internet Explorer versions 7 and 8

Recently, we encountered an unusual issue with jQuery and CSS while working on compatibility with IE7 and IE8. Our project involves animations and height measurements, and during the animations, we wanted to prevent text from wrapping. To achieve this, we ...

Error encountered when trying to load Ajax script

As a beginner in the learning process, my code may appear messy. I am currently wrapping up my second project, which is a photo viewer. On the main page, there is a navigation system that loads different sections of the website using ajax. Since this proje ...

Implementing interactive dropdown menus to trigger specific actions

I have modified some code I found in a tutorial on creating hoverable dropdowns from W3. Instead of the default behavior where clicking on a link takes you to another page, I want to pass a value to a function when a user clicks. Below is a snippet of the ...

Use this jQuery-animated menu to make hyperlinks hover with style!

Currently immersed in my exam project, I have integrated an animated jQuery navigation. I am aiming to set the text color to white when hovering over both the link itself and the menu icon that appears upon hovering over the <li> elements. Despite ...

Arranging Bootstrap Cards in an Orderly Stack

I recently created a set of bootstrap cards displayed like this: <div class="card-deck"> <div class="card"> <img class="card-img-top" src=".." alt="Card image cap"> <div class="card-body"> <h5 cl ...

Centering DIVs both vertically and horizontally within parent DIVs that have a height and width of 100%

I am facing a challenge with my nested parent DIVs that occupy 100% of the browser window in terms of height and width. I am struggling to center secondary DIVs inside their respective parent containers. Here are the definitions for my stacked parents: # ...

utilizing ng-option to present choices in a dropdown menu

I have been implementing a scroll-down menu in my application using options. However, I now want to switch to using ng-option to populate the values from a JavaScript file. I also require assistance with writing AngularJS code for this task. Below is a s ...

The width property is ineffective when used in conjunction with the d3 styling method

My goal is to create bar graphs where the width of each bar represents a person's age. However, I am having trouble applying the width attribute to the bars using the style method in d3 (I checked this by inspecting the elements in the browser). Other ...

How to show a button within a table cell using AngularJS?

The AngularJS application developed by my company was recently handed over to me for further development. Currently, I am working on integrating a navigation button in a table cell that will allow users to navigate to custom pages of their choice. Within ...

How to transfer a java list to an html template

I have extracted some information from an HTML file that relies on input from a Map structure as demonstrated below Template t = TemplateLoader.load("Printing/account.html"); Map<String, Object> map = new HashMap<String, Object>(); map.put("a ...