你平时有收藏哪些常用的css代码片断?

72 阅读1分钟

"```markdown

  • Flex布局
.container {
  display: flex;
  justify-content: center;
  align-items: center;
}
  • 水平居中
.center {
  margin-left: auto;
  margin-right: auto;
}
  • 垂直居中
.center {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
  • 文字溢出省略号
.ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
  • 清除浮动
.clearfix::after {
  content: \"\";
  display: table;
  clear: both;
}
  • 盒模型重置
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
  • 文本居中
.center {
  text-align: center;
}
  • 隐藏元素
.hidden {
  display: none;
}
  • 圆角边框
.rounded {
  border-radius: 50%;
}
  • 渐变背景
.gradient {
  background: linear-gradient(to right, #ff00ff, #00ffff);
}