# 多益网络校招笔试题(前端工程师）

13 篇文章 0 订阅
6 篇文章 0 订阅

### 1 写出inline和inline-block的差别：

What is the difference between display: inline and display: inline-block?

### 4 考察字体大小的单位：rem,em,百分比

• em:

Another way of setting the font size is with em values. The size of an em value is dynamic. When defining the font-size property, an em is equal to the size of the font that applies to the parent of the element in question. If you haven’t set the font size anywhere on the page, then it is the browser default, which is often 16px. So, by default 1em = 16px, and 2em = 32px. If you set a font-size of 20px on the body element, then 1em = 20px and 2em = 40px. Note that the value 2 is essentially a multiplier of the current em size.

In order to calculate the em equivalent for any pixel value required, you can use this formula:

em = desired element pixel value / parent element font-size in pixels

核心观点:


• rem

rem values were invented in order to sidestep the compounding problem. rem values are relative to the root html element, not the parent element. In other words, it lets you specify a font size in a relative fashion without being affected by the size of the parent, thereby eliminating compounding.

核心观点：避免em的复合计算，相对root html元素的大小。

• length-percentage

A positive length or percentage value. When the units of length values are specified in em or ex, the size is defined relative to the size of the font on the parent element of the element in question. For example, 0.5em is half the font size of the parent of the current element. When the units are specified in rem, the size is defined relative to the size of the font used by the html (root) element.

percentage values refer to the parent element’s font size.

It is best to use values that are relative to the user’s default font size, and avoid absolute values such as lengths with units other than em or ex. However, if such absolute values must be used, px are preferred over other units because their meaning does not vary depending on what the operating system thinks (generally incorrectly) the resolution of the monitor is.

### 5 隐藏元素的N种方式

reference:

Five Ways to Hide Elements in CSS

• opacity
.hide {
opacity: 0;
}


• visibility
.hide {
visibility: hidden;
}


The element box is invisible (not drawn), but still affects layout as normal. Descendants of the element will be visible if they have visibility set to visible. The element cannot receive focus (such as when navigating through tab indexes).

display

display: none


Turns off the display of an element so that it has no effect on layout (the document is rendered as though the element did not exist). All descendant elements also have their display turned off.

To have an element take up the space that it would normally take, but without actually rendering anything, use the visibility property instead.

• Position
.hide {
position: absolute;
top: -9999px;
left: -9999px;
}


### 6 jQuery中live,bind,on,delegate的区别

• to be continued

### 7 如何去除img元素底部的空白

The line-height CSS property sets the amount of space used for lines, such as in text. On block-level elements, it specifies the minimum height of line boxes within the element. On non-replaced inline elements, it specifies the height that is used to calculate line box height.

• 5
点赞
• 0
评论
• 31
收藏
• 一键三连
• 扫一扫，分享海报

03-25
09-05 284

07-09 3807
09-07 2479
10-11 2838
09-06 913
12-11 614
04-10
10-20 788
03-01 1675
06-04 627
07-04 1万+
07-21 7万+