css

2019-04-07  本文已影响0人  十六只猴子王
  1. css:层叠样式表

层叠:一层一层的
样式表:很多的属性和属性值
提高代码的可维护性


  1. css和html的结合方式:四种

  <style type = "text/css">
  div{
    background-color:red;
    color:green;
  }
</style>

第三种结合方式缺点:在有些的浏览器中不能使用,一般使用第四种方式
优先级的问题:由上到下,由外到内,优先级由低到高,后加载的优先级高(一般情况)

选择器名称:选择器名称{属性名:属性值;属性名:属性值;......}


  1. css的选择器

选择器:要对哪个标签的数据进行操作

  <style type = "text/css">
  div.hah{
    background-color:red;
    color:green;
  }
</style>
 <style type = "text/css">
  div#hah{
    background-color:red;
    color:green;
  }
</style>

优先级

style > id选择器 > class选择器 > 标签选择器


  1. css的扩展选择器

 <style type = "text/css">
  div p{
    background-color:red;
    color:green;
  }
</style>
 <style type = "text/css">
  div,p{
    background-color:red;
    color:green;
  }
</style>

超链接状态:

原始状态 悬停状态 点击状态 点击后状态
:link :hover :active :visited

<a href >超链接1</a>

<style type = "text/css">
  a:link{
    background-color:blue;
  }
  a:link{
    background-color:green;
  }
  a:link{
    background-color:red;
  }
  a:visited{
    background-color:gray;
  }
</style>

  1. 盒子模型


  1. css的布局的漂浮

float
left:文本流向div的右边
right:文本流向div的左边


  1. css布局的定位

position
absolution:将对象从文档流总拖出,可以是top、bottom、left、right等属性进行定位
relative:不会将对象从文档流总拖出,可以是top、bottom、left、right等属性进行定位

上一篇 下一篇

猜你喜欢

热点阅读