我正在开发一个移动应用程序,使其看起来像在iPad上运行。最初加载页面时,如果页面正文超出窗口/屏幕大小,则页面的滚动条显示为“超过”页眉和页脚。但是在刷新页面之后,滚动条会在页眉和页脚之间显示(也就是它只在整个页面上),这正是我想要的。页面加载时显示页眉和页脚的滚动条
我无法在jsfiddle上复制确切的行为(其中滚动条仅显示在主体上的滚动条),但它至少会在整个页面上显示滚动条。
任何帮助表示赞赏...
下面是我的代码: CSS:
.locationListItem {
margin-bottom: 5px;
}
.locationListPrimary {
color: blue;
font-weight: bold;
font-size: medium;
}
.locationListSecondary {
font-weight: bold;
font-size: smaller;
}
HTML:
@section header {
@*
Recommeneded to use an h1 element, but can contain any kind of element, but make sure to add the TrailsHeaderPrimary class to get the proper styling...
Using an h1 element will get the proper padding around the header line. To see the difference, try doing an h1 vs p *@
<h1 class="testHeaderPrimary">Search Locations</h1>
}
<div style="top: 15px; left: 15px; width: 100%; z-index: 2">
<ul data-role="listview" data-filter="true" data-filter-placeholder="Search/Filter Locations...">
@foreach (var location in Model.AvailableLocations)
{
<li>
<a href="#">
<div class="ui-grid-b">
<div class="ui-block-a"><span class="locationListPrimary" style="width: 20%">@location.Thing</span></div>
<div class="ui-block-b"><span class="locationListPrimary" style="width: 20%">@location.Person</span></div>
<div class="ui-block-c"><span class="locationListSecondary" style="width: 60%">@location.Year | @location.Stuff | @location.Type</span></div>
</div>
</a>
</li>
}
</ul>
</div>
@section navBar1 {
<a href="/Search/Index" style="font-size: x-large">Search</a>
}
@section navBar2 {
<a href="/Location/Index" style="font-size: x-large">Location</a>
}
@section navBar3 {
<a href="/LocationStrip/Index" style="font-size: x-large">LocationStrip</a>
}
@section navBar4 {
<a href="http://stackoverflow.com/" style="font-size: x-large; height: 60px" target="_blank">StackOverflow</a>
}
@section navBar5 {
<a href="#" style="font-size: x-large" target="_blank">NA</a>
}
的Javascript(从布局):
$(document).ready(function() {
resetScreenSize();
});
$(window).resize(function() {
resetScreenSize();
});
var resetScreenSize = function() {
var windowHeight = $(window).height();
var header = $('#testHeader');
var headerHeight = header.outerHeight();
var footer = $("#testFooter");
var footerHeight = footer.outerHeight() - 1;
$(".ui-grid-a").height(windowHeight - footerHeight - headerHeight);
$("#panelMain").height(windowHeight - footerHeight - headerHeight);
};
更新1: 下面是从布局文件身体......
<body style="height: 100%">
<div id="main" role="main" class="ui-content jqm-content" style="padding: 0; height: 100%;">
<div id="testHeader" data-role="header" data-theme="b" data-position="fixed">
@RenderSection("header", false)
</div>
<div class="ui-grid-a" data-theme="a">
<div id="panelMain" style="overflow: auto;">
<div class="ui-content">
@RenderBody()
</div>
</div>
</div>
<div id="testFooter" data-role="footer" data-theme="b" data-position="fixed" data-tap-toggle="false" style="height: 60px; display: block;">
<div data-role="navbar">
<ul>
<li>@RenderSection("navBar1", true)</li> <!-- Home/1 should be reserved for the home screen -->
<li>@RenderSection("navBar2", true)</li>
<li>@RenderSection("navBar3", true)</li>
<li>@RenderSection("navBar4", true)</li>
<li>@RenderSection("navBar5", true)</li>
</ul>
</div>
</div>
</div>
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
更新2: 一个在底部的标签进入到它的分裂20页%/ 80%。该页面使用不同的布局来完成20/80。当第一次加载页面,并没有纳入我的风格,在“头”标签,看起来像这样:
#panelLeft {
width: 20%;
border-right: 3px solid
}
#panelMain {
width: 80%;
}
但只要我刷新页面,所有的造型被应用。我开始怀疑它是否不会应用我在我的布局页面的每个“头”标记中指定的自定义样式。我应该把它们放在一个单独的css文件中吗?
此问题不再需要,因为项目正在转换为角度SPA。我没有机会尝试和建议的答案。 – ganders