简体   繁体   English

如何修改iframe滚动?

[英]How to modify iframe scroll?

I'm trying remake ( http://dollarz.comli.com/testing/index2.html ) the design structure of https://www.seedlipdrinks.com/ . 我正在尝试翻新https://www.seedlipdrinks.com/的设计结构( http://dollarz.comli.com/testing/index2.html )。

So I created a page with an iframe. 因此,我创建了一个带有iframe的页面。 But I've a problem with iframe scroll, it's not similar to the design that I'm trying to match. 但是我对iframe滚动存在问题,它与我要匹配的设计不相似。

I've tried using scrolling="no" attribute, but it's totally disabling the scroll. 我试过使用scrolling =“ no”属性,但是它完全禁用了滚动。

I want the content inside iframe to be scrollable and the scroll bar should be hidden. 我希望iframe中的内容是可滚动的,并且滚动条应隐藏。 Is there any way to do that? 有什么办法吗?

The site you linked does not use an iframe or any sort of scrolling container. 您链接的网站不使用iframe或任何类型的滚动容器。 It essentially has an opaque & fixed header & footer + margins for the main content. 它的主要内容基本上具有不透明且固定的页眉和页脚+页边距。 This is what make the site look contained in a rectangle, while preserving the ability to scroll using the window scroll bar. 这就是使网站看起来包含在矩形中的原因,同时保留了使用窗口滚动条滚动的功能。 Here's how you can replicate the effect: 复制效果的方法如下:

body {
  background-color: white;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background-color: white;
}

section {
  padding: 50px 0; /* So the header/footer doesn't overlap the content */
  background-color: #7fff7f;
  margin: 0 50px;
}

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  background-color: white;
}

Demo here 在这里演示

You can use a wrapper div around your iframe with style of overflow: hidden , and set your iframe width a little more than that div. 您可以在iframe周围使用包装样式div,其样式为overflow: hidden样式overflow: hidden ,并将iframe的宽度设置为比该div大一些。

HTML : HTML:

<div style="overflow: hidden">
    <iframe src='http://dollarz.comli.com/testing/index.html'></iframe>
</div>

CSS: CSS:

iframe {
    width: 103%;
    height: 100%;
}

JSFiddle 的jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM