码迷,mamicode.com
首页 > Web开发 > 详细

2014阿里巴巴web前端实习生试题分析(1)

时间:2014-10-14 19:36:49      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:阿里巴巴   web前端   

简化以下CSS代码:


div.container{
	
	width:500px;
	background-image:url(/img/sprite.png);
	background-repeat:no-repeat;
	background-position:0px -78px;
}

div.container ul#news-list,div.container ul#news-list li{
	margin:0px;padding:0px;
}

div.container ul#news-list li{
	padding-left:20px;
	background-image:url(/img/sprite.png);
	background-position:-120px opx;
}

A{
	font-size:14px;
	font-weight:bold;
	line-height:150%;
	color:#000000;
}


答案:

div.container{
	
	width:500px;
	background-image:url(/img/sprite.png);
	background-repeat:no-repeat;
	background-position:0px -78px;
}

div.container ul#news-list,div.container ul#news-list li{
	margin:0px;padding:0px;
}

div.container ul#news-list li{
	padding-left:20px;
	background-image:url(/img/sprite.png);
	background-position:-120px opx;
}

A{
	font-size:14px;
	font-weight:bold;
	line-height:150%;
	color:#000000;
}

div.container{
	
	width:500px;
	background:url(/img/sprite.png) no-repeat 0 -78px;
}

#news-list,#news-list li{
	
	margin:0 padding:0;
}

#news-list li{
	
	padding-left:20px;background:url(/img/sprite.png)no-repeat -120px 0;
}

分析:CSS简写用法介绍


(1)CSS中font简写:

font:italicsmall-capsbold12px/1.5emarial,verdana;等效于:


font-style:italic;
font-variant:small-caps;
font-weight:bold;
font-size:12px;
line-height:1.5em;
font-family:arial,verdana;

顺序:font-style|font-variant|font-weight|font-size|line-height|font-family


(2)CSS中background简写:

background:#fffurl(bg.gif)no-repeatfixedlefttop;等效于:

background-color:#fff;
background-image:url(bg.gif);
background-repeat:no-repeat;
background-attachment:fixed;
background-position:lefttop;

顺序:background-color|background-image|background-repeat|background-attachment|background-position


(3)CSS中margin&padding简写:

border:1pxsolid#000;等效于:

border-width:1px;
border-style:solid;
border-color:#000;


顺序:border-width|border-style|border-color

(4)CSS中list-style简写:

list-style:squareoutsideurl(bullet.gif);等效于:


list-style-type:square;
list-style-position:outside;
list-style-image:url(bullet.gif)

顺序:list-style-type|list-style-position|list-style-image


(5)四边的简写一般如下:

padding:1px2px3px4px;等效于:


padding-top:1px;
padding-right:2px;
padding-bottom:3px;
padding-left:4px;


顺序:top|right|bottom|left
不论是边框宽度,还是边框颜色、边距等,只要CSS样式涉及四边,顺序通通都是“上右下左”(顺时针方向)。


5.1)如果四边的值省略一个,只写三个:

padding:1px2px3px;则等效于省略的“左值”等于“右值”:


padding-top:1px;
padding-right:2px;
padding-bottom:3px;
padding-left:2px;

5.2)如果四边的值省略两个:

padding:1px2px;则等效于:省略的左值等于右值,上值等于下值


padding-top:1px;
padding-right:2px;
padding-bottom:1px;
padding-left:2px;

5.3)只有一个值

Padding:1px:则等效于:

padding-top:1px;
padding-right:1px;
padding-bottom:1px;
padding-left:1px;


























2014阿里巴巴web前端实习生试题分析(1)

标签:阿里巴巴   web前端   

原文地址:http://blog.csdn.net/u013476464/article/details/40081753

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!