CSS

时间:2021-01-24 18:24:36   收藏:0   阅读:44

①:CSS与HTML结合方式

1.内联样式

2.内部样式表

3.外部样式表

②:CSS的使用

1.选择器

1.元素选择器

2.类选择器与D选择器

 <style> 
  .h31{}
  #h32{}
</style>
	……
  <h3 class="h31">i like you</h3>
  <h3 id="h32">i like you too</h3>

3.选择器组(,)

<style>
  .h31,#h32{ color: #b3d4fc}  
</style>

4.派生选择器

 div p{color: #b3d4fc} <!--忽略层级--> 
 div>p{color: #b3d4fc} /* 只选取一级 */

5.css中的伪类

技术分享图片

2.CSS中的基本属性

1.文本属性

<style>
  p {
    font-family: "隶书"; /*指定字体*/
    font-size: 2em; /*字体大小*/
    font-weight: bold; /*字体加粗*/
    color: #b3d4fc; /*文本颜色*/
    text-align: center; /*文本排列: left/right/center*/
    text-decoration: underline; /*文字修饰 下划线*/
    line-height: 50px; /*行高*/
   	text-indent : value (2em); /*首行文本缩进 这里未用上*/
  }
</style> ……
<p>i like you 你好</p>

技术分享图片

2.背景属性

<style>
  div{
    width: 100%;
    height: 800px;
    background-color: pink;
    background-image: url("../imgs/zoe.jpg");/*背景图*/
    background-repeat:no-repeat;/*设置平铺方式(x or y)*/
    background-position: 0 200px;/*设置背景图像的起始位置*/
    background-attachment: fixed; /*设置背景图相较于页面固定*/
  }
</style>

技术分享图片

3.列表属性

技术分享图片

4.边框属性(border)

<style>
  div {
    /*border: 10px red solid;/*实线*/
    border: 10px blue dashed; /*虚线*/
    /*border: 10px red none; /*无边框*/
   /*border-bottom: dashed #b3d4fc 10px; /*设置底边框的样式*/
   /* border-left: red solid; /*设置右边框的样式*/
      outline: red 2px solid;/*轮廓*/ 
  }
</style>

5.轮廓属性(outline)

6.盒子属性

技术分享图片

3.CSS定位

1.默认定位

2.浮动定位(float)

<style>
  .a{
    width: 100px;
    height: 100px;
    background: #b3d4fc;
   float: left;
    /*display: inline-block; 方式二:变成行内块元素消除独占一行属性*/
  }
  .b{
    width: 100px;
    height: 100px;
    background: pink;
    float:right;
    /*相对定位
    position: relative;
    right: 200px; 
    */
  }
</style>

![](https://img.imgdb.cn/item/600ce8423ffa7d37b3253413.jpg title="浮动")

3.相对定位(relative)

![](https://img.imgdb.cn/item/600ce8173ffa7d37b3252818.jpg title="相对定位")

4.绝对定位(absolute)

5.固定定位(fixed)

6.z-index

技术分享图片

③:CSS3新特性

1.圆角与盒子阴影

<style>
  div {
    width: 300px;
    height: 300px;
    background-color: pink;
    /* border-radius: 1px 20px 30px 50px;/*左上、右上、右下、左下(顺时针)*/
    border-radius: 50px; /*圆角*/
    /*盒子阴影:依次代表:水平偏移、垂直偏移、模糊半径、扩张半径、颜色*/
    box-shadow: 20px 20px 50px 10px gray;
  }
</style>

技术分享图片

2.渐变属性

<style>
 /*线性渐变*/   
background: linear-gradient(red, yellow);
background: linear-gradient(to right bottom, black, white);
background: linear-gradient(30deg, black, white); /*角度*/
/*径向渐变*/      
background: radial-gradient(black, white);
border-radius: 50px;
background: radial-gradient(black, white);
</style>

技术分享图片

4.背景

![](https://img.imgdb.cn/item/600d07233ffa7d37b33371ec.jpg title="大小使用的contain")

技术分享图片

4.过渡动画

原文:https://www.cnblogs.com/zoezza/p/14321279.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!