css 学习

来源:互联网 发布:银欣乌鸦2e 数据 编辑:程序博客网 时间:2024/06/05 13:26

positon: relative, fixed, absolute

  • absolute: 绝对定位,相对于父容器定位。
  • relative: 相对定位,相对于兄弟容器定位,不能使用left right, 而是使用margin。

水平居中:

.container{    margin: 0px auto;    width: 80%;}
body {    text-align:center;}p {    text-align: left;}
.container {    left: 50%;    width: 50%;    position: absolute;    margin-left: -25%;      //宽度/2}

float 浮动

  • left
  • right
  • clear: both
    出现浮动基本上必定出现一个clear.
.left {    float: left;}.right {    float: right;}.clear {    clear: both;}技巧.clearfix:after {    content: ".";    display: block;    height: 0;    clear: both;    visibility: hidden;}

background

  • background-color
    • transparent
    • color:#eeeeee
  • background-image
    • none
    • url(”)
  • background-repeat
    • repeat
    • no-repeat
    • repeat-x
    • repeat-y
  • background-attachment
    • fixed
    • scroll (default)
  • background-position:
    x y [left top bottom right 50%]

字体

字体单位一般使用px em, px绝对大小,em相对大小。

0 0