移动混合开发之页面布局

<!DOCTYPE html>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 -->
<html>
<head>
    <!--
     Customize this policy to fit your own app‘s needs. For more guidance, see:
     https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
     Some notes:
     * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
     * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
     * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
     * Enable inline JS: add ‘unsafe-inline‘ to default-src
     -->
    <meta http-equiv="Content-Security-Policy"
          content="default-src ‘self‘ data: gap: https://ssl.gstatic.com ‘unsafe-eval‘; style-src ‘self‘ ‘unsafe-inline‘; media-src *">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta charset="utf-8">
    <meta name="viewport"
          content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
    <link rel="stylesheet" type="text/css" href="css/index.css">    <!----引入jQuery----!>
    <script type="text/javascript" src="js/jquery-2.2.4.min.js"></script>
    <!--引入滑动第三方库,让列表滑动-->
    <script type="text/javascript" src="js/iscroll-lite.js"></script>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <title>Hello World</title>
</head>
<body>
<div class="head">
    极客浏览器
</div>
<!--自定义布局,没有使用第三方框架-->
<div class="content">
    <div class="nav"></div>
    <div class="list" id="file-list">
        <ul >
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name1</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name2</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name3</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name4</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name5</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name6</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name7</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name8</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name9</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li><li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
            <li>
                <div class="file-icon"></div>
                <div class="file-name">This is file name</div>
            </li>
        </ul>
    </div>
</div>
</body>
</html>

index.css:

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
* {
    -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
}

.head{
    position:absolute;
    left:0;
    right:0;
    top:0;
    height:2rem;
    line-height: 2rem;
    background-color:orange;
    padding-left:.3rem;
    color: white;
    text-align: center;
}

.content{
    position:absolute;
    top:2rem;
    bottom:0;
    left:0;
    right:0
}
.content .nav{
    position: absolute;
    top: 0;
    height: 1.5rem;
    left: 0;
    right: 0;
    background: #efefef;
}

.content .list{
    position: absolute;
    top: 1.5rem;
    left: 0;
    right: 0;
    bottom: 0;
    background: #adadad;
    overflow: hidden;
}

.content ul{
    list-style: none;
    padding: 0;
    margin: 0;
}

.content ul li{
    position: relative;
    height: 2rem;
    padding-left: .5rem ;
    border-bottom: 1px solid gray;
    background: white;
}
.content ul li.touchInside{
    background: #efefef;
}
.content ul li .file-icon{
    position: absolute;
    background: url("../img/file.png") no-repeat center;
    background-size: 1.2rem 1.2rem;
    width: 1.2rem;
    height: 1.2rem;
    left: 1rem;
    top:.3rem;
}
.content ul li .file-name{
    position: absolute;
    line-height: 2rem;
    left: 3.2rem;
}

index.js:

/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements.  See the NOTICE file * distributed with this work for additional information * regarding copyright ownership.  The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied.  See the License for the * specific language governing permissions and limitations * under the License. */var app = {    // Application Constructor    initialize: function () {        this.bindEvents();    },    // Bind Event Listeners    //    // Bind any events that are required on startup. Common events are:    // ‘load‘, ‘deviceready‘, ‘offline‘, and ‘online‘.    bindEvents: function () {        document.addEventListener(‘deviceready‘, this.onDeviceReady, false);    },    // deviceready Event Handler    //    // The scope of ‘this‘ is the event. In order to call the ‘receivedEvent‘    // function, we must explicitly call ‘app.receivedEvent(...);‘    onDeviceReady: function () {        app.receivedEvent(‘deviceready‘);    },    // Update DOM on a Received Event    receivedEvent: function (id) {        var parentElement = document.getElementById(id);        var listeningElement = parentElement.querySelector(‘.listening‘);        var receivedElement = parentElement.querySelector(‘.received‘);

        listeningElement.setAttribute(‘style‘, ‘display:none;‘);        receivedElement.setAttribute(‘style‘, ‘display:block;‘);

        console.log(‘Received Event: ‘ + id);    }};

app.initialize();

