Properties Methods distal --css

Tags written fast

总结:‘.’点代表class类,‘#’代表id,‘$’代表数字从1开始,‘>’代表儿子

div.c1#d1               按下tab键
效果:
<div class="c1" id="d1"></div>

div.c$#d$*2             按下tab键
效果:
<div class="c1" id="d1"></div>
<div class="c2" id="d2"></div>

div.c$#d${文本}*2
效果:
<div class="c1" id="d1">文本</div>
<div class="c2" id="d2">文本</div>

div>(p>a)*10
效果:
<div>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
    <p><a href=""></a></p>
</div>  

Width and height

height: 200px;  # 高度200px
width: 200px;   # 宽度200px

Fonts

1. The text font

body {
  font-family: "Microsoft Yahei", "微软雅黑", "Arial", sans-serif
}

2. Font Size

p {
  font-size: 14px;
}

3. Font weight

font-weight is used to set the font of the word weight (thickness).

value description
normal The default value, standard thickness
bold Bold face
bolder Thicker
lighter thinner
100~900 Set specific thickness, 400 is equivalent to the normal, bold and is equivalent to 700
inherit Inherit the parent element font weight values

4. Font Color

- 十六进制值 - 如: #FF0000
- 一个RGB值 - 如: rgb(255,0,0)
- 一个RGB值 - 如: rgba(255,0,0,0.3)  # 第四个值为alpha,控制透明度
- 颜色的名称 - 如:  red

5. Font Alignment

text-align property predetermined level alignment of the text elements.

value description
left The default value is left-aligned
right Align Right
center Align
justify Justify

6. Underline Text Control

text-decoration property to add special effects to text.

value description
none default. Text defined criteria.
underline The next line of text is defined.
overline A text line definition.
line-through Define a line passing through the text.
inherit Text-decoration property inherited value of the parent element.

Commonly used to remove a label from the default scribe:

a {
  text-decoration: none;
}

7. The first line indent text

The first line of a paragraph indent 32 pixels:

p {
  text-indent: 32px;
}

8. English font change capital

text-transform

value description
none default. Defined text with lowercase and uppercase letters standards.
text-transform:capitalize Text each word beginning with a capital letter.
text-transform:uppercase Defined only capital letters.
text-transform:lowercase No definition of uppercase letters, lowercase letters only.
text-transform:inherit Provision should inherit the value of the text-transform property from the parent element.

Background Properties

1. Background Color

/*背景颜色*/
background-color: red;

2. Background image

/*背景图片*/
background-image: url('1.jpg');

3. Do not tile background

 background-repeat:repeat(默认):背景图片平铺排满整个网页
 background-repeat:repeat-x:背景图片只在水平方向上平铺
 background-repeat:repeat-y:背景图片只在垂直方向上平铺
 background-repeat:no-repeat:背景图片不平铺

4. Background position

background-position: 100px 10px; !*第一个调节左右  第二个调节上下

The stationary background image

Custom background image with the roll axis moves

background-attachment: fixed;

background: url("111.png")  center center;
background-attachment: fixed;

Case:

Copy the code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>滚动背景图示例</title>
    <style>
        * {
            margin: 0;
        }
        .box {
            width: 100%;
            height: 500px;
            background: url("http://gss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=e9952f4a6f09c93d07a706f3aa0dd4ea/4a36acaf2edda3cc5c5bdd6409e93901213f9232.jpg")  center center;
            background-attachment: fixed;
        }
        .d1 {
            height: 500px;
            background-color: tomato;
        }
        .d2 {
            height: 500px;
            background-color: steelblue;
        }
        .d3 {
            height: 500px;
            background-color: mediumorchid;
        }
    </style>
</head>
<body>
    <div class="d1"></div>
    <div class="box"></div>
    <div class="d2"></div>
    <div class="d3"></div>
</body>
</html>

Copy the code

6. shorthand method

background:#336699 url('1.png') no-repeat left top;

frame

1. border properties (width, style, color)

border-width
border-style
border-color

Commonly used shorthand way:

#i1 {
  border: 2px solid red;
}

2. Border Style

value description
none Rimless.
dotted Dot dashed border.
dashed Rectangular dotted border.
solid Solid border.

3. Set up and down the border

#d1 {
  border-top-style:dotted;  # 上边框类型
  border-top-color: red;    # 上边框颜色
  border-right-style:solid;     # 右边框类型
  border-bottom-style:dotted;   # 底部边框类型
  border-left-style:none;       做边框类型
}

4. disposed circular border

This effect can be achieved with attribute rounded border.

The border-radius set to be longer or to obtain a high half circular

div {
            height: 200px;
            width: 200px;
            border-radius: 50%;   # 宽的50%,高的50%。出来就是圆
            background-color: red;
            background-repeat: no-repeat;   # 禁止平铺
        }

The exemplary circular Avatar

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body {
            margin: 0;
            background-color: antiquewhite;
        }
        .c1 {
            height: 100px;
            width: 100px;
            border-radius: 50%;
            border: 5px solid white;
            overflow: hidden;
        }
        img {
            max-width: 100%;
        }
    </style>
</head>
<body>
<div class="c1">
    <img src="111.png" alt="">
