简体   繁体   English

使DIV不在容器的外部显示

[英]Make a DIV not be shown outside it's container

I'm making a very basic animation with JQuery. 我正在使用JQuery制作非常基本的动画。 Basically what I have is a DIV in the size of 60% width, 80% height and it contains a manual. 基本上,我所拥有的是DIV,宽度为60%,高度为80%,其中包含手册。 My goal is that when you go through pages in the manual, the current page moves up and disappears and the next page comes up from the bottom. 我的目标是,当您浏览手册中的页面时,当前页面将向上移动并消失,而下一页将从底部开始。

I'm close enough, but something's just wrong and I can't get an idea on how to fix it - The page DIVs are visible outside their container. 我已经足够接近了,但是出了点问题,而且我不知道如何解决它- 页面DIV在容器外部可见。 Their top property is set to 110% yet I can see it doesn't take effect. 他们的top属性设置为110%,但我看不到它没有生效。 Their position is only affected by the menu table above them. 它们的位置仅受其上方菜单表的影响。

So my problem, really is - how do I make a DIV invisible outside it's container, but without changing the visibillity or display of the whole DIV, so the text will be seen when moving up - but only the text that lays on the container and isn't outside it. 因此,我的问题确实是- 如何在容器的外部使DIV不可见,而又不改变整个DIV的可见性或显示方式,因此在向上移动时将看到文本-但只有位于容器上的文本和不在外面。

    .manualPage {
    color:rgba(241, 241, 241,1.0);
    top:110%;
    text-align:left;
    left:0%;
    cursor:default;
    z-index:30;
    font-family: "Open Sans", sans-serif;
    font-size:11pt;
    width:100%;
    height:100%;
}

.BigWindow {
    position:absolute;
    width:60%;
    height:80%;
    top:10%;
    display:inline-block;

    left:-70%;

    background-repeat:repeat;

    color:rgba(241, 241, 241,1.0);

    font-family: "Open Sans", sans-serif;
    font-size:12pt;

    text-align:center;

    cursor:default;

    z-index:30;
}

notice that BigWindow is the container, manualPage is a page. 请注意,BigWindow是容器,manualPage是页面。

Here's the function, but I think the CSS problem is the one to be solved first: 这是函数,但是我认为CSS问题是首先要解决的问题:

var currentPage = -1;

function setManualPage(num) {
    if ($('#manualMenu').css('display') != 'none')
        $('#manualMenu').fadeOut(750);
    if (currentPage != -1) {
        $('#page' + currentPage).animate({ top: '-100%' }, screen.availHeight / 2, function () { $('#page' + currentPage).css('top', '110%'); });
    }

    if (num != -1)
        $('#page' + num).animate({ top: '0%' }, screen.availHeight / 2);
    currentPage = num;
}

basically this is done by adding CSS 基本上,这是通过添加CSS来完成的

overflow: hidden;

to the enclosing container, but without seeing the code over here, getting help is hard. 到封闭的容器中,但是在这里看不到代码,很难获得帮助。

try 尝试

 .manualPage{opacity:0}

OR 要么

.manualPAge{visibility:hidden}

this way, all ages ( #page1 , #page2 etc) with class manualPAge would not be visible. 这样,将不会显示具有manualPAge类的所有年龄段( #page1#page2等)。

during the animation, when you are setting the top property, set the opacity to 1 OR visibility to visible 在动画期间,当您设置top属性时,将opacity设置为1或将visible visibilityvisible

another way to do it is to set the overflow property of the containing window: 另一种方法是设置包含窗口的overflow属性:

          .BigWindow{overflow:hidden} 

this way, any content exceeding the height of the .BigWindow would not be shown 这样,任何超出.BigWindow高度的内容都不会显示

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

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