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

CSS Notes

时间:2014-08-20 09:12:56      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:des   blog   http   color   io   strong   for   ar   

Margin vs. Padding

Margin is on the outside of block elements while padding is on the inside. Use margin to separate the block from things outside it. Use padding to move the contents away from the edges of the block. Enter image description here:

bubuko.com,布布扣

When elements needs space between them, better to use margins. When text or an inner element needs space between the parent box and itself go for paddings.

 

Width & Height

When you set the width and height properties of an element with CSS, you just set the width and height of the content area. To calculate the full size of an element, you must also add the padding, borders and margins.

 

/* It will only have effect on the link in this page */

#this-page a:hover {

    ...

}

 

nth-child

You can actually select any child of an element after the first child with the pseudo-class selector nth-child; you just add the child‘s number in parentheses after the pseudo-class selector. For example,

p:nth-child(2) {

    color: red;

}

would turn every paragraph that is the second child of its parent element red. The element that is the child goes before :nth-child; its parent element is the element that contains it.

CSS Notes,布布扣,bubuko.com

CSS Notes

标签:des   blog   http   color   io   strong   for   ar   

原文地址:http://www.cnblogs.com/shuaiwhu/p/3923724.html

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