Creating a website with an iframe that adjusts to different screen sizes

Currently, my website features an iframe as the primary content with some graphs displayed in a sidebar. However, I am facing layout issues when the screen size is adjusted.

I have been struggling to ensure that the iframe fits properly within the website, especially since I am unable to specify a percentage value in the html.

Here is the HTML code:

.header {
  background-color: #fafafa;
  text-align: left;
  padding-left: 25px;
  padding-top: 15px;
}
.row {
    display: flex;
}
.column.side {
    flex-basis: 25%;
    background-color: #fafafa;
}
.column.middle {
    flex-basis: 75%;
}
.container {
  position: relative;
  padding-bottom: 50%;
  height: 0;
  overflow: hidden;
  max-width: 100%;
  background-color: #fafafa;
}
.container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
<div class="row">
  <div class="column middle">
    <div class="container">
      <iframe src="https://hestia.speckle.works/#/embed/li0TtsHb3F"
        frameborder="0"allowfullscreen>
      </iframe>
    </div>
  </div>

  <div class="column side">
    <div style="height: 500px">
      <h6>UNIT <span style="color: #3888db">BREAKDOWN</span></h6>
      <canvas id="chart1" height="250px"></canvas>
    </div>
  </div>
</div>

Answer №1

Hello @jamie, implementing media queries in your CSS can help make your website more responsive. Additionally, consider using the `scrolling="no"` attribute within iframes to enhance the user interface.

    <iframe src="https://hestia.speckle.works/#/embed/li0TtsHb3F"
      frameborder="0" scrolling="no" allowfullscreen>
    </iframe>

Answer №2

Do not need to use position: absolute; for iframe. The problem can be resolved by removing it.

.header {
  background-color: #fafafa;
  text-align: left;
  padding-left: 25px;
  padding-top: 15px;
}

.row {
  display: flex;
}

.column.side {
  flex-basis: 25%;
  background-color: #fafafa;
}

.column.middle {
  flex-basis: 75%;
}

.container {
  position: relative;
  overflow: hidden;
  max-width: 100%;
  background-color: #fafafa;
}

.container iframe {
  width: 100%;
  height: 100%;
}
<div class="row">
  <div class="column middle">
    <div class="container">
      <iframe src="https://hestia.speckle.works/#/embed/li0TtsHb3F" frameborder="0" allowfullscreen>
      </iframe>
    </div>
  </div>

  <div class="column side">
    <div style="height: 500px">
      <h6>UNIT <span style="color: #3888db">BREAKDOWN</span></h6>
      <canvas id="chart1" height="250px"></canvas>
    </div>
  </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

Is there a way to integrate Javascript code with a React component?

I need to find a way to include this block of code in just one specific React component. Any suggestions? <!-- Create a button that your customers click to complete their purchase. Customize the styling to suit your branding. --> <button sty ...

Utilizing external CSS to style an SVG file within an HTML document

Hello there, I have a collection of SVG files that I need to dynamically modify the fill color of, preferably using CSS. Here is the structure: <div> <svg width="100%" height="100%" viewbox="0 0 64 64" preserveAspectRatio="xMinYMin m ...

Tips for concealing a collapsible navbar menu upon clicking elsewhere (Bootstrap 5)

I am trying to create a collapsible navbar menu: <div class="collapse navbar-collapse" id="navbarCollapsible"> .. menu items .. </div> My goal is to hide the menu whenever a user clicks outside of it (not just when click ...

Review all the information in the Excel spreadsheet

I aim to extract data from the initial row, execute an operation on it, record the outcome, then proceed to the subsequent rows until all the data in the Excel file has been processed. Here are some queries I have: Why are the iterators not functioning ...

Execute the jQuery function to submit the form via AJAX once the validation process has been

I am currently working on a form and implementing the jQuery validate plugin for validation purposes. My aim is to trigger the ajax code to submit the form only after the validation process is successfully completed. How can I achieve the following: // T ...

Issue creating a JWT using jsonwebtoken module in Node.js

Could someone help me troubleshoot an issue I'm having while trying to generate a JWT token? The error message "TypeError: Right-hand side of 'instanceof' is not an object" keeps appearing even though the syntax seems correct. const jsonwebt ...

Can you identify the transport protocol that serves as the foundation for XmlHttpRequest?

I'm interested in finding out if it's SOAP, plain HTTP, or something different. I tried looking up XmlHttpRequest on Wikipedia but couldn't find any information about it there. ...

How to showcase a nested list using Angular 2

I need assistance with displaying a nested list structure. Here is an example of the list: [ { name: "Level 1A", children: [ { name: "Level 2A", children: [ ...

Determine in Node.js whether a variable is present in the request object for each page the user visits

Currently, my authentication system utilizes passportjs to define req.user when the user is logged in. As my website expands beyond its current 5 pages, I have been checking for the existence of req.user at the top of each route. Based on whether it exist ...

Unable to transmit props through components with Vue router

Hey there, I'm currently facing an issue with passing props from my vue router. It seems like nothing is being printed and when I checked in the mounted hook, it's returning undefined. However, strangely enough, when I use console.log(this.$route ...

Failing to draw an image on a blank canvas

I'm having trouble with my canvas. I want to clear it and then redraw it 30 pixels to the left on the x axis. However, when I try running the code, the canvas clears but the new image is not drawn. If I remove the "clearRect" function, the images are ...

What is the best way to line up a label and a textarea?

Here is how my code currently looks: XXXXX XXXXX Description: XXXXX My desired output is: XXXXX Description: XXXXX XXXXX Sometimes the "Description" field can span multiple lines. Code snippet: < ...

A Step-by-Step Guide to Successfully Clicking on a Checkbox Using Selenium and Python

Hello everyone, I'm facing an issue with clicking a checkbox. Here is the code for the checkbox: <label class="has-checkbox terms"><input name="order[terms]" type="hidden" value="0" /><input class="checkbox" type="checkbox" value=" ...

Is there a way to modify the video height so that it aligns with the dimensions of the

I'm currently trying to adjust the background video to fit the parent div, but I am facing issues with adjusting its height within the media query. Any suggestions on how I can resolve this problem? HTML <div class="hero"> <video ...

Responsive Tabs with Material-UI

Can MUI's Tabs be made responsive? This is what I currently have: https://i.stack.imgur.com/KF8eO.png And this is what I aim to accomplish: https://i.stack.imgur.com/b3QLc.png ...

Unlocking the power of Google Feed API to incorporate MIXED FORMAT in AngularJS

Currently, I am utilizing Google's Feed API in conjunction with AngularJS to retrieve my feed data in a mixed format of both JSON and XML. Although I have attempted to modify the method and callback tags to MIXED_FORMAT as per Google's documentat ...

How to Align Pictures in an Unordered List

I'm having trouble centering these images within the UL element. Despite researching solutions from other sources, I can't seem to apply them successfully in my specific case. Any assistance would be greatly appreciated. Thank you. JSFiddle: htt ...

Upon attempting to dynamically destructure my object in React, I encountered an unexpected token error

Currently, I am working on updating an input field using the onChange event in React. const handleUpdateText = (id, name, text) => { const newItems = items.map( item => { if (item.id === id) { return {...item, [menuLang][name]:text } // <- ...

How can you prevent horizontal tapping on a mobile screen when the content perfectly fits the display?

The shopping cart in Bootstrap 3 utilizes standard Bootstrap markup as shown below: <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <div class="container"> <div id ...

Using the data retrieved from getStaticProps to loop through an object and render it in the component

I'm encountering an issue with displaying the results of a database fetch that occurred within the getStaticProps function. When I try to map the object in my component template, I receive certain errors. My goal is to showcase all the data retrieved ...