• 最全前端开发面试问题及答案整理


    来自Github秋风的原文

    说说你对闭包的理解

    Talk about your understanding of closures

    使用闭包主要是为了设计私有的方法和变量。闭包的优点是可以避免全局变量的污染,缺点是闭包会常驻内存,会增大内存使用量,使用不当很容易造成内存泄露。

    Using closures designed primarily to private methods and variables. Closure advantage of global variables are avoided contamination, the disadvantage is the closure will be permanent memory, the memory usage increases, improper use is likely to cause a memory leak.

    闭包有三个特性:

    Closures have three characteristics:

    1.函数嵌套函数
    2.函数内部可以引用外部的参数和变量
    3.参数和变量不会被垃圾回收机制回收

    1. Function
    2. The internal function nested function can refer to external parameters and variables
    3. The parameters and variables will not be garbage collection mechanism Recycling

    请你谈谈Cookie的弊端

    You talk about the shortcomings of Cookie

    cookie虽然在持久保存客户端数据提供了方便,分担了服务器存储的负担,但还是有很多局限性的。
    第一:每个特定的域名下最多生成20个cookie

    1.IE6或更低版本最多20个cookie
    2.IE7和之后的版本最后可以有50个cookie。
    3.Firefox最多50个cookie
    4.chrome和Safari没有做硬性限制
    
    1.IE6 or earlier up to 20 cookie 
    2.IE7 later version and last may have 50 cookie. 
    3.Firefox up to 50 cookie 
    4.chrome and Safari does not do hard limit. IE and Opera will clean up the least recently used cookie , Firefox will randomly to clean cookie .
    

    IEOpera 会清理近期最少使用的cookieFirefox会随机清理cookie

    cookie的最大大约为4096字节,为了兼容性,一般不能超过4095字节。

    IE 提供了一种存储可以持久化用户数据,叫做userdata,从IE5.0就开始支持。每个数据最多128K,每个域名下最多1M。这个持久化数据放在缓存中,如果缓存没有清理,那么会一直存在。

    IE can provide a way to store persistent user data, called UserData , from IE5.0 has supported. Each data up to 128K, under each domain up to 1M. The persistent data in the cache, if not cleaned the cache, it will always exist.

    优点:极高的扩展性和可用性

    Advantages: high scalability and availability

    1.通过良好的编程,控制保存在cookie中的session对象的大小。
    2.通过加密和安全传输技术(SSL),减少cookie被破解的可能性。
    3.只在cookie中存放不敏感数据,即使被盗也不会有重大损失。
    4.控制cookie的生命期,使之不会永远有效。偷盗者很可能拿到一个过期的cookie。
    
    1. Good programming, control the size of the session cookie stored in the object. 
    2. encryption and secure transmission technology (SSL), to reduce the possibility of cookie to crack. 
    3. Only non-sensitive data is stored in a cookie, even if stolen will not have significant losses. 
    4. Control cookie lifetime, so it will not always be effective. Theft are likely to get an expired cookie.
    

    缺点:

    Disadvantages:

    1.`Cookie`数量和长度的限制。每个domain最多只能有20条cookie,每个cookie长度不能超过4KB,否则会被截掉。
    
    2.安全性问题。如果cookie被人拦截了,那人就可以取得所有的session信息。即使加密也与事无补,因为拦截者并不需要知道cookie的意义,他只要原样转发cookie就可以达到目的了。
    
    3.有些状态不可能保存在客户端。例如,为了防止重复提交表单,我们需要在服务器端保存一个计数器。如果我们把这个计数器保存在客户端,那么它起不到任何作用。
    
    1.`Cookie` limit the number and length. Each domain can have a maximum of 20 cookie, each cookie length can not exceed 4KB, otherwise it will be truncated. 
    
    2. The security issues. If the cookie is intercepted, that person can get all the session information. Even if encryption is also unhelpful, because Interceptor does not need to know the meaning of the cookie, cookie forwarding as long as he can achieve their goals. 
    
    3. Some state can not be stored in the client. For example, in order to prevent duplicate submission form, we need to save a counter on the server side. If we put this counter is stored in the client, then it will not achieve any effect.

    Browser local storage

    浏览器本地存储

    在较高版本的浏览器中,js提供了sessionStorageglobalStorage。在HTML5中提供了localStorage来取代globalStorage

    In later versions of the browser, JS provides sessionStorage and globalStorage . In HTML5 provides in localStorage to replace globalStorage.

    html5中的Web Storage包括了两种存储方式:sessionStoragelocalStorage

    html5 The Web Storage includes two storage methods: sessionStorage and localStorage .

    sessionStorage用于本地存储一个会话(session)中的数据,这些数据只有在同一个会话中的页面才能访问并且当会话结束后数据也随之销毁。因此sessionStorage不是一种持久化的本地存储,仅仅是会话级别的存储。

    sessionStorage data stored locally for a session (session) in which the data only in the same session of the page to access data, and when the end of the session also will be destroyed. So sessionStorage not a persistent local storage, just session-level storage.

    localStorage用于持久化的本地存储,除非主动删除数据,否则数据是永远不会过期的。

    And localStorage for persistent local storage, unless the initiative to remove the data, or the data is never out of date.

    web storage和cookie的区别

    the difference between web storage and a cookie

    Web Storage的概念和cookie相似,区别是它是为了更大容量存储设计的。Cookie的大小是受限的,并且每次你请求一个新的页面的时候Cookie都会被发送过去,这样无形中浪费了带宽,另外cookie还需要指定作用域,不可以跨域调用。

    Web Storage concept and cookie similar, except that it is designed for higher-capacity storage. Cookie size is limited, and every time you request a new page when the Cookie will be sent in the past, so that virtually waste bandwidth, another cookie also need to specify the scope, not cross-domain calls.

    除此之外,Web Storage拥有setItem,getItem,removeItem,clear等方法,不像cookie需要前端开发者自己封装setCookie,getCookie

    In addition, Web Storage has setItem, getItem, removeItem, clear methods, unlike the cookie front-end developers need their own package setCookie, getCookie.

    但是cookie也是不可以或缺的:cookie的作用是与服务器进行交互,作为HTTP规范的一部分而存在 ,而Web Storage仅仅是为了在本地“存储”数据而生

    But the cookie is not indispensable: cookie 's role is to interact with the server as HTTP part of the specification exists, and Web Storage simply to the local "store" raw data

    浏览器的支持除了IE7及以下不支持外,其他标准浏览器都完全支持(ie及FF需在web服务器里运行),值得一提的是IE总是办好事,例如IE7、IE6中的userData其实就是javascript本地存储的解决方案。通过简单的代码封装可以统一到所有的浏览器都支持web storage

    Browser support in addition to IE7 and below are not supported, other standard browsers fully support (ie and FF need to run a web server in), it is worth mentioning that IE always good things, such as IE7, IE6 in the userData fact is javascript local storage solutions. By simple code package can be unified to all the browsers support Web storage.

    localStoragesessionStorage都具有相同的操作方法,例如setItem、getItemremoveItem

    localStorage and sessionStorage have the same method of operation, for example setItem, getItem and removeItem etc.

    cookie 和session 的区别:

    cookie and session distinction:

     1、cookie数据存放在客户的浏览器上,session数据放在服务器上。
     2、cookie不是很安全,别人可以分析存放在本地的COOKIE并进行COOKIE欺骗
        考虑到安全应当使用session。
     3、session会在一定时间内保存在服务器上。当访问增多,会比较占用你服务器的性能
         考虑到减轻服务器性能方面,应当使用COOKIE。
     4、单个cookie保存的数据不能超过4K,很多浏览器都限制一个站点最多保存20个cookie。
     5、所以个人建议:
        将登陆信息等重要信息存放为SESSION
        其他信息如果需要保留,可以放在COOKIE中
        
     1, cookie data is stored on the customer's browser, session data on the server. 
     2, cookie is not very safe, others can be analyzed at a local store and COOKIE COOKIE cheat should be used taking into account the security session. 
     3, session will be within a certain time saved on the server. When accessing the increase, it would be more occupy the performance of your server consider to reduce server performance, you should use COOKIE. 
     4, the data stored in a single cookie can not exceed 4K, many browsers are limited to a maximum of one site to save 20 cookie. 
     5, so personal recommendations: the login information and other important information is stored as SESSION additional information, if necessary, it can be placed in COOKIE
    

    CSS 相关问题

    CSS-related issues

    display:none和visibility:hidden的区别?

    display: none and visibility: hidden difference?

    display:none  隐藏对应的元素,在文档布局中不再给它分配空间,它各边的元素会合拢,
    就当他从来不存在。
    
    visibility:hidden  隐藏对应的元素,但是在文档布局中仍保留原来的空间。
    
    display: none to hide the corresponding elements in the document layout is no longer space allocated to it, it is the element of each side will be closed, on when he never existed. 
    
    visibility: hidden hides the corresponding elements, but still retain the original layout of the space in the document. The difference in the link andimport CSS is?
    

    CSS中 link 和@import 的区别是?

    The difference in the link andimport CSS is?

    (1) link属于HTML标签,而@import是CSS提供的; 
    (2) 页面被加载的时,link会同时被加载,而@import引用的CSS会等到页面被加载完再加载;
    (3) import只在IE5以上才能识别,而link是HTML标签,无兼容问题; 
    (4) link方式的样式的权重 高于@import的权重.
    
    (1) link belong to HTML tags, and CSSimport is provided; 
    (2) the page is loaded, link will also be loaded, but referencesimport CSS will wait until the page is finished loading reloading; 
    (3) Import only to recognize in IE5 or more, while link is HTML tag, no compatibility issues; style right 
    (4) linkimport way of weight above the weight of heavy. Similarities and Differences between absolute and float attributes: position
    

    position:absolute和float属性的异同

    Similarities and Differences between absolute and float attributes: position

    
    A:共同点:
    对内联元素设置`float`和`absolute`属性,可以让元素脱离文档流,并且可以设置其宽高。
    
    B:不同点:
    float仍会占据位置,position会覆盖文档流中的其他元素。
    
    A: common: 
    inline element set `float` and` absolute` property allows elements from the document flow, and can set its width and height. 
    
    B: Different point: 
    float will still occupy the position, position overrides other elements in the document flow.
    

    介绍一下box-sizing属性?

    Introduce the box-sizing property?

    box-sizing属性主要用来控制元素的盒模型的解析模式。默认值是content-box
    box-sizing property is primarily used to control element analytical model box model. The default value is content-Box.

    • content-box:让元素维持W3C的标准盒模型。元素的宽度/高度由border + padding + content的宽度/高度决定,设置width/height属性指的是content部分的宽/高
    • content-Box : Let element to maintain the standard W3C box model. Width / height of the element / height is determined by the border + padding + content width, set width / height attribute refers to the content portion of the width / height
    • border-box:让元素维持IE传统盒模型(IE6以下版本和IE6~7的怪异模式)。设置width/height属性指的是border + padding + content
    • border-Box : Let element to maintain the traditional box model IE (IE6 and IE6 ~ 7 the following versions of quirks mode). Set width / height attribute refers to the border + padding + content

    标准浏览器下,按照W3C规范对盒模型解析,一旦修改了元素的边框或内距,就会影响元素的盒子尺寸,就不得不重新计算元素的盒子尺寸,从而影响整个页面的布局。

    Under standard browser, according to W3C box model specification analysis, once the border or modify the elements within distance, it will affect the size of the box element, you have to recalculate the box the size of the elements, thus affecting the layout of the entire page.

    CSS 选择符有哪些?哪些属性可以继承?优先级算法如何计算? CSS3新增伪类有那些?

    CSS selectors are there? Which attributes can be inherited? Priority algorithm calculated? Added CSS3 pseudo-classes are those?

    1.id选择器( # myid)
    2.类选择器(.myclassname)
    3.标签选择器(div, h1, p)
    4.相邻选择器(h1 + p)
    5.子选择器(ul > li)
    6.后代选择器(li a)
    7.通配符选择器( * )
    8.属性选择器(a[rel = "external"])
    9.伪类选择器(a: hover, li:nth-child)
    
    1.id selector (# myid) 
    2. Class selector (.myclassname) 
    3. Tag selectors (div, h1, P) 
    4. adjacent selector (h1 + P) 
    5. child selector (ul> li ) 
    6. descendant selectors (li a) 
    7. wildcard selector (*) 
    8. attribute selector (a [rel = "external"]) 
    9. pseudo-class selectors (a: hover, li: nth-child)
          
    • 可继承的样式: font-size font-family color, text-indent;

    • 不可继承的样式:border padding margin width height ;

    • 优先级就近原则,同权重情况下样式定义最近者为准;

    • 载入样式以最后载入的定位为准;
    • Inheritable style: font-size font-family color, text-indent;
    • Non Inherited Styles: border padding margin width height;
    • Priority under the principle of proximity, with weights whichever the case recently defined style;
    • Loading last loaded positioning styles to prevail;

    优先级为:

    Priority:

      
      
    !important >  id > class > tag  
      
    important 比 内联优先级高,但内联比 id 要高
    

    CSS3新增伪类举例:

       
    p:first-of-type 选择属于其父元素的首个 <p> 元素的每个 <p> 元素。
    p:last-of-type  选择属于其父元素的最后 <p> 元素的每个 <p> 元素。
    p:only-of-type  选择属于其父元素唯一的 <p> 元素的每个 <p> 元素。
    p:only-child    选择属于其父元素的唯一子元素的每个 <p> 元素。
    p:nth-child(2)  选择属于其父元素的第二个子元素的每个 <p> 元素。
    :enabled  :disabled 控制表单控件的禁用状态。
    :checked        单选框或复选框被选中。
    

    position的值, relative和absolute分别是相对于谁进行定位的?

    position values, relative and absolute are positioned with respect to whom?

    absolute 
            生成绝对定位的元素, 相对于最近一级的 定位不是 static 的父元素来进行定位。
    
    fixed (老IE不支持)
        生成绝对定位的元素,相对于浏览器窗口进行定位。 
    
    relative 
        生成相对定位的元素,相对于其在普通流中的位置进行定位。 
    
    static  默认值。没有定位,元素出现在正常的流中
    
    absolute 
        generate absolute element positioned relative to the recent level is not static positioned parent element to be positioned. 
    
    fixed (old IE does not support) 
        to generate absolute element positioned relative to the browser window positioning. 
    
    relative 
        generating element relative positioning, relative to its position in the general stream positioning. 
    
    static default. No positioning element occurs in the normal stream
    

    CSS3有哪些新特性?

    CSS3 What's new?

    CSS3实现圆角(border-radius),阴影(box-shadow),
    对文字加特效(text-shadow、),线性渐变(gradient),旋转(transform)
    transform:rotate(9deg) scale(0.85,0.90) translate(0px,-30px) skew(-9deg,0deg);//旋转,缩放,定位,倾斜
    增加了更多的CSS选择器  多背景 rgba 
    在CSS3中唯一引入的伪元素是::selection.
    媒体查询,多栏布局
    border-image
    
    CSS3 rounded corners (border-radius), shadow (box-shadow), 
    add special effects to the text (text-shadow,), a linear gradient (gradient), rotation (transform) 
    transform: Rotate (9deg) Scale (0.85,0.90) translate (0px, -30px) skew (-9deg, 0deg); // rotation, scaling, positioning, tilt 
    adds more CSS selectors more background rgba 
    unique introduced in CSS3 pseudo-elements :: selection. 
    Media queries , multi-column layout 
    border-image
      

    XML和JSON的区别?

    XML and JSON difference?

    (1).数据体积方面。
    JSON相对于XML来讲,数据的体积小,传递的速度更快些。
    (2).数据交互方面。
    JSON与JavaScript的交互更加方便,更容易解析处理,更好的数据交互。
    (3).数据描述方面。
    JSON对数据的描述性比XML较差。
    (4).传输速度方面。
    JSON的速度要远远快于XML。
    
    (1) The data volume terms. 
    XML JSON relative terms, the volume of data is small, the speed of delivery faster. 
    (2) aspects of data exchange. 
    JSON and JavaScript interaction more convenient and easier to parse processing, better data interaction. 
    (3) The data described aspects. 
    JSON description of data than XML poor. 
    (4) The transmission speed. 
    JSON's speed is much faster than XML.
    

    对BFC规范的理解?

    BFC norms of understanding?

          BFC,块级格式化上下文,一个创建了新的BFC的盒子是独立布局的,盒子里面的子元素的样式不会影响到外面的元素。在同一个BFC中的两个毗邻的块级盒在垂直方向(和布局方向有关系)的margin会发生折叠。
        (W3C CSS 2.1 规范中的一个概念,它决定了元素如何对其内容进行布局,以及与其他元素的关系和相互作用。)
        BFC, block-level formatting context, a BFC created a new box is an independent layout, style, child elements inside the box will not affect the outside elements. In the same BFC two adjoining block-level box in the vertical direction (the direction of a relationship and layout) of margin will collapse from happening. 
        (A concept W3C CSS 2.1 specification, which determines how the elements in the layout of its contents, and its relationship with other elements and interactions.)
    

    解释下 CSS sprites,以及你要如何在页面或网站中使用它。

    Talk about your understanding of the semantic?

    CSS Sprites其实就是把网页中一些背景图片整合到一张图片文件中,再利用CSS的“background-image”,“background- repeat”,“background-position”的组合进行背景定位,background-position可以用数字能精确的定位出背景图片的位置。这样可以减少很多图片请求的开销,因为请求耗时比较长;请求虽然可以并发,但是也有限制,一般浏览器都是6个。对于未来而言,就不需要这样做了,因为有了`http2`。
    CSS Sprites in fact, the number of pages in the background image into an image file, and then use the CSS "background-image", "background- repeat", "background-position" a combination of background positioning, background-position can be used Digital can accurately locate the position of the background image. This can reduce the cost of many pictures request because the request takes a relatively long; although requests can be complicated, but there are limits, are six general browser. For the future, there is no need to do so, and because of `http2`.
    

    html部分

    html part

    说说你对语义化的理解?

    Talk about your understanding of the semantic?

    1,去掉或者丢失样式的时候能够让页面呈现出清晰的结构
    2,有利于SEO:和搜索引擎建立良好沟通,有助于爬虫抓取更多的有效信息:爬虫依赖于标签来确定上下文和各个关键字的权重;
    3,方便其他设备解析(如屏幕阅读器、盲人阅读器、移动设备)以意义的方式来渲染网页;
    4,便于团队开发和维护,语义化更具可读性,是下一步吧网页的重要动向,遵循W3C标准的团队都遵循这个标准,可以减少差异化。
    
    1, removed or lost when allowing page style showing clear structure 
    2, is conducive to SEO: search engines and to establish good communication helps crawlers to crawl more useful information: reptiles rely on labels to determine the context and the individual right keyword weight; 
    3, easy to resolve other devices (such as a screen reader, blind readers, mobile devices) in meaningful ways to render web pages;     4, easy to team development and maintenance, more readable semantic, is under Important Trends step right of the page, follow the W3C standards team follow this standard, the difference can be reduced.
    

    Doctype作用? 严格模式与混杂模式如何区分?它们有何意义?

    Doctype role? Strict mode and mixed mode how to distinguish? They mean?

    (1)、<!DOCTYPE> 声明位于文档中的最前面,处于 <html> 标签之前。告知浏览器以何种模式来渲染文档。 
    
    (2)、严格模式的排版和 JS 运作模式是  以该浏览器支持的最高标准运行。
    
    (3)、在混杂模式中,页面以宽松的向后兼容的方式显示。模拟老式浏览器的行为以防止站点无法工作。
    
    (4)、DOCTYPE不存在或格式不正确会导致文档以混杂模式呈现。  
    
    (1), <! DOCTYPE> declaration in the document in the front, in the <html> tag before. Tells the browser to render the document in which mode. 
    
    (2) strict mode layout and JS mode of operation is based on the highest standards of the browser supports running. 
    
    (3), in promiscuous mode, page backward compatible with liberal display. Simulate the behavior of older browsers do not work to prevent the site. 
    
    (4), DOCTYPE does not exist or incorrectly formatted document will lead to promiscuous mode rendering.   
    

    你知道多少种Doctype文档类型?

    Do you know how many document types Doctype?

     该标签可声明三种 DTD 类型,分别表示严格版本、过渡版本以及基于框架的 HTML 文档。
     HTML 4.01 规定了三种文档类型:Strict、Transitional 以及 Frameset。
     XHTML 1.0 规定了三种 XML 文档类型:Strict、Transitional 以及 Frameset。
    Standards (标准)模式(也就是严格呈现模式)用于呈现遵循最新标准的网页,而 Quirks
     (包容)模式(也就是松散呈现模式或者兼容模式)用于呈现为传统浏览器而设计的网页。
     
     The label can be declared DTD three types, respectively strict version, interim version and an HTML-based documentation framework. 
     HTML 4.01 specifies three document types: Strict, Transitional, and Frameset. 
     XHTML 1.0 specifies three XML document types: Strict, Transitional, and Frameset. 
     Standards (standard) mode (that is, in strict rendering mode) complies with the latest standards for rendering Web pages, while Quirks 

    (inclusive) mode (that is, loose rendering mode or compatibility mode) is used to render conventional web browser designed.

    HTML与XHTML——二者有什么区别

    HTML and XHTML-- What is the difference

    区别:
    1.所有的标记都必须要有一个相应的结束标记
    2.所有标签的元素和属性的名字都必须使用小写
    3.所有的XML标记都必须合理嵌套
    4.所有的属性必须用引号""括起来
    5.把所有<和&特殊符号用编码表示
    6.给所有属性赋一个值
    7.不要在注释内容中使“--”
    8.图片必须有说明文字
    
    Difference: 
    1. All tags must have a corresponding end tag element and attribute names 
    2. All tags must be lowercase 
    3. All the XML tags must be properly nested 
    4. All attributes must be quoted. " "enclosed 
    5. Put all the <and & special symbols with the coded representation 
    6. assign a value to all of the properties in the comment 7. Do not manipulation "-" 
    8. The image must have caption
    

    常见兼容性问题?

    Common compatibility problems?

    * png24位的图片在iE6浏览器上出现背景,解决方案是做成PNG8.也可以引用一段脚本处理.
    
    * 浏览器默认的margin和padding不同。解决方案是加一个全局的*{margin:0;padding:0;}来统一。
    
    * IE6双边距bug:块属性标签float后,又有横行的margin情况下,在ie6显示margin比设置的大。 
    
    * 浮动ie产生的双倍距离(IE6双边距问题:在IE6下,如果对元素设置了浮动,同时又设置了margin-left或margin-right,margin值会加倍。)
      #box{ float:left; 10px; margin:0 0 0 100px;} 
    
     这种情况之下IE会产生20px的距离,解决方案是在float的标签样式控制中加入 ——_display:inline;将其转化为行内属性。(_这个符号只有ie6会识别)
    
    *  渐进识别的方式,从总体中逐渐排除局部。 
    
    * Png24 bit image appears on iE6 browser background, the solution is made ​​PNG8. It can refer to a script processing. 
    
    * The browser's default margin and padding. The solution is to add a global * {margin: 0; padding: 0;} to unify. 
    
    * IE6 bilateral Distance bug: After the block attribute labels float, there are rampant margin circumstances, in ie6 show larger margin than the settings. 
    
    * Double ie generated from the float (IE6 bilateral distance problem: In IE6, if the element is set to float, while setting the margin-left or margin-right, margin value will double.) 

    #box {float: left; 10px; margin: 0 0 0 100px;}

    Under such circumstances IE will produce 20px distance, the solution is to add --_ display in the label style float control: inline; be converted to inline property. (_ This symbol identifies only ie6)

    * gradual recognition of the way from the local population gradually excluded. 
    
      首先,巧妙的使用“9”这一标记,将IE游览器从所有情况中分离出来。 
      接着,再次使用“+”将IE8和IE7、IE6分离开来,这样IE8已经独立识别。
      
      First, the clever use of " 9" This marks the IE's browser separated out from all the circumstances. 
      Then, again using the "+" to IE8 and IE7, IE6 separated, so that IE8 has been independently identified. 
    
      css
          .bb{
           background-color:#f1ee18;/*所有识别*/
          .background-color:#00deff9; /*IE6、7、8识别*/
          +background-color:#a200ff;/*IE6、7识别*/
          _background-color:#1e0bd1;/*IE6识别*/ 
          } 
    
    *  IE下,可以使用获取常规属性的方法来获取自定义属性,
       也可以使用getAttribute()获取自定义属性;
       Firefox下,只能使用getAttribute()获取自定义属性. 
       解决方法:统一通过getAttribute()获取自定义属性.
    
    * IE下,event对象有x,y属性,但是没有pageX,pageY属性; 
      Firefox下,event对象有pageX,pageY属性,但是没有x,y属性.
    
    * 解决方法:(条件注释)缺点是在IE浏览器下可能会增加额外的HTTP请求数。
    
    * Chrome 中文界面下默认会将小于 12px 的文本强制按照 12px 显示, 
      可通过加入 CSS 属性 -webkit-text-size-adjust: none; 解决.
    
    * 超链接访问过后hover样式就不出现了 被点击访问过的超链接样式不在具有hover和active了解决方法是改变CSS属性的排列顺序:
    L-V-H-A :  a:link {} a:visited {} a:hover {} a:active {}
    
    * 怪异模式问题:漏写DTD声明,Firefox仍然会按照标准模式来解析网页,但在IE中会触发怪异模式。为避免怪异模式给我们带来不必要的麻烦,最好养成书写DTD声明的好习惯。现在可以使用[html5](http://www.w3.org/TR/html5/single-page.html)推荐的写法:`<doctype html>`
    
    * 上下margin重合问题
    ie和ff都存在,相邻的两个div的margin-left和margin-right不会重合,但是margin-top和margin-bottom却会发生重合。
    解决方法,养成良好的代码编写习惯,同时采用margin-top或者同时采用margin-bottom。
    * ie6对png图片格式支持不好(引用一段脚本处理)
    
    * under IE, you can use the method to get the general properties for custom properties, 

    you can also use getAttribute () Gets the custom attributes;
    under Firefox, only Use getAttribute () Gets custom attributes.
    Workaround: Uniform for custom properties through getAttribute ().

    * Under IE, event object has x, y attributes, but no pageX, pageY property; 

    under Firefox, event object has pageX, pageY property, but there is no x, y properties.

    * Solution :( conditional comments) drawback is that in IE browser may add additional HTTP requests. 
    
    * Under Chrome Chinese interface will be smaller than default to force the 12px 12px text display, 

    by the addition of CSS properties -webkit-text-size-adjust: none; resolved.

    * After hover style is not accessible by hyperlink is clicked appears visited The Hyperlink style does not have hover and active the solution is to change the order of CSS properties: 

    LVHA: a: link {} a: visited {} a: hover {} a: Active {}

    * weird modalities: Leakage write DTD statement, Firefox will still be in accordance with the standard model to resolve the page, but IE will trigger quirks mode. To avoid quirks mode gives us unnecessary trouble, it is best to develop the good habit of writing DTD declaration. You can now use [html5] (http://www.w3.org/TR/html5/single-page.html) recommended notation: `<DOCTYPE html>` 
    
    * top and bottom margin overlap problem 

    ie and ff are present, adjacent both margin-left and margin-right does not coincide div, but margin-top and margin-bottom but it will coincide occur.
    Solution, to develop good coding habits, while using margin-top or while using margin-bottom.

    * Ie6 png image format support is not good for (quote a script processing)
    

    解释下浮动和它的工作原理?清除浮动的技巧

    Floating and explain how it works? Clear float tips

    浮动元素脱离文档流,不占据空间。浮动元素碰到包含它的边框或者浮动元素的边框停留。
    Floating elements from the document flow, does not occupy space. Floats across the border to stay its borders contain or floating elements. 
    
    1.使用空标签清除浮动。
       这种方法是在所有浮动标签后面添加一个空标签 定义css clear:both. 弊端就是增加了无意义标签。
    2.使用overflow。
       给包含浮动元素的父标签添加css属性 overflow:auto; zoom:1; zoom:1用于兼容IE6。
    3.使用after伪对象清除浮动。
       该方法只适用于非IE浏览器。具体写法可参照以下
    

    本文转载于:猿2048最全前端开发面试问题及答案整理

  • 相关阅读:
    (转)浅析epoll-为何多路复用I/O要使用epoll
    (转)C++对象的内存布局
    (转)C++ 虚函数表解析
    VS2008文件编码格式修改
    ubuntu与windows相关配置内容
    (转)windows宿主机,ubuntu虚拟机下的上网设置(有线网络和无线网络)
    第10章 名字控制
    php 代码重用
    php 变量
    php in_array 和 str_replace
  • 原文地址:https://www.cnblogs.com/10manongit/p/12645325.html
Copyright © 2020-2023  润新知