为了账号安全,请及时绑定邮箱和手机立即绑定

css常用知识小梳理一二三

标签:
CSS3
CSS 使用技巧
  • 文字
    1. 水平居中
      text-aligh:center
    2. 垂直居中
      div{height:35px;line-height:35px}//1/n容器高度
  • 容器
    1. 水平居中
      div{width:760px;margin:0 auto}
    2. 垂直居中
      .outer{ position:relative; height:480px; } .inner{ position:absolute; top:50%; height:240px; margin-top:-120px; //然后,将小容器定位为absolute,再将它的左上角沿y轴下移50%,最后将它margin-top上移本身高度的50%即可。 }
  • 图片宽度自适应
    img{max-width:100%}
  • 3D按钮
    button {     background: #888;     border: 1px solid;     border-color: #999 #777 #777 #999;   }
  • font属性

body {     font-family: Arial, Helvetica, sans-serif;     font-size: 13px;     font-weight: normal;     font-variant: small-caps;     font-style: italic;     line-height: 150%;   } body {     font: italic small-caps normal 13px/150% Arial, Helvetica, sans-serif;   }

  • link状态设置顺序
    a:link   a:visited   a:hover   a:active
  • IE条件注释
    <!--[if IE]>     <link rel="stylesheet" type="text/css" href="ie-stylesheet.css" />   < ![endif]-->

  • CSS 优先级
    `
      行内样式 > id样式 > class样式 > 标签名样式

`

  • font-size基准
      body {font-size:62.5%;} //浏览器的缺省字体大小是16px,你可以先将基准字体大小设为10px:
  • Text-transform和Font Variant
    p {text-transform: uppercase}   p {text-transform: lowercase}   p {text-transform: capitalize}
  • reset
    `

`

  • 图片列表
    ul {list-style: none}   ul li {     background-image: url("path-to-your-image");     background-repeat: none;     background-position: 0 0.5em;   }
  • 三角形
    .triangle {     border-color: transparent transparent green transparent;     border-style: solid;     border-width: 0px 300px 300px 300px;     height: 0px;     width: 0px;   }
  • 禁止自动换行
    p { white-space:nowrap; }
  • 用图片替换文字---有时我们需要在标题栏中使用图片,但是又必须保证搜索引擎能够读到标题
    h1 {     text-indent:-9999px;     background:url("h1-image.jpg") no-repeat;     width:200px;     height:50px;   }
  • 焦点突出
      input:focus { border: 2px solid green; }
  • CSS 提示框
      <a class="tooltip" href="#">链接文字 <span>提示文字</span></a> a.tooltip {position: relative}   a.tooltip span {display:none; padding:5px; width:200px;}   a:hover {background:#fff;} /*background-color is a must for IE6*/   a.tooltip:hover span{display:inline; position:absolute;}
  • 固定位置
    body{ margin:0;padding:100px 0 0 0;}   div#header{     position:absolute;     top:0;     left:0;     width:100%;     height:<length>;   }   @media screen{     body>div#header{position: fixed;}   }   * html body{overflow:hidden;}   * html div#content{height:100%;overflow:auto;}
  • 图片预加载
    预加载
  • CSS选择器
    CSS选择器
  • 背景图定位
    定位
点击查看更多内容
3人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
Web前端工程师
手记
粉丝
7245
获赞与收藏
3476

关注作者,订阅最新文章

阅读免费教程

感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消