【codecademy summary】html+css box model content

padding

The space between the contents of a box and the borders of a box is konwn as padding.

exmaple:

  padding: 10px;

or

  padding: 5px 10px 5px 10px; ( top right bottom left )

or

  padding: 5px 10px; ( top& bottom left& right)

or

  padding-top

  padding-right

  padding-bottom

  padding-left

 

-------------------------------------------------------------------------------------------------------------------

margin

The margin refers to the sapce directly outside of the box. We can adjust this spacing with the margin property.

exmaple:

  margin: 20px;

or 

  margin: 6px 12px 6px 12px; ( top right bottom left )

or

  margin: 6px 12px;

or

  margin-top

  margin-right

  margin-bottom

 

When margin: auto is uesd, anelements will center relative to its container. But the width of div must be less than the width of the class body.

 

-------------------------------------------------------------------------------------------------------------------

The code in the example above resets the default margin and padding values of all HTML elements.It is often the first CSS rule in an exernal stylesheet.

exmaple:

  *{

    margin: 0;

    padding: 0;

   }  

 

-------------------------------------------------------------------------------------------------------------------

dispaly 

Modifying the display property of an element can help achieve a desired layout for a web page. The dispaly property can take on one of four values:

 

  inline - cause block-level elements(like a div) to behave like an inline element (like a link)

  block - cause inline elements(like a link)t to behave like a block element (like a div)

  inline-block - causes block-level elements to behave like an inline element, but retain the feature of a block-level element.

  none - removes an element form view. The rest of the web page will act as if the element does not exit

 

In the example above, the block-level list items will now behave as inline elemnets. The result will be list items appearing on the same line, like a navigation bar.

-------------------------------------------------------------------------------------------------------------------

visibility

The visibility property can be set to one of the following values:

  hidden - hides an element.

  visible - displays an element.

Notice:

What's the difference between display: none and visibility: hidden ?An element with display: none will be completely removed from the web page. An element with visibility:hidden ,however, will nor be visible on the web page, but the space reserved for it will. But all that still can view the contents of the list item by viewing the source code in their browser.

转载于:https://www.cnblogs.com/guangluwutu/p/6552545.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值