简体   繁体   English

如何向UI Desinger证明2个div具有相同的高度和垂直位置?

[英]How can I prove to a UI Desinger that 2 divs have the same height and vertical position?

I work as a front-end developer and I keep getting bugs filed by a UI Designer who says that 2 of my elements are slightly misaligned and need to match the mockup more closely. 我作为前端开发人员工作,并且不断收到UI设计师提交的错误,该设计师说我的两个元素略有不一致,需要更紧密地匹配模型。 I've looked at my page a million ways and I can't see how anyone could claim that these 2 boxes aren't perfectly aligned. 我已经以一百万种方式查看了我的页面,但看不到有人能声称这两个框未完全对齐。 I've looked in Inspect Element and there are perfect horizontal lines through the tops and bottoms of the boxes. 我查看了Inspect Element,并通过框的顶部和底部有完美的水平线。 I want some way of "proving" this, though. 不过,我想要某种“证明”的方式。 So I want something like 所以我想要像

function( var id1, var id2 )
{
    /* id1, id2: identifiers of the 2 divs */

    /* .... */ 
}

to print something like 打印类似

vertical position of top and bottom of first div: 162px, 180px
vertical position of top and bottom of second div: 162px, 180px

to the console, where the pixels are the absolute position with respect to the whole page (or the body , I suppose). 到控制台,其中像素是相对于整个页面(或body ,我想)的绝对位置。 Is this possible, and if so, how do I implement it? 这可能吗?如果可以,我该如何实施?

You will be wasting your time if all you have to go off of is a description of "slightly misaligned". 如果您所要做的只是描述“轻微未对准”,那将浪费您的时间。

Politely ask the UI Designer to provide a screenshot of the issue they are seeing. 礼貌地要求UI设计器提供他们遇到的问题的屏幕截图。

Additional information that will be helpful is: 其他有用的信息是:

  1. Operating System / Version 操作系统/版本
  2. Browser / Version 浏览器/版本
  3. Device / Resolution 设备/分辨率
  4. Browser addons 浏览器插件
  5. Browser settings that are not default 非默认的浏览器设置

It is most likely that you are both seeing different things and if you cannot reproduce it, you cannot fix it. 很有可能你们俩都看到了不同的东西,如果您无法复制它,就无法修复它。 It is important for you to mimic their environment as closely as possible. 对您来说,尽可能紧密地模仿他们的环境很重要。

Now, if for some reason they cannot provide a screenshot and if you do want go down the route of proving what you see is correct and they are not (which is not a good use of time) you can use the following JavaScript to get the pixel coordinates of your elements on the screen. 现在,如果由于某种原因他们不能提供屏幕截图,并且如果您确实想证明自己所见的正确而又不正确(这不是很好的时间浪费),则可以使用以下JavaScript来获取屏幕上元素的像素坐标。

var myElem = document.getElementById('id1').getBoundingClientRect(); console.log(myElem.top, myElem.right, myElem.bottom, myElem.left);

The values returned by element.getBoundingClientRect() are relative to the viewport. element.getBoundingClientRect()返回的值是相对于视口的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM