Home Web Front-end HTML Tutorial Teach you how to create scroll bar styles in iframe tags, and introduce the usage of iframe tags

Teach you how to create scroll bar styles in iframe tags, and introduce the usage of iframe tags

Aug 28, 2018 pm 04:57 PM
html iframe

This article mainly talks about the scrolling issues in HTML iframe tags. This article writes about the removal and preservation of the scroll bars of iframe tags and solving the problems of double scroll bars after the iframe with dynamic height is loaded. , let us read the article now

First let us take a look at the removal and preservation of scroll bars in the HTML iframe tag:

After the iframe is embedded in the page, we Sometimes it is necessary to adjust the scroll bars, for example, remove all scroll bars, remove the right scroll bar and keep the bottom scroll bar, remove the bottom scroll bar and keep the right scroll bar. So what should we do?

1: Remove all scroll bars

The first method: iframe has a scrolling attribute, which has three values: auto, yes, and no.

scrolling : auto -----The scroll bar appears when needed

scrolling : yes ------Always display the scroll bar

scrolling : no - ------Always hide scroll bars

When scrolling: no is set, all scroll bars will be gone.

Second method: I found that in addition to scrolling to remove all scroll bars, there is another method, setting body{overflow:hidden} in the embedded page, so that the scroll bars can also be removed. And this is also the property used when we only want to remove a certain scroll bar.

Two: Remove the right scroll bar and keep the bottom scroll bar

If you only want to keep the bottom scroll bar, you can set the body{ in the embedded page overflow-x: auto; overflow-y: hidden;}

Three: Remove the bottom scroll bar and keep the right scroll bar

Set in the embedded page body{overflow-x: hidden; overflow-y: auto;}

We already know that these two properties can set the display and hiding of the scroll bar, so when both are set at the same time, which one will appear? What's the effect?

Through detection, I found that when scrolling="auto" or "yes", if the body is set, the settings in the body will be used; when scrolling="no", no matter what is set in the body , the scrolling setting will be used, that is, all scroll bars will be removed.

Next let’s talk about how to remove the horizontal scroll bar:

It can be removed by the following method: In the web page contained in the iframe Add

<style>
html { overflow-x:hidden; }
</style>
Copy after login

to remove the horizontal scroll bar, and you can also use the same method to remove the vertical scroll bar.

Solve the problem of double scroll bars after loading an iframe with dynamic height:

If the iframe data is loaded asynchronously through ajax, the height of the div inside is also dynamically obtained. There is a problem here. When the content in the div is not loaded, the above var height can only obtain the unexpanded height. After loading ajax, the actual height still cannot be obtained. Here, you need to wait until all document trees are loaded before loading. How to get the actual height

Ultimate version, written on the iframe page

var ht = setInterval(&#39;getHeight&#39;,100);
function getHeight(){
    if(document.readyState == &#39;complete&#39;){
        var height = (document.body.scrollHeight)+&#39;px&#39;;
        $(&#39;parentdiv&#39;,window.parent.document).css(&#39;height&#39;,height);
        window.clearInterval(gh);
    }
}
Copy after login

There may be a simpler solution, but this is the idea and code that I encountered and solved step by step. It is worth it Record it. Of course, the scrolling attribute can also be used. You can study it. If you have any simple methods, we can discuss it together. Welcome to leave a message below

[Editor’s recommendation]

How to write a relative path for the base tag in HTML? (Introduction to use included)

What is the usage of the src attribute of the HTML img tag? Analysis of specific usage methods (examples attached)

The above is the detailed content of Teach you how to create scroll bar styles in iframe tags, and introduce the usage of iframe tags. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles