最全前端開發面試問題及答案整理

wscats發表於2019-02-16

來自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; width: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; width: 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瀏覽器。具體寫法可參照以下

相關文章