</div>
</body>
</html>

6.display control display

HTML elements for controlling the display.

value significance
display:"none" HTML document element exists, but does not display in the browser. JavaScript code typically used for mating.
display:"block" Default occupies the entire width of the page, if you specify the width of the set, with the margin remaining part will be filled.
display:"inline" Press display inline elements, then re-set the element's width, height, margin-top, margin-bottom and float property will not be affected.
display:"inline block" At the same time that the element has the characteristics of inline elements and block-level elements.

Box model

margin:            用于控制元素与元素之间的距离;margin的最基本用途就是控制元素周围空间的间隔,从视觉角度上达到相互隔开的目的。
padding:           用于控制内容与边框之间的距离;   
Border(边框):     围绕在内边距和内容外的边框。
Content(内容):   盒子的内容,显示文本和图像。

margin outer border

.margin-test {
  margin-top:5px;       # 上外边框距离
  margin-right:10px;    # 右外边框距离
  margin-bottom:15px;   # 底部外边框距离
  margin-left:20px;     # 左边外边框距离
}

Shorthand:

.margin-test {
  margin: 5px 10px 15px 20px;  # 上右下左,顺时针
}

Common Center:

.mycenter {
  margin: 0 auto;
}

padding inside filling

.padding-test {
  padding-top: 5px;     # 上内边框距离
  padding-right: 10px;  # 右内边框距离
  padding-bottom: 15px; # 底部内边框距离
  padding-left: 20px;   # 左边内边框距离
}

Recommended use shorthand:

.padding-test {
  padding: 5px 10px 15px 20px;
}

Order: on the right lower left

Supplementary padding commonly used shorthand way:

  • A, for the four sides;
  • Providing two, one for the first - next, the second for left - right;
  • If three provided, for the first, second for left - right, for the third;
  • Providing four parameter values, will be the - Right - lower - left order to act on the four sides;

float float

Method 1. Floating

Are three values:

float: left:向左浮动

float: right:向右浮动

float: none:默认值,不浮动

clear attributes specify which element prevents the other side floating elements.

value description
left Not allowed to float on the left.
right On the right side floating elements are not allowed.
both Left and right sides are not allowed to float.
none Defaults. Allowing the floating element appear on both sides.
inherit Clear provisions should inherit the property value from the parent element.

2.clear

clear attributes specify which element prevents the other side floating elements.

value description
left Not allowed to float on the left.
right On the right side floating elements are not allowed.
both Left and right sides are not allowed to float.
none Defaults. Allowing the floating element appear on both sides.
inherit Clear provisions should inherit the property value from the parent element.

Note: clear property only for their own work, without affecting other elements.

3. Clear float

Clear float side-effects (collapse parent tag question)

There are three main ways:

  • Fixed height
  • Clear pseudo-element method
  • overflow:hidden

Clear pseudo-element method (use more):

.clearfix:after {
  content: "";
  display: block;
  clear: both;
}

overflow overflow property

value description
visible Defaults. Content will not be pruned, there will be elements outside the box.
hidden Content will be trimmed, and the remaining content is not visible.
scroll Content will be trimmed, but the browser will display the scroll bar to view the rest of the content.
auto If the content is pruned, the browser will display the scroll bar to view the rest of the content.
inherit Provision should inherit the value of the overflow property from the parent element.
.c1 {
            height: 100px;
            width: 100px;
            border: 1px solid black;
            overflow: auto;
        }

Locate

position: relative;  # 绝对定位
position: absolute;  # 相对定位
left: 100px;  # 距离左边100px
left: 50%;   # 距离左边50%距离
top: 100px;  # 距离上面100px;
top:50%;    # 距离上面50%的距离
相对定位  relative
    相当于标签原有的位置做偏移
        了解即可

绝对定位  absolute
    相当于已经定位过的(static>>>relative)父标签做偏移
        eg:
            小米购物车

固定定位  fixed
    相当于浏览器窗口固定在某个位置始终不变
        eg:
            回到顶部

Fixed positioning:

        .cc{    
            position: fixed;
            bottom: 20px;
            right: 20px;
            height: 50px;
            width: 100px;
            }
         <div class="cc">回到顶部</div>

z-index control from the z-axis

Laminating order of the objects is provided.

  1. z-index value indicates Who pressing, a large value to cover small pressure value,
  2. Only the positioning of the elements, in order to have z-index, that is to say, regardless of the relative positioning, absolute positioning, fixed positioning, you can use z-index, but can not use the floating element z-index
  3. z-index value has no units, is a positive integer, the default z-index value of zero if we do not have z-index value, or z-index value is the same, then who wrote the HTML behind, someone who is pressing on it, positioning the elements, the elements do not always suppress positioning.
  4. From the parent phenomenon: the father counsels his son and then regressed useless
#d1 {
  z-index: 999;
}
#d2 {
  z-index: 1000;
}

结果:优先展示d2的

transparency

Used to define the transparency. In the range from 0 to 1,0 it is completely transparent, 1 is completely opaque.

.c2 {
            background-color: rgb(128,128,128);
            opacity: 0.4;
        }

Guess you like

Origin www.cnblogs.com/guyouyin123/p/12109582.html