How to add scrollbars in iframe

2020-07-06 05:50发布

问题:

I want to add scrollbars in my iframe. Below is my code.

<iframe src="http://www.w3schools.com"  width="1349px" height="100%" scrolling="auto">

</iframe>

I am writing this in Drupal 7. Problem is it doesn't show iframe with scrollbars and border. Earlier I simply set the source without width and height and scrolling options and it showed iframe with scrollbars but after adding width and height,it disappeared.

Thanks

回答1:

scrolling="yes" and also frameborder aren't valid HTML5 attributes anymore. They can't be found in the list of allowed attributes, see: W3C: 4.7.6. The iframe element or MDN: <iframe>.

Use CSS instead:

iframe {
    overflow: scroll;
    width: 1349px;
    height: 100%;
    border: 1px solid black;
}

But actually all browsers show the scrollbars right away if needed.

Demo

Try before buy



回答2:

you were missing scrolling="yes" in your code try the following code

<iframe src="http://www.w3schools.com"  width="1349px" height="100%" scrolling="yes">
</iframe>


回答3:

Change the scrolling attribute to

scrolling="yes"


回答4:

Change scrolling="auto" to scrolling="yes" and add frameborder="1"

Try the style:

iframe {
   border: 1px solid #000 !important;
   overflow: scroll !important;
}


回答5:

This is not an issue with Firefox, ie, or edge.

The way i solved my particular issue is removing a class's overflow: auto and replacing it with the following on the parent of (in my current case) a table

class {
 overflow-y: scroll !important;
}


标签: html iframe