2018-07-12

1.css的样式设置

1.背景

1.背景重复

         background-repeat:no-repeat|repeat-x|repeat-y
         
         background-repeat: no-repeat;

2.背景位置

        background-position-x:横坐标方向的位置
        background-position-y:纵坐标方向的位置
        传参 top,right,bottom,left,center

3.背景初步简写

        background-position: x y;
         
        background-position: center center;

4.背景简写

        background:color image repeat position

5.背景的吸附

       background-attachment:scroll|fixed;

6.背景大小

        background-size:x y;
        x -->width
        y -->height
        cover -->会覆盖整个div  特点:只能以大覆小

2.文本

1.文本颜色

    red -->纯色
    #ff2d51
    rgb()

2.文本对齐

    text-align:left|center|right 

3.文本修饰

    text-decoration:none|underline|overline|line-through

4.文本缩进

    text-indent 

5.文本转换

     text-transfomr:uppercase|lowercase|capitalize

3.字体

1.最小的字体

   不要小于12px 
    font-size字体大小

2.字体样式

    font-style:normal|italic

3.字体的权重

    font-weight:bold|bolder|lighter
    100-900

4.链接

    link -->没有访问的链接
    visited -->已经访问过的链接
    hover -->鼠标移入到链接上的状态
    active -->鼠标点击的那一刻

    tip:同时使用链接的这几种状态,顺序不打乱
1.png

5.列表

1.列表样式

    list-style:none;

2.列表样式类型

    list-style-type:disc|circle|square

3.列表样式图片

    list-style-image

6.表格

1.表格的简单模式和关键样式

关键样式:border-collapse: collapse;

     <style>
    table,th,td{
        width:500px;
        border:1px solid #333;
    }
    table{
       
        border-collapse: collapse;
        line-height: 50px;
        text-align: center;
    }
  </style>
    </head>
        <body>
         <table>
      <thead>
        <!-- tr  table row -->
        <tr><th>商城</th><th>手机</th></tr>
     </thead>
    <tbody>
        <!-- table data -->
        <tr><td>JD</td><td>苹果</td></tr>
        <tr><td>Tmall</td><td>小米</td></tr>
        <tr><td>苏宁</td><td>华为</td></tr>
    </tbody>
</table>
  </body>
2.png

2.跨越行row的表格

谁要跨越给谁rowspan

     <style>
    table,td{
        border: 1px solid #333;
    }
    table{
        text-align: center;
        border-collapse: collapse;
        width:500px;
        line-height: 50px;
    }
</style>
     </head>
    <body>
    <table>
    <tr><td rowspan="3">商城</td><td>鞋子</td> <td>衣服</td></tr>
    <tr>     <td>手机</td><td>钱包</td></tr>
    <tr>     <td>拖鞋</td><td>Tshirt</td></tr>
</table>
 </body>
3.png

3.跨越列的表格

谁跨越列就给谁colspan

      <style>
   
     table{
        width:500px;
        line-height: 50px;
        border-collapse: collapse;
        text-align: center;
    }
    table,td{
        border:1px solid #333;
    }
      </style>
  </head>
     <body>
    <table>
    <tr><td colspan="2">商场</td></tr>
    <tr><td>手机</td><td>衣服</td></tr>
    <tr><td>鞋子</td><td>pen</td></tr>
    <tr><td>服装</td><td>瓶子</td></tr>
    </table>
  </body>
4.png

6.轮廓

1.div轮廓

        width:100px;
        height:100px;
        background:#ff2d51;
        outline: 10px solid #44cef6;
5.png

2.input

默认情况


6.png

设置

     input{outline: none;}
7.png

7.设置元素的透明度

opacity设置元素的透明度

        div{
        width: 100px;
        height: 100px;
        background: red;
        opacity: 0.5;
        }

8.样式的继承

仅仅发生在块级元素之间

1. 子元素不设置宽度,它会继承父元素的宽度

     <style>
    .parent{
        width:200px;
        height:200px;
        background:red;
    }
    .child{
        height:100px;
        background:blue;
    }
    
</style>
</head>
<body>

<div class="parent">
    <div class="child"></div>
</div>
 </body>
8.png

2.父元素不设置height,它会获取子元素的height

  <style>
     .parent{
        width:200px;
        background:red;
    }
    .child{
        width:100px;
        height:100px;
        background:blue;
    }
    </style>
    </head>
   <body>

<div class="parent">
    <div class="child"></div>
 </div>
   </body>
9.png

3.文本和字体相关属性都是可以继承的

     <style>
    body{
        text-align: center;
        color:red;
        text-decoration: underline;

        font-size: 30px;
    }
    ul{
        list-style: none;
    }
    table{
        border-collapse: collapse;
    }
</style>
 </head>
 <body>

<p>hello world</p>
<ul>
    <li>1</li>
    <li>1</li>
    <li>1</li>
</ul>
<div>
    hello
    <p>world</p>
</div>
</body>
10.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,813评论 1 92
  • HTML 5 HTML5概述 因特网上的信息是以网页的形式展示给用户的,因此网页是网络信息传递的载体。网页文件是用...
    阿啊阿吖丁阅读 4,080评论 0 0
  • 学会使用CSS选择器熟记CSS样式和外观属性熟练掌握CSS各种选择器熟练掌握CSS各种选择器熟练掌握CSS三种显示...
    七彩小鹿阅读 6,342评论 2 66
  • HTML基础标签 1. ........ 定义段落 标签里面如果有多个空格,浏览器会默认只有一个空格 浏览器显示...
    环绕圈子阅读 428评论 1 0
  • 学习CSS的最佳网站没有之一 http://www.w3school.com.cn/tags/index.asp ...
    Amyyy_阅读 1,100评论 0 1