Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 围绕div对齐/环绕图像 我想实现的是一个页面,中间有一个DIV,屏幕中间(720x360)。这是使用jQuery完成的,使用: $(window).height()_Javascript_Jquery_Css_Alignment - Fatal编程技术网

Javascript 围绕div对齐/环绕图像 我想实现的是一个页面,中间有一个DIV,屏幕中间(720x360)。这是使用jQuery完成的,使用: $(window).height()

Javascript 围绕div对齐/环绕图像 我想实现的是一个页面,中间有一个DIV,屏幕中间(720x360)。这是使用jQuery完成的,使用: $(window).height(),javascript,jquery,css,alignment,Javascript,Jquery,Css,Alignment,以及: 这很好用 下一部分是获取180x180图像,以适应中间分区。这些图像将填充屏幕 我被困在如何使这些对齐的方式,我找不到一个活生生的例子,任何人做同样的事情 那么,这可能吗? <style type="text/css"> #main { display: block; margin:0 auto; /* This is make div into center of screen*/ width: 720px; height: 360px;

以及:

这很好用

下一部分是获取180x180图像,以适应中间分区。这些图像将填充屏幕

我被困在如何使这些对齐的方式,我找不到一个活生生的例子,任何人做同样的事情

那么,这可能吗?


<style type="text/css">

#main {
    display: block;
    margin:0 auto; /* This is make div into center of screen*/
    width: 720px;
    height: 360px;
    background: #ccc; /* Just for visibility */
    position: relative; /* As we want to make other div into center of this */
}

#content {
    display: block;
    width: 180px;
    height: 180px;
    position: absolute;
    left: 36.36%; /* You can calculate using math */
    /*
        Total Width - Width
        So you will get end point now minus half
        Width / 2 = 90
        Then 720 - 180 = 540
        And now your box will point to end but you need to divide
        half of width again 90/2 = 45
        Result is : 
        180/2/2 = 45
        720-180-45 = 495
        180/495*100 = 36.36
        So this is your width position.
    * */
    top: 25%;
    /*
    Same for height but as you can see it's 25% of your value and very easy
    * */
    background: red;
}


    </style>
    <div id="main">
   <div id="content"></div>
    </div>
#主要{ 显示:块; 边距:0自动;/*这是使div进入屏幕中心*/ 宽度:720px; 高度:360px; 背景:#ccc;/*仅用于可见性*/ 位置:relative;/*因为我们想将另一个div放到这个中心*/ } #内容{ 显示:块; 宽度:180px; 高度:180像素; 位置:绝对位置; 左:36.36%;/*你可以用数学计算*/ /* 总宽度-宽度 现在你们将得到终点减去一半 宽度/2=90 那么720-180=540 现在你们的盒子将指向终点,但你们需要分开 宽度的一半90/2=45 结果是: 180/2/2 = 45 720-180-45 = 495 180/495*100 = 36.36 这是你的宽度位置。 * */ 最高:25%; /* 同样的高度,但正如你所看到的,它是你价值的25%,非常简单 * */ 背景:红色; }
你可以为设计写一个CSS类,让你的图像继承它。试试JQueYes中的“GETAtQuy”,你不能用相同的技术来定位图像,把DIV放在中间,但是有适当的偏移坐标吗?也许你可以展示一下你目前所得到的(html、css和JS)。
<style type="text/css">

#main {
    display: block;
    margin:0 auto; /* This is make div into center of screen*/
    width: 720px;
    height: 360px;
    background: #ccc; /* Just for visibility */
    position: relative; /* As we want to make other div into center of this */
}

#content {
    display: block;
    width: 180px;
    height: 180px;
    position: absolute;
    left: 36.36%; /* You can calculate using math */
    /*
        Total Width - Width
        So you will get end point now minus half
        Width / 2 = 90
        Then 720 - 180 = 540
        And now your box will point to end but you need to divide
        half of width again 90/2 = 45
        Result is : 
        180/2/2 = 45
        720-180-45 = 495
        180/495*100 = 36.36
        So this is your width position.
    * */
    top: 25%;
    /*
    Same for height but as you can see it's 25% of your value and very easy
    * */
    background: red;
}


    </style>
    <div id="main">
   <div id="content"></div>
    </div>