1. Hide files:
Ensure that search engines will not be considered spam and ignored; So that screen readers do not ignore hidden text.
.text-hidden {
display:block;
overflow: hidden;
width: 0;
height: 0;
}Copy the code
div{
box-sizing: border-box;
}Copy the code
div{
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
}Copy the code
Can only be used on a single line and width must be set
Add Clearfix to the parent element to make it easy to use
.clearfix:after {
display: table;
content: ' ';
clear: both;
overflow: hidden;
}
.clearfix {
*zoom: 1;
}Copy the code
5. The image grays
img {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
}Copy the code
You don’t need to use one more image to achieve the graying effect
body:before {
content: "";
position: fixed;
top: -10px;
left: 0;
width: 100%;
height: 10px;
-webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
-moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
box-shadow: 0px 0px 10px rgba(0,0,0,.8); z-index: 100;
}Copy the code
7. Comma-separated lists
ul > li:not(:last-child)::after {
content: ",";
}Copy the code
html {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
}Copy the code
a[href^="http"]:empty::before {
content: attr(href);
}Copy the code
.complexBlock {
width: calc(100% - 50% / 3);
padding: 5px calc(3% - 2px);
margin-left: calc(10% + 10px);
}Copy the code
11. Disable the mouse event
.noclick { pointer-events: none; }Copy the code
12. A P label with the left and right lines drawn before and after
p{
text-align: center;
}
p:after,
p:before{
content: "";
position: absolute;
top:10px;
height: 1px;
background: red;
width: 200px
}
p:after{
left: 0;
}
p:before{
right:0;
}Copy the code
<div class="choose">
<label><input type="checkbox">111</label>
<label><input type="checkbox">222</label>
<label><input type="checkbox">333</label>
<label><input type="checkbox">444</label>
<label><input type="checkbox">555</label>
</div>
<p class="count"></p>Copy the code
.choose{
counter-reset: fruit;
}
.choose input:checked{
counter-increment: fruit;
}
.count:before{
content: counter(fruit);
}Copy the code
14. User-select Disables the user from selecting text
div {
user-select: none;
}Copy the code
15. A highlight that appears after clearing the phone tap event
* {- its - tap - highlight - color: rgba (0,0,0,0); }Copy the code
16. Touch screen elements scrolling
overflow: scroll / auto, you also need to
-webkit-overflow-scrolling: touch;
17. Use hardware acceleration
.block {
transform: translateZ(0);
}Copy the code
18. Move the mouse over the button with a white light sweep
button{
width: 200px;
height: 50px;
border-radius: 4px;
background: #ea6f5a;
border: none;
color: #fff;
position: relative;
}
button:after{
background: #fff;
content:"";
position: absolute;
width: 50px;
height: 155px;
left: -70px;
top: -60px;
opacity:.3;
transform: rotate(40deg);
transition: all 1.4 s cubic-bezier(0.2, 1, 0.2, 1);
}
button:hover:after{
left: 60%;
}Copy the code
.arrow {
width:0px;
height:0px;
border-left:10px solid transparent;
border-right:10px solid transparent;
border-bottom:10px solid red;
font-size:0px; line-height:0px;
}Copy the code
20. Page center pop-up layer
.popup{
position: fixed;
margin: auto;
top:0;
left: 0;
right: 0;
bottom:0;
z-index:1;
}Copy the code
To make the pop-up layer absolutely centered on the screen, remember to set the width and height of your pop-up layer