I have used some biased CSS once or twice, but I can’t remember it. Therefore, I need to go to Baidu and Google, so THEY all accumulate.

If you have a good CSS, you can also comment on the message, summary together, easy to check later use (continue to update…) 😀

For more details, check out my blog lishaoy.net


outline A border appears when input is selected

/* Normally set to None */
textarea:focus.input:focus{
    outline: none;
}
Copy the code

contenteditable Specifies whether the element content is editable

<div id="example-one" contenteditable="true">
Copy the code
#example-one { 
    margin-bottom: 10px; 
}
[contenteditable="true"] { 
    padding: 10px; outline: 2px dashed #CCC; 
}
[contenteditable="true"]:hover { 
    outline: 2px dashed #0090D2; 
}
Copy the code

webkit-playsinline All videos can be played on a page instead of in full screen

<video id="myvideo" src="test.mp4" webkit-playsinline="true"></video>
Copy the code

clearfix Remove the floating

.clearfix {
    zoom: 1;
}
.clearfix:after {
     visibility: hidden;
     display: block;
     font-size: 0;
     content: "";
     clear: both;
     height: 0;
 }
Copy the code

user-select Disallow selected text

p {
    -webkit-user-select: none; /* Chrome, Opera, Safari */
    -moz-user-select: none; /* Firefox 2+ */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* Standard syntax */
}
Copy the code

webkit-scrollbar Custom browser scroll bar

/* Define the width and height of the scroll bar and the background. The width and height correspond to the dimensions of the horizontal and vertical scroll bars */

div::-webkit-scrollbar {
    width: 5px;
    height: 5px;
    background-color: rgba(245, 245, 245, 0.47);
}

/* Define the scroll bar tracks, inner shadows and rounded corners */

div::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 3);border-radius: 10px;
    background-color: #f5f5f5;
}

/* Define slider, inner shadow and rounded corners */

div::-webkit-scrollbar-thumb {
    /*width: 10px; * /
    height: 20px;
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 3);background-color: rgba(85, 85, 85, 0.25);
}
Copy the code

webkit-appearance Remove default styles

input, button, textarea, select {
    *font-size: 100%;
    -webkit-appearance:none;
}
Copy the code

Page flickering bugs can occur when using CSS Transforms or animations

elements {
     -webkit-backface-visibility: hidden; 
}
Copy the code

transform-style: preserve-3d Make elements 3D-enabled

elements {
    -webkit-transform: rotateY(60deg); /* Chrome, Safari, Opera */
    -webkit-transform-style: preserve-3d; /* Chrome, Safari, Opera */
    transform: rotateY(60deg);
    transform-style: preserve-3d;
}
Copy the code

perspective This property defines that the child element gets perspective, not the element itself

<div class="cube pers250">
    <div class="face front">1</div>
    <div class="face back">2</div>
    <div class="face right">3</div>
    <div class="face left">4</div>
    <div class="face top">5</div>
    <div class="face bottom">6</div>
</div>
Copy the code
.cube {
  width: 100%;
  height: 100%;
  backface-visibility: visible;
  perspective-origin: 150% 150%;
  transform-style: preserve-3d;
  -webkit-backface-visibility: visible;
  -webkit-perspective-origin: 150% 150%;
  -webkit-transform-style: preserve-3d;
}
.pers250 {
  perspective: 250px;
  -webkit-perspective: 250px;
}
.face {
  display: block;
  position: absolute;
  width: 100px;
  height: 100px;
   border: none;
  line-height: 100px;
  font-family: sans-serif;
  font-size: 60px;
  color: white;
  text-align: center;
}
Copy the code

The CSS implements non-newline, automatic newline, and forced newline

/* No newline */
white-space:nowrap;

/* Wrap */
word-wrap: break-word; 
word-break: normal; 

/* Force a newline */
word-break:break-all;
Copy the code

font-smoothing Set font smoothness to make the font look more comfortable

h1..h1.h2..h2.h3..h3.h4..h4.h5..h5.h6..h6.p..navbar..brand.a..td-name.td {
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    font-family: "Microsoft YaHei".Microsoft Yahei.'Muli'."Helvetica", Arial, sans-serif;
}
Copy the code

::selection Modifies the selected text color

::selection {
	color: white;
	background-color: rgba(0, 0, 0, 0.8);
}
::-webkit-selection {
	color: white;
	background-color: rgba(0, 0, 0, 0.8);
}
::-moz-selection {
	color: white;
	background-color: rgba(0, 0, 0, 0.8);
}
Copy the code