$(function () {    var size = $(window).width() / 18    //设计字体宽度    $(‘html‘).css(‘font-size‘, size);    var myscroll = new IScroll("#file-list");    attachEvent($(‘li‘),function () {        // $(this).remove();    })});

function attachEvent(sr, cb) {    var _this = $(this);    var timeID = null;    //click事件反应时间为300毫秒    //手指按下,若手指移动,则触发取消    sr.unbind();    sr.on(‘touchstart‘, function () {        _this.data(‘touch‘, true);        var me = $(this)        //设计timeID如果点下时滑动就不用触发        timeID = setTimeout(function () {            me.addClass(‘touchInside‘);        },100);    })

    sr.on(‘touchend‘, function () {        clearTimeout(timeID);        if (_this.data(‘touch‘)){            //改变回调函数的this指针为sr            //触发回调函数            cb.bind(this)();        }        $(this).removeClass(‘touchInside‘)        _this.data(‘touch‘, false);    })

    sr.on(‘touchmove‘, function () {        clearTimeout(timeID);        _this.data(‘touch‘, false);        $(this).removeClass(‘touchInside‘)    })}
时间: 2024-10-10 16:00:19

移动混合开发之页面布局的相关文章

小程序开发之页面布局

Flex布局又称弹性布局,在小程序开发中比较适用.因此将Flex布局相关属性整理如下,搞清楚了这个布局,小程序开发的页面布局就不在话下了. 网页布局(layout)是CSS的一个重点应用. 布局的传统解决方案,基于盒状模型,依赖 display属性 + position属性 + float属性.它对于那些特殊布局非常不方便,比如,垂直居中就不容易实现. 2009年,W3C提出了一种新的方案--Flex布局,可以简便.完整.响应式地实现各种页面布局.目前,它已经得到了所有浏览器的支持,这意味着,现

Android混合应用开发之页面跳转

Android混合开发之Activity类与html页面之间的相互跳转(并解决黑屏问题) 在底部有本程序源码下载 本程序流程:程序启动-->testActivity--->phonegap2框架类--->index.html--->testActivity,主要实现activity与html页面的相互跳转,并实现 传递参数的功能. 程序结构图: 1.创建一个安卓项目,在该项目里面添加PhoneGap框架(具体步骤请点击查看),我们知道我们在定义一个主界面的时候往往用的是Activi

ios&amp;h5混合开发项目仿app页面跳转优化

前言:本人原本是ios开发工程师,但由于现今H5的兴起,行内刮起了一阵混合开发的风气,趁着这股劲,我也学了前端开发,不说研究的多深,但也能胜任日常的开发工作.长话短说,现今的混合开发应该还处于摸索阶段,我们的项目主要页面都是由网页做的,只有一些IM.支付.分享.推送.上传照片这些用的是原生功能,大家都知道ios原生app的体验一直是很好的,现在改成了混合开发,无疑中就有些舍弃了ios原生的用户体验,而这个作为一个向来以用户体验为先的开发人员来说,这个真的是难以忍受,所以开始了以优化用户体验的为目

一步一步构建手机WebApp开发——页面布局篇

继上一篇:一步一步构建手机WebApp开发——环境搭建篇过后,我相信很多朋友都想看看实战案例,这一次的教程是页面布局篇,先上图: 如上图所示,此篇教程便是教初学者如何快速布局这样的页面.废话少说,直接上代码 注意:此教程是接上一篇教程,也就是所有的内容是直接从body开始写,当然,也会贴出所有代码给大家. 第一步:框架的布局及幻灯片的布局(Html) ① 如上图所示,我们应该准备以下容器,方便填充内容 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

.Net程序员玩转Android开发---(4)注册页面布局

上一篇我们介绍了登陆页面的布局,这一节我们看看注册页面的布局,实际上页面布局大同小异,来一起熟悉下基本控件的用法. 效果图: 1.添加注册页面 右键选中layout文件夹,添加注册页面.如下图 点击完成,页面添加完毕. 在页面中添加控件,XML代码如下 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com

python 之 前端开发(盒子模型、页面布局、浮动、定位、z-index、overflow溢出)

11.312 盒子模型 HTML文档中的每个元素都被比喻成矩形盒子, 盒子模型通过四个边界来描述:margin(外边距),border(边框),padding(内填充),content(内容区域),如果把一个盒子比喻成一个壁挂相片,那么 外边距margin ===== 一个相框与另外一个相框之间的距离 边框border ====== 边框指的就是相框 内边距padding ===== 相片与边框的距离 宽度width/高度height ===== 指定可以存放相片的区域 1.css显示模式:块级

网页开发学习笔记九: css 页面布局

文档流 块元素独占一行 行内元素在一行上显示 自上而下 浮动 float 用法 float: left | right; 特点 浮动起来 不占位置(脱标) 如果多个盒子都使用了浮动, 会在一行上显示 尽量用 display: inline-block; 来转 行内块 作用 文本绕图 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title>

学习android开发之路(一)页面布局

Android页面布局 1.Android页面布局一共分为6种: LinearLayout(线性布局).RelativeLayout(相对布局).TableLayout(表格布局).FrameLayout(帧布局).GridLayout(网格布局).AbsoluteLayout(绝对布局) 常用的为:线性布局和相对布局 2.布局的特点 FrameLayout帧布局 布局特点:放入其中的所有元素都被放置在最左上的区域,而且无法为这些元素指定一个确切的位置,下一个子元素会重叠覆盖上一个子元素 应用场

在混合开发中软键盘引起的布局问题、input与可编辑DIV兼容性问题汇总

此文复现的所有兼容性问题均为以下情况: 1. 腾讯X5内核 2. 全屏webview 问题如下: 1. IOS12 中软键盘弹出导致页面顶部截断,并且无法恢复. 解决方法:添加交互事件,调用本地方法,在键盘收起后执行页面回滚操作. bridgeClass.jsEventHook.keyboardWillShow = function () { // 添加flag 是因为 有多个空时,切换输入框也会调用WillHide switchFlag = true; }; bridgeClass.jsEve