目录css
#FF0000
直接利用pycharm提供的取色器用font-family 控制字体种类html
body { font-family: "Microsoft Yahei", "微软雅黑", "Arial", sans-serif }
用font-size浏览器
p { font-size: 36px; }
值 | 描述 |
---|---|
normal | 默认值,标准粗细 |
bold | 粗体 |
bolder | 更粗 |
lighter | 更细 |
100~900 | 设置具体粗细,400等同于normal,而700等同于bold |
text-align属性规定了元素的中文本的水平对齐方式性能
值 | 描述 |
---|---|
left | 左对齐,默认就是左对齐 |
right | 右对齐 |
center | 居中对齐 |
text-decoration 属性用来给文字添加特殊效果字体
值 | 描述 |
---|---|
none | 默认。定义标准的文本。 |
underline | 定义文本下的一条线。 |
overline | 定义文本上的一条线。 |
line-through | 定义穿过文本下的一条线。 |
注意: 一个应用场景就是 :url
<style> a { text-decoration: none; } </style> <a href="https://www.baidu.com">首页</a>
本来a标签上内的文字有下划线,能够用text-decoration: none;
去掉code
将段落的第一行缩进 32像素:orm
p { text-indent: 32px; }
/*背景颜色*/ background-color: orange; /*背景图片*/ background-image: url("123.png"); /*背景图片平铺排满整个页面*/ background-repeat: repeat; /*背景图片不平铺*/ background-repeat: no-repeat; /*背景图片只在水平方向上平铺*/ background-repeat: repeat-x; /*背景图片只在垂直方向上平铺*/ background-repeat: repeat-y; /*背景图片的位置*/ background-position: 20px 30px;
支持简写:background:#336699 url('1.png') no-repeat left top;
htm
一般一个页面上的一个个的小图标并非单独的,而是一张很是大的图片,该图片上有网址所用到的全部的小图标经过控制背景图片的位置,来显示不一样的样式。blog
/*用来固定背景图片*/ background-attachment: fixed;
边框属性
分别写颜色、字体、样式
#d1 { border-width: 2px; border-style: solid; border-color: red; }
一般使用简写方式:
#d1 { border: 2px solid red; }
边框样式
值 | 描述 |
---|---|
none | 无边框。 |
dotted | 点状虚线边框。 |
dashed | 矩形虚线边框。 |
solid | 实线边框。 |
能实现圆角边框的效果
<style> div { border: 1px solid blue; background-color: red; height: 200px; width: 200px; border-radius: 10px; } </style>
inline 将块儿级标签变成行内标签 block 可以将行内标签 也能设置长宽和独占一行 inline-block; /*便可以设置长宽 也能够在一行展现*/ display:none 隐藏标签 而且标签原来占的位置也没有了 visibility:hidden 隐藏标签 可是标签原来的位置还在
.c1 { margin-top:5px; margin-right:10px; margin-bottom:15px; margin-left:20px; } /*能够简写*/ .c1 { margin: 5px 10px 15px 20px; } /*居中, 只能左右居中,不能上下居中*/ .c2 { margin: 0 auto; }
顺序为:上右下左
.c3 { padding-top: 5px; padding-right: 10px; padding-bottom: 15px; padding-left: 20px; } /*简写*/ .c3 { padding: 5px 10px 15px 20px; }
与margin同样,也是顺序为:上右下左
在css中,任何元素均可以浮动
浮动的元素是脱离正常文档流的(原来的位置会让出来)
浏览器会优先展现文本内容
.c1 { height: 100px; width: 100px; background-color: red; float: left; /*向左浮动*/ } .c2 { height: 100px; width: 100px; background-color: green; float: right; /*向右浮动*/ } .c3 { height: 100px; width: 100px; background-color: blue; float: none; /*默认值,不浮动*/ }
会形成父标签塌陷
clear属性能清除浮动带来的影响
值 | 描述 |
---|---|
left | 在左侧不容许浮动元素。 |
right | 在右侧不容许浮动元素。 |
both | 在左右两侧均不容许浮动元素。 |
none | 默认值。容许浮动元素出如今两侧。 |
inherit | 规定应该从父元素继承 clear 属性的值。 |
清除浮动影响能够用 :
.clearfix:after { content: ''; clear: both; /*左右两边不能右浮动的元素*/ display: block; } /*谁塌陷就把clearfix加给谁*/
值 | 描述 |
---|---|
visible | 默认值。内容不会被修剪,会呈如今元素框以外。 |
hidden | 内容会被修剪,而且其他内容是不可见的。 |
scroll | 内容会被修剪,可是浏览器会显示滚动条以便查看其他的内容。 |
auto | 若是内容被修剪,则浏览器会显示滚动条以便查看其他的内容。 |
/*设置圆形*/
全部的标签默认都是静态的,没法改变位置
position: static;
必须将静态的状态修改为定位以后
相对于标签原来的位置 移动
相对于已经定位过(只要不是static均可以)的父标签 再作定位
相对于浏览器窗口固定在某个位置不动
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .cover { background-color: rgba(128,128,128,0.5); position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 999; } .modal { background-color: white; position: fixed; /*top: 50%;*/ /*left: 50%;*/ z-index: 1000; } </style> </head> <body> <div>我是最底下的被压着的那个</div> <div class="cover"></div> <div class="modal"> <form action=""> <p>username: <input type="text"> </p> <p>password: <input type="password"> </p> <input type="submit"> </form> </div> </body> </html>
opacity
用来定义透明效果。取值范围是0~1,0是彻底透明,1是彻底不透明。