zoukankan      html  css  js  c++  java
  • 窗口和对话框居中对齐

    Web前端的窗口,对话框等界面,经常需要居中对齐。
    在Jquery Easyui中等window组件中,通常有宽度width、高度height、距离容器左边的距离left、距离容器顶部的距离top,4个参数。


    在实现过程中,主要就是动态或静态设置这4个参数。


    当前窗口的高度:$(window).width()
    当前窗口的宽度:$(window).width()


    如果是获得父窗口的,用window.parent就可以了。


    width:是个方法,不是属性。


    下面是一个例子:
     var windowWidth =$(window.parent).width();
        var windowHeight=$(window.parent).height();
        var width=380;
        var height=windowHeight-200;
        var top=(windowHeight-height)/2;
        var left=(windowWidth-width)/2;
        var $win = $('#preView').window({
          content : '<iframe scrolling="yes" frameborder="0"  src="'  
                  + href  
                  + '" style="100%;height:98%;"></iframe>',  
            title: 'APP预览',
            width,
            height: height,
            top: top,
            left: left,
        });


        $win.window('open');

    宽度:固定宽度380
    高度:窗口高度-固定200
    距离顶部的距离:(窗口高度-对话框的高度)/2,居中对齐
    距离左边的距离:居中对齐


    在2种屏幕,试了,没有问题~
  • 相关阅读:
    FreeRTOS——队列管理
    Replication Controller、Replica Set
    基本概念与组件
    YAML配置文件
    curl命令测试服务器是否支持断点续传
    浏览器http跳转至https问题
    常用Linux日志文件功能
    SSH连接时,长时间不操作就断开的解觉办法
    防HTTP慢速攻击的nginx安全配置
    Centos6.5升级安装openssh7.7p1
  • 原文地址:https://www.cnblogs.com/qitian1/p/6462615.html
Copyright © 2011-2022 走看看