简体   繁体   English

如何使WinJS应用程序可滚动?

[英]How to make winJS app scrollable?

I am new to developing Windows 8 store apps, and I am in the process of creating my first one. 我是开发Windows 8应用商店应用程序的新手,并且正在创建我的第一个应用程序。

The app I am making is a note taking app. 我正在制作的应用程序是一个记笔记的应用程序。 I only started the app yesterday, so it's still very basic, but I am having a problem with the scrolling. 我昨天才启动该应用程序,所以它仍然非常基础,但是我在滚动时遇到了问题。 Here is a screen shot displaying the problem: 这是显示问题的屏幕截图:

在此处输入图片说明

As you can see, when a certain number of notes are entered, they start overlapping the screen. 如您所见,当输入一定数量的笔记时,它们开始与屏幕重叠。 What I need to do is make it so that when the notes a certain amount of pixels from the side of the display, it makes it scroll-able. 我需要做的是使它在从显示侧面注意到一定数量的像素时使其可滚动。

The divs that the notes are contained in are created as the note is written. 编写注释时会创建包含注释的div。 The notes also auto change size depending on the amount of text entered. 注释还会根据输入的文本量自动更改大小。

Does anyone know how I would make it so that they scroll to the left and right instead of overlapping? 有谁知道我会怎么做,以便他们向左和向右滚动而不是重叠?

EDIT: Here is the CSS: 编辑:这是CSS:

body {

      overflow-x:auto;

}

#textInput {
    padding:20px;
    float:left;
    margin-top: 20px;
    margin-left: 20px;

    position:fixed;




}
#noteInput {
    display:block;
    border-width:5px;
    border-color:purple;
    box-shadow: 5px 5px 5px;


}

#titleInput {
    border-width:5px;
    border-color:purple;
    width:285px;
    box-shadow: 5px 5px 5px;


}

#noteSubmit {
    width:295px;
}

#headers {
    margin-left:100px;
    margin-top:80px;

}

#hr {
    margin-right: 40px;
    margin-left: 40px;
}

#noteContainer {
    float:left;
    margin-right:5px;
    margin-top:5px;
    margin-bottom:5px;
    margin-left:400px;





}

I haven't really bothered with the UI and design much yet, as I want to get all the background stuff like javascript, jquery, and azure working first. 我还没有真正为UI烦恼并进行过多设计,因为我想让所有背景知识(例如javascript,jquery和azure)首先工作。

I am only doing this app as a project for practice, for the 70-481 and 70-482 exams I have in two months, so its never going to be in the store or anything. 我只是将此应用程序作为练习项目,用于我两个月内进行的70-481和70-482考试,因此它永远不会在商店中出现。 Thanks for your help 谢谢你的帮助

Cheers Corey 干杯科里

I strongly recommend using a WinJS.UI.ListView control instead of writing the div elements yourself. 我强烈建议您使用WinJS.UI.ListView控件,而不要自己编写div元素。

That way you'll not only get a look & feel to your application that's consistent with what the user expects from a Windows 8 Modern UI app but it will also take care of the scrolling and management of the DOM elements for you. 这样,您不仅可以使应用程序的外观与用户对Windows 8 Modern UI应用程序的期望保持一致,而且还将为您处理DOM元素的滚动和管理。

See this tutorial on how to create and style a ListView control. 请参阅本教程 ,了解如何创建和设置ListView控件的样式。

I agree with @ma_il, but if you do want to add scrolling functionality to custom elements, you simple wrap those elements in a div and add some CSS properties to that div... 我同意@ma_il,但是如果您确实想向自定义元素添加滚动功能,则可以将这些元素简单地包装在div中,然后向该div中添加一些CSS属性...

overflow-x: auto; 溢出-x:自动; /* to scroll horizontally / overflow-y: auto; / *水平滚动/溢出-y:自动; / to scroll vertically / overflow: auto; /垂直滚动/溢出:自动; / to scroll in both directions */ /双向滚动* /

If the contents of that div are wider (or taller or both) than the screen then your screen will automatically become scrolling and touch will be supported. 如果该div的内容比屏幕宽(或更高或两者都高),则屏幕将自动滚动并支持触摸。

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

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