Hongmu Notes
Home Summary of pitfalls How to make the content within an iFrame framework expand both horizontally and vertically?
Summary of pitfalls

How to make the content within an iFrame framework expand both horizontally and vertically?

How to make the content within an iFrame framework expand both horizontally and vertically?

To make the content within an iframe expand in both height and width, use the following method:

  1. Set within the iframe tagscrolling="no"frameborder="0"Disables scroll bars and borders.
  2. Add an element after the `iframe` tag.<div>And provide this.<div>Set Styleposition: relative; width: 100%; height: 0; padding-bottom: 56.25%;.among,padding-bottomThe value should represent the aspect ratio of the content embedded within the iframe (for example, a video with an aspect ratio of 16:9 should be set topadding-bottom: 56.25%)。
  3. Use absolute positioning as mentioned above.<div>Place a child element inside and set its style to:position: absolute; top: 0; left: 0; width: 100%; height: 100%;

The complete code example is shown below:

<div style="position: relative; width: 100%; height: 0; padding-bottom: 56.25%;">
  <iframe src="https://example.com" frameborder="0" scrolling="no"></iframe>
  <div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>
</div>

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 202

Recommended reading

Responsive fitness and body sculpting corporate website template 0692

Responsive fitness and body sculpting corporate website template 0692 Practical Collection Yiyou template

An eyouCMS responsive website template designed for fitness and body shaping businesses. Its vibrant and healthy design effectively showcases fitness classes, body shaping programs, the coaching team, and the club environment. This template helps fitness institutions attract members online and enhance their brand awareness. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (E...
👁 44
css absolute positioning center

css absolute positioning center Language Notes CSS

There are numerous methods to achieve absolute positioning with centering in CSS; below, we will introduce four such techniques. 1. A widely compatible and mainstream approach for achieving absolute positioning with centering in CSS: `.container {width: 600px; height: 400px; position: absolute; left: 50%; top: 50%; margin:...`
👁 414
Locomotive collector generates relevant tags based on collection titles (aggregation pages are created in batches)

Locomotive collector generates relevant tags based on collection titles (aggregation pages are created in batches) Practical Collection High-speed rail collection

If you often make websites, you will definitely find that many programs have a tag field! This field can aggregate related articles to create an effect similar to a list page! When this plug-in is used properly, it is very friendly to website ranking or website optimization! Generate corresponding tags based on the title, and tags are separated by English commas. This means that you can publish it directly to your website without having to modify it again! Come and see the effect!
👁 301
(Adaptive Mobile Version) Green PBootCMS Industry Development Association Website Template – Download Government Association Website Source Code – 0388

(Adaptive Mobile Version) Green PBootCMS Industry Development Association Website Template – Download Government Association Website Source Code – 0388 Practical Collection pbootcms Template

An adaptive mobile-friendly website template for green industry development and association platforms (based on PbootCMS). The design features a professional yet natural aesthetic, making it ideal for industry associations and government industrial departments to showcase policies, events, and member services. It helps public institutions establish online platforms for information dissemination and communication. Template Overview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 45
(Adaptive Mobile Version) General Business Website Template – Download Corporate Official Website Source Code – 1115

(Adaptive Mobile Version) General Business Website Template – Download Corporate Official Website Source Code – 1115 Practical Collection pbootcms Template

A versatile PbootCMS website template designed for display-oriented businesses, compatible with both PC and WAP devices. Its minimalist, modern design makes it ideal for companies showcasing their products to quickly create a professional brand website. It is an ideal foundational solution for businesses looking to build their websites at low cost and with high efficiency. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles: PbootCMS...
👁 42
Treadmill Fitness Equipment Website Template 0693

Treadmill Fitness Equipment Website Template 0693 Practical Collection Yiyou template

This EyouCMS template is ideal for the treadmill and fitness equipment industry, featuring a vibrant and healthy design style perfect for showcasing fitness equipment products, treadmill ranges, workout plans, and brand imagery. It helps fitness equipment brands effectively present their products online and attract both gym members and home users. Template Preview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Common Questions About EyouCMS Installation...
👁 49