zoukankan      html  css  js  c++  java
  • 移动混合开发之页面布局

    <!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;
         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')
    })
    }
  • 相关阅读:
    存储过程调用API
    Visual Studio 2019 添加不了区域 解决办法
    .NET Core 3.1 IIS其它网站出现HTTP503无法访问解决方法
    串口数据处理分包处理
    树莓派实践总和
    mysql定期任务
    Newtonsoft.Json.Linq 序列化 反序列化等知识
    使用IDbCommandInterceptor解决EF-CORE-3.x-使用MYSQL时,未正常的生成LIKE查询语句
    .Net Core自定义读取配置文件信息appsettings.Json
    .Net Core Cors跨域
  • 原文地址:https://www.cnblogs.com/yqlog/p/5604871.html
Copyright © 2011-2022 走看看