Home >Web Front-end >HTML Tutorial >Css3 cool summary usage_html/css_WEB-ITnose
Let’s start with the CSS3 selectors:
E F: all descendant elements;
E>F: child elements in E;
E F: The nearest selector after the E element;
E~F: All sibling elements behind E (CSS3 does not include itself, nor does it include the previous one)
att* =val: As long as it contains the specified element character (val1, val2, etc.);
att^=val: Matches the first character;
att$=val: Matches the last character;
ATT~=val: separated by spaces, and one of them is val;
att|=val: starting with val and using the "-" connector;
CSS3 pseudo-class selection Object: first-line first-letter root not empty target before after first-child last-child nth-child(2) nth-last-child(odd) ;
Shadow: box -shadow: horizontal offset px vertical offset px shadow blur value color
box-shadow: 3px 4px 2px #000;
text-shadow: 5px -10px 5px red;
Background: background-size:10px 5px; background-clip: the clipping area of the background; background-origin: the starting position of the reference coordinates that specifies the background-position attribute;
background: -webkit- gradient(linear, 0, 0, 0, 100%, from(#fff), to(#000));
Rounded border: border-radius:10px 15px 20px 25px;
Border-top-right-radius: Horizontal radius Vertical radius (10px/30px)
Border-radius: 10px/20px 25px; // Four horizontal ones are 10, two vertical ones are 20 and two are 25
How to draw an ellipse: use half the width as the horizontal radius and half the height as the vertical radius
Media Query:
bf5aff75bef0e38269da60c09686e8bb user-scalable:0 does not allow manual scaling
01a0d24a99511494d2d9b6f1159e8051 This style file is applied when the width and length of the visible area of the screen is between 600px and 900px
In small.css: @media screen and (min-width:600px) and (max-width:900px) {//...}
9a0eddf47b59b2b79528778ffd79f60bThis mode is applied when the mobile device is in portrait mode; landscape
Border attribute border-image-source:url(./***.png);//Suppose the image is 81*81, and each one after the rule of nine is 27*27
border-image-width: 27px;
Border-image-slice: 27; // Only one of the nine points is displayed in the four corners; if it is 27*2=54, four of the nine points are displayed; if it is 81, then Display 9, cut to three times the width
border-image-outset: 0px; // The size of the border to expand outward
border-image-repeat: stretch; // Stretch repeat repeat pattern, the 2468 in the middle are repeated
Reflection attribute-webkit-box-reflect:above/below/left/right 100px -webkit-linear-gradient(top,transparent,#fff)
Transition transition: the effect of slowly transitioning from one to another -webkit-transition:padding 1s ease-out, color 1s linear 1s;
Four parameters (transition property-property, transition Time-duration, transition form-timing-function, delay time-delay)
animation animation parameters (name-name, -duration transition time, timing-function transition form, -delay delay time, -iteration-count The number of loops, whether -direction is reversed, -play-state animation state, -fill-mode state outside animation time)
-webkit-animation:demo 2s linear 3s 3
@ -webkit-keyframes demo {
0% {opacity:0;transform:translate(0px)} //Transparency translation
20% {opacity:0.2;transform:translate(20px)}
40% {opacity:0.4;transform:translate(40px)}
60% {opacity:0.6;transform:translate(60px)}
100% {opacity :1;transform:translate(100px)}
}
Attach an animation animation of the pop-up window
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>tan</title> <meta name="description" content=""> <meta name="keywords" content=""> <link href="" rel="stylesheet"> <style> .result-bg{ position:fixed;top:0;left:0; width:100%;height:100%; background-color:rgba(0,0,0,0.5); z-index:20 } .result{ display:block; position:absolute;top:0;left:0; z-index:21; width:16rem } .result.tan{ -webkit-animation:bouncein .8s ease-out backwards; -moz-animation:bouncein .8s ease-out backwards; -ms-animation:bouncein .8s ease-out backwards; animation:bouncein .8s ease-out backwards} @-webkit-keyframes bouncein{ 0%{opacity:0;-webkit-transform:scale(0.3)} 50%{opacity:1;-webkit-transform:scale(1.05)} 70%{-webkit-transform:scale(0.9)} 100%{-webkit-transform:scale(1)} } @keyframes bouncein{ 0%{opacity:0;transform:scale(0.3)} 50%{opacity:1;transform:scale(1.05)} 70%{transform:scale(0.9)} 100%{transform:scale(1)} } </style> </head> <body> <div class="result-bg J-result-bg"></div> <img class="result J-result tan" src="http://b0.hucdn.com/party/default/89f818525d6539038a89e21235c3dd59.png"> </body></html>
Here we talk about the cool -webkit-css:
-webkit-user-select:none You can use it to ban the content of the selected page: it is used to protect the content of the website from being copied and copied by users. Reprint to protect the copyright of the information;
在iOS上,当你触摸并按住触摸的目标,比如一个链接,Safari浏览器将显示链接有关的系统默认菜单。这个属性可以让你禁用系统默认菜单。
-webkit-touch-callout:none 在iPhone或者iPad上,当你触摸并按住触摸的目标,这个属性可以让你禁用系统默认菜单。 为default 是默认弹出系统框
-webkit-line-clamp:d2c1e15f2758ae4ead444247148d09ea 多行文本溢出显示省略号
大家应该都知道用text-overflow:ellipsis属性来实现单行文本的溢出显示省略号(…)。
如何解决多行显示省略号呢?
WebKit浏览器或移动端的页面可以采取 -webkit-line-clamp 它是一个 不规范的属性,它没有出现在 CSS 规范草案中。 它需要组合其他外来的WebKit属性。常见结合属性:
A. display: -webkit-box; 必须结合的属性 ,将对象作为弹性伸缩盒子模型显示 。
B. -webkit-box-orient :vertical;必须结合的属性 ,设置或检索伸缩盒对象的子元素的排列方式
C. text-overflow:ellipsis,可以用来多行文本的情况下,用省略号“…”隐藏超出范围的文本 。
跨浏览器兼容的方案:
p { position:relative; line-height:1.4em; /* 3 times the line-height to show 3 lines */ height:4.2em; overflow:hidden; } p::after { content:"..."; font-weight:bold; position:absolute; bottom:0; right:0; padding:0 20px 1px 45px; background:url(http://css88.b0.upaiyun.com/css88/2014/09/ellipsis_bg.png) repeat-y; }
这里注意几点:
-webkit-overflow-scrolling:touch 滑动很顺滑 在iOS 5+上促使一个元素类似Native的快速滚动和回弹的效果
.selector { overflow: auto;/* auto | scroll */ -webkit-overflow-scrolling: touch;}
-webkit-text-size-adjust:100% iOS浏览器横屏时会重置字体大小 横竖屏时候字体自己跟着自适应,PC端此属性已经除去
-webkit-tap-highlight-color -webkit-tap-highlight-color 只用于iOS (iPhone和iPad)和Android。在你点击一个3499910bf9dac5ae3c52d5ede7383485或者利用Javascript生成的可点击元素的时候,它就会出现一个半透明的灰色背景。
通过-webkit-tap-highlight-color,可以设置该属性为任何颜色。:-webkit-tap-highlight-color:transparent在Android下无效,透明可以通过rgba(0,0,0,0)实现。
-webkit-appearance:none 内阴影 为none改变按钮在iPhone下的默认风格 在IE系列和Opera浏览器上不支持“appearance”,而且Safari也只有3.0版本以上支持,而在Chrome和Firefox以及移动设置浏览器上得到较好的支持。
appearance的属性值 checkbox radio button listbox listitem等等 例如设置button的话 会让一段文字看起来像个button
border-radius Android 2.3:border-radius 在自带浏览器中不支持 %
Android 4.2.x:border-radius + border + 背景色,在自带浏览器中背景色溢出到圆角以外部分=>使用四个拓展最后一个合并
属性 | 描述 | CSS |
transform | 向元素应用 2D 或 3D 转换。 | 3 |
transform-origin | 允许你改变被转换元素的位置。 | 3 |
函数 | 描述 | 实例 | |
转换 | |||
translateX(n) translateY(n) | 沿着 X 或Y 轴移动元素。 | ||
translate(x,y) | 沿着 X 和 Y 轴移动元素。 | 值 translate(50px,100px) 把元素从左侧移动 50 像素,从顶端移动 100 像素。 div{ | |
缩放 | |||
scaleX(n) scaleY(n) | 改变元素的宽或高度。 | ||
scale(x,y) | 改变元素的宽度和高度。 | 值 scale(2,4) 把宽度转换为原始尺寸的 2 倍,把高度转换为原始高度的 4 倍。 div{ | |
定义 2D 旋转 | |||
rotate(angle) | 在参数中规定角度。turn是圈,1turn = 360deg;另外还有弧度rad,2πrad = 1turn = 360deg。如,transform:rotate(2turn); //旋转两圈 | 值 rotate(30deg) 把元素顺时针旋转 30 度。 div{ | |
倾斜 | |||
skewX(angle) skewY(angle) | 沿着 X 、或Y轴。 | ||
skew(x-angle,y-angle) | 沿着 X 和 Y 轴。 | 值 skew(30deg,20deg) 围绕 X 轴把元素翻转 30 度,围绕 Y 轴翻转 20 度。 div{ | |
使用六个值的矩阵。 | |||
matrix(n,n,n,n,n,n) | 定义 2D 转换,使用六个值的矩阵。 matrix() 方法把所有 2D 转换方法组合在一起。 | 使用 matrix 方法将 div 元素旋转 30 度 div{ |