騰訊校園招聘前端實習生面試題及答案

一、耐心填一填!(每空4分,共24分)

1. 爲div設置類a與b,應編寫HTML代碼  <div class=”a b”></div>

2. 設置CSS屬性clear的值爲 both時可清除左右兩邊浮動。

3.  ____li_____標籤必須直接嵌套於ul、ol中。

4.  CSS屬性 _____margin_______可爲元素設置外補丁。

5. 設置CSS屬性float的值爲 ___none____時可取消元素的浮動。

6. 文字居中的CSS代碼是 ____text-align:center______。

二、精心選一選!(每題4分,共16分)

1. 下列哪個樣式定義後,內聯(非塊狀)元素可以定義寬度和高度( C  )

A. display:inline      B. display:none     C. display:block    D. display:inheric


2. 選出你認爲最合理的定義標題的方法( C    )

A. <span class=”heading”>文章標題</span>

B. <p><b>文章標題</b></p>

C. <h1>文章標題</h1>

D. <strong>文章標題</strong>


3. br標籤在XHTML中語義爲( A  )

A.換行          B.強調          C.段落          D.標題


4. 不換行必須設置(  AC )

A.word-break        B.letter-spacing        C.white-space       D.word-spacing


5. 在使用table表現數據時,有時候表現出來的會比自己實際設置的寬度要寬,爲此需要設置下面哪些屬性值(  AD  )

A. cellpadding=”0″      B. padding:0        C. margin:0     D. cellspacing=”0″

三、判斷對或錯! (每題4分,共24分)

1. CSS屬性font-style用於設置字體的粗細。                           (  ×  )

2. CSS屬性overflow用於設置元素超過寬度時是否隱藏或顯示滾動條。    (   √  )

3. 在不涉及樣式情況下,頁面元素的優先顯示與結構擺放順序無關。       (  ×  )

4.在不涉及樣式情況下,頁面元素的優先顯示與標籤選用無關。            (    )

5. display:inline兼容所有的瀏覽器。                                     (     )

6. input屬於窗體元素,層級顯示比flash、其它元素都高。                  (   ×  )

四、用心想一想,你一定是生活中的智者!(每題9分,共36分)

1. 寫出ul、ol、dl三種列表的html結構。

答:

<ul>
       <li></li>
</ul>
 <ol>
       <li></li>
</ol>
<dl>
       <dt></dt>
       <dd></dd>
</dl>

2. 將以下CSS代碼進行縮寫,注意要符合縮寫的規範。

a) 代碼一:

border-width:1px; 

border-color:#000; 

border-style:solid;  

b) 代碼二:

background-position:0 0; 

background-repeat:no-repeat; 

background-attachment:fixed; 

background-color:#f00; 

background-image:url(background.gif);  

c)代碼三:

font-style:italic; 

font-family:"LucidaGrande",sans-serif; 

font-size:1em; 

font-weight:bold; 

font-variant:small-caps; 

line-height:140%;  

d) 代碼四:

list-style-position:inside; 

list-style-type:square; 

list-style-image:url(image.gif);

e)代碼五:

margin-left:20px; 

margin-right:20px; 

margin-bottom:5px; 

margin-top:20px; 

f)代碼六

color:#336699;  

color:#ffcc00; 

答:

代碼一:border:1px#000 solid;

代碼二:background:#f00 url(background.gif) no-repeat fixed 0 0;

代碼三:font:italicbold small-caps 1em/140% "lucida Grande",sans-serif;

代碼四:list-style:url(image.gif) square inside;

代碼五:margin:20px20px 5px 20px;

代碼六:color:#369;color:#fc0;

3. 修改以下代碼,使其結構更加合理以及符合W3C標準。(XHTML 1.0 Strict)

代碼:

<div> <h2>Don’tbuy these electronics used</h2> Money may be tight, but you may kickyourself for purchasing these electronics secondhand. <br /> Even whenthe price is low, the risk may be too high. <br /> <p><imgsrc=”album.jpg”></p> <p> <a href=”home.html”target=”_blank”>home</a> <a href=”content.html” target=”_blank”>content</a></p> </div>

答:

<div> <h2>Don’tbuy these electronics used</h2> <p> Money may be tight, but you may kick yourself for purchasingthese electronics secondhand. </p> <p>Even when the price is low, the risk may be too high.</p>  <img src="album.jpg"alt="album" /> <ul>    <li><ahref="home.html" rel="external" title="home">home</a></li>    <li><ahref="content.html" rel="external" title="content">content</a></li>  </ul></div>

4. 簡述border:none以及border:0的區別,並給出使用建議。

答:border:none表示邊框樣式無,border:0表示邊框寬度爲0;當定義了border:none,即隱藏了邊框的顯示,實際就是邊框寬度爲0.

當定義邊框時,必須定義邊框的顯示樣式.因爲邊框默認樣式爲不顯示none,所以僅設置邊框寬度,由於樣式不存在,邊框的寬度也自動被設置爲0。

五、勇氣拼一拼,讓你超越別人的加分題目來了!(不限於一種方法,共30分)

使用重構的方式製作出一個如下圖的水平、垂直都居中短邊爲50px,長邊爲150px的紅色十字架。

要求:

 

1.使用2個div完成

2.使用3個div完成

3.使用5個div完成

答案:

1.      使用2個div完成

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>2個DIV</title>

<styletype="text/css">

#heng,#shu{left:50%;top:50%;position:absolute;background-color:#f00;} 

#shu{width:50px;height:150px;margin-left:-25px;margin-top:-75px;} 

#heng{width:150px;height:50px;margin-left:-75px;margin-top:-25px;background-color:#f00;} 

</style>

</head>

<body>

     <divid="heng"></div>

     <div id="shu"></div>

</body>

</html> 

2.使用3個div完成

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />

<styletype="text/css">

.main{width:150px;height:150px; top:50%; left:50%; position:absolute; margin:-75px 0 0 -75px;border:2px #F00 solid;} 

.heng{width:150px;height:50px; background:#F00; margin-top:50px;} 

.shu{width:50px;height:150px; background:#F00; margin-left:50px; margin-top:-100px;/*margin上邊界疊加*/} 

</style>

<title>3個DIV</title>

</head>

<body>

  <div class="main">

         <divclass="heng"></div>

         <divclass="shu"></div>

</div>

</body>

</html> 

3.使用5個div完成

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>5個DIV(www.hemin.cn)</title>

<styletype="text/css">

#top,#middle,#left,#right,#bottom{height:50px;width:50px;position:absolute;top:50%;left:50%;} 

#top{margin:-75px 0 0-25px;background:#F00;} 

#middle{margin:-25px 0 0-25px;background:#000;} 

#left{margin:-25px 0 0-75px;background:#00F;} 

#right{margin:-25px 0 025px;background:#0F0;} 

#bottom{margin:25px 0 0-25px;background:#FF0;} 

</style>

</head>

<body>

<divid="top"></div>

<divid="middle"></div>

<divid="left"></div>

<divid="right"></div>

<divid="bottom"></div>

</body>

</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章