tecent面试题解答
题目在这
http://www.chinesefeng.com/default.asp?tag=%E6%8B%9B%E8%81%98%E8%AF%95%E9%A2%98
二个的实现
Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< TITLE > New Document </ TITLE >
< META NAME ="Generator" CONTENT ="EditPlus" >
< META NAME ="Author" CONTENT ="" >
< META NAME ="Keywords" CONTENT ="" >
< META NAME ="Description" CONTENT ="" >
< style type ="text/css" >
#x1
{
width : 150px ;
background-color : red ;
height : 50px ;
left : 50% ;
top : 50% ;
position : absolute ;
margin-top : -25px ;
margin-left : -75px ; }
#x2
{
width : 50px ;
height : 150px ;
background-color : red ;
left : 50% ;
top : 50% ;
position : absolute ;
margin-left : -25px ;
margin-top : -75 ; }
</ style >
</ HEAD >
< BODY >
< div id ="x1" ></ div >
< div id ="x2" ></ div >
</ BODY >
</ HTML >
三个的实现
Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< TITLE > New Document </ TITLE >
< META NAME ="Generator" CONTENT ="EditPlus" >
< META NAME ="Author" CONTENT ="" >
< META NAME ="Keywords" CONTENT ="" >
< META NAME ="Description" CONTENT ="" >
< style type ="text/css" >
<!--
/* 这三个css有很多雷同的样式,怎么样重构哪 */
#x { width : 50px ; height : 150px ; position : absolute ; left : 50% ; top : 50% ; margin-left : -25px ; margin-top : -75px ; background-color : red ; }
#y { width : 50px ; height : 50px ; position : absolute ; left : 50% ; top : 50% ; margin-left : -75px ; margin-top : -25px ; background-color : red ; }
#z { width : 50px ; height : 50px ; position : absolute ; left : 50% ; top : 50% ; margin-left : 25px ; margin-top : -25px ; background-color : red ; }
-->
</ style >
</ HEAD >
< BODY >
< div id ="x" ></ div >< div id ="y" ></ div >< div id ="z" ></ div >
</ BODY >
</ HTML >
Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< TITLE > New Document </ TITLE >
< META NAME ="Generator" CONTENT ="EditPlus" >
< META NAME ="Author" CONTENT ="" >
< META NAME ="Keywords" CONTENT ="" >
< META NAME ="Description" CONTENT ="" >
< style type ="text/css" >
<!--
/* 这三个css有很多雷同的样式,这样重构哪 */
div { width : 50px ; position : absolute ; left : 50% ; top : 50% ; background-color : red ; }
#x { height : 150px ; margin-left : -25px ; margin-top : -75px ; }
#y { height : 50px ; margin-left : -75px ; margin-top : -25px ; }
#z { height : 50px ; margin-left : 25px ; margin-top : -25px ; }
-->
</ style >
</ HEAD >
< BODY >
< div id ="x" ></ div >< div id ="y" ></ div >< div id ="z" ></ div >
</ BODY >
</ HTML >