css3总结笔记_html/css_WEB
属性选择器E[attr]只使用属性名,但没有确定任何属性值
备注:IE7及以上支持; 结构性伪类E:nth-child(n) 表示E父元素中的第n个字节点
其它伪类E:target 表示当前的URL片段的元素类型,这个元素必须是E css3绘制叉号 a{ display: inline-block; width: 20px;height:5px; background: red;line-height: 0;font-size:0;vertical-align: middle;-webkit-transform: rotate(45deg) } a:after{content:'/';display:block;width: 20px;height:5px; background: red;-webkit-transform: rotate(-90deg);}文字 文字阴影text-shadow:x y blur color, … 文字阴影应用 最简单用法 text-shadow:2px 2px 4px black 阴影叠加 text-shadow:2px 2px 0px red, 2px 2px 4px green; 先渲染后面的,再渲染前面的 //层叠:color:red; font-size:100px; font-weight:bold; text-shadow:2px 2px 0px white, 4px 4px 0px red;//光晕:color:white; font-size:100px; text-shadow:0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #ff00de, 0 0 70px #ff00de, 0 0 80px #ff00de, 0 0 100px #ff00de, 0 0 150px #ff00de;//火焰文字:text-shadow: 0 0 20px #fefcc9, 10px -10px 30px #feec85, -20px -20px 40px #ffae34, 20px -40px 50px #ec760c, -20px -60px 60px #cd4606, 0 -80px 70px #973716, 10px -90px 80px #451b0e; font-family:Verdana, Geneva, sans-serif; font-size:100px; font-weight:bold; color:white; 文字描边webkit-text-stroke:宽度 颜色 新增文本功能Direction 定义文字排列方式(全兼容) p{width:300px;border:1px solid #000;font:14px/30px "宋体";direction:rtl;unicode-bidi:bidi-override;unicode-bidi: bidi-override} Text-overflow 定义省略文本的处理方式 p{width:300px;border:1px solid #000;font:14px/30px "宋体"; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } 自定义文字 代码格式 @font-face { font-family: 'miaov'; src: url('1-webfont.eot'); src: url('1-webfont.eot?#iefix') format('embedded-opentype'), url('1-webfont.woff') format('woff'), url('1-webfont.ttf') format('truetype'), url('1-webfont.svg#untitledregular') format('svg'); font-weight: normal; font-style: normal;} 转换字体格式生成兼容代码http://www.fontsquirrel.com/fontface/generator 弹性布局弹性盒模型 1 2 3 4 5 注意在使用弹性盒模型的时候 父元素必须要加display:box 或 display:inline-box box-orient 定义盒模型的布局方向 Horizontal 水平显示vertical 垂直方向 .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box;-webkit-box-orient:vertical; } box-direction 元素排列顺序 Normal 正序 Reverse 反序 .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box;-webkit-box-direction:Reverse; font-size:20px;color:#fff; } box-ordinal-group 设置元素的具体位置 .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box; font-size:20px;color:#fff; }.box div{width:100px;height:100px;background:red;border:1px solid #fff;}.box div:nth-of-type(1){-webkit-box-ordinal-group:2;}.box div:nth-of-type(2){-webkit-box-ordinal-group:4;}.box div:nth-of-type(3){-webkit-box-ordinal-group:1;}.box div:nth-of-type(4){-webkit-box-ordinal-group:5;}.box div:nth-of-type(5){-webkit-box-ordinal-group:3;} box-flex 定义盒子的弹性空间 子元素的尺寸=盒子的尺寸*子元素的box-flex属性值 / 所有子元素的box-flex属性值的和 .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box; font-size:20px;color:#fff; }.box div{height:100px;background:red;border:1px solid #fff;}.box div:nth-of-type(1){width:300px;}.box div:nth-of-type(2){-webkit-box-flex:2;}.box div:nth-of-type(3){-webkit-box-flex:3;}.box div:nth-of-type(4){-webkit-box-flex:4;}.box div:nth-of-type(5){-webkit-box-flex:5;} box-pack 对盒子富裕的空间进行管理 start 所有子元素在盒子左侧显示,富裕空间在右侧 .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box;-webkit-box-direction:Reverse; font-size:20px;color:#fff;-webkit-box-pack:justify ; } box-align 在垂直方向上对元素的位置进行管理 star 所有子元素在据顶 1s 2s 3s 4s 5s 盒模型阴影用法 box-shadow:[inset] x y blur [spread] color 参数 box-shadow:10px 10px 30px blue;box-shadow:inset 10px 10px 30px blue;box-shadow:0 0 30px 10px #000; box-shadow:0 0 30px 30px #000,inset 0 0 30px yellow; 其他盒模型新增属性box-reflect 倒影 direction 方向必选 above|below|left|right; img{ -webkit-box-reflect:below;}//上下排列,倒影在下方img{ -webkit-box-reflect:right 10px;}//左右排列,倒影在右方img{-webkit-box-reflect:right 10px -webkit-linear-gradient(right,rgba(0,0,0,1) 0,rgba(0,0,0,0) 50%);}//线性渐变,逐渐消失background:-webkit-linear-gradient(red 0,blue 100%);//背景渐变 resize 自由缩放 both 水平垂直都可以缩放 .box{width:100px;height:100px;background:url(bg.jpg);border:5px solid #000; resize:both; overflow:auto;} 注意:一定要配合overflow:auto 一块使用只有水平方向可以缩放 box-sizing 盒模型解析模式 content-box 标准盒模型 width/height=border+padding+content .box{width:200px;height:200px;padding:50px;border:10px solid #000; box-sizing:border-box;} Css3分栏布局column-width 栏目宽度 .wrap{width:900px;border:1px solid #000; font:14px/28px "宋体";color:#000; text-indent:2em; -webkit-column-width:400px;}//分成了宽度400px的两栏.wrap{ -webkit-column-count:4; -webkit-column-gap:30px; -webkit-column-rule:1px solid red;}//分成了四列 只有webkit内核实现了该属性 Css3响应式布局媒体类型 all 所有媒体 关键字 and 媒体特性 (max-width:600px) 移动端meta
圆角border-radius: 1-4个数字 / 1-4个数字 border-radius: 10px/5px;border-radius:100px/150px;border-radius:20px 40px 60px 80px/10px 20px 30px 40px; 参数 border-radius:50%; 用法 border-radius:20px; 2个:对角 border-radius:20px 40px; 3个:斜对角 border-radius:20px 40px 60px; 4个:全部,顺时针 border-radius:20px 40px 60px 80px; 例子:风车 边框边框图片 border-image border-image-sourceg 引入图片 .box{width:200px;height:60px; -webkit-border-image:url(bt_blue.png) 0 10;border-left-width:20px;border-right-width:20px;}.box{width:100px;height:100px; border-width:20px; -webkit-border-image:url(border.png) 27 27 round round;} 边框颜色 border-colors 只在火狐下实现 -moz-border-left-colors:red blue yellow red blue yellow red blue yellow; 线性渐变线性渐变格式 IE 下的样式格式如下 filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#ff0000',GradientType='1');` 参数 background-image:-webkit-linear-gradient(60deg,red,blue);background-image:-webkit-linear-gradient(60deg,red,blue,yellow,blue); 点:渐变点的颜色和位置 线性渐变实例进度条 background-image:-webkit-linear-gradient(60deg,red 0,blue 50%,green 100%); repeating-linear-gradient background-image:-webkit-repeating-linear-gradient(60deg,red 0,blue 30px); 性渐变实例(2) background: -webkit-linear-gradient (top, rgba(255,255,255,1) 30%, rgba(255,255,255,0)), url(a.gif) 实例:百度音乐图片光影效果 兼容版本 .box{background:-webkit-linear-gradient(red,blue);background:-moz-linear-gradient(red,blue);background:linear-gradient(red,blue); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='red',endColorstr='blue',GradientType='0');} 径向渐变radial-gradient([<起点>]? [<形状> || <大小>,]? <点>, <点>…); background:-webkit-radial-gradient(red,blue);background:-webkit-radial-gradient(100px 50px,red,blue);background:-webkit-radial-gradient(100px 50px,circle,red,blue);background:-webkit-radial-gradient(100px 50px,100px 20px,red,blue);background:-moz-radial-gradient(100px 50px,red,blue); 背景多背景 先写的背景在上面 background:url(bt_blue.png) no-repeat, url(border.png) repeat-y right 0; 背景尺寸 遮罩Mask-image 1、通过 translate 来移动元素和用 left top 移动元素有何区别?分别有何优劣? |