三十的博客

Css 常用特效

发布时间
阅读量 加载中...

毛玻璃

此演示仅在桌面端浏览器中可用

css
.frosted-glass {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); /* Safari支持 */
  border: 1px solid rgba(255, 255, 255, 0.18);
}

渐变文本

此演示仅在桌面端浏览器中可用

css
.gradient-text {
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

悬浮阴影

此演示仅在桌面端浏览器中可用

css
.card {
  padding: 20px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

图片悬浮放大

此演示仅在桌面端浏览器中可用

css
.image-hover-zoom {
  transition: transform 0.5s ease;
}

.image-hover-zoom:hover {
  transform: scale(1.1);
}

文字阴影

此演示仅在桌面端浏览器中可用

css
.text-shadow {
  font-size: 25px;
  font-weight: bold;
  color: #2c3e50;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); /* 水平 垂直 模糊 颜色 */
}

/* 多层阴影效果 */
.multi-shadow {
  font-size: 25px;
  font-weight: bold;
  color: #e74c3c;
  text-shadow: 1px 1px 0 #c0392b, 2px 2px 0 #922b21,
    3px 3px 5px rgba(0, 0, 0, 0.6);
}

渐变边框

此演示仅在桌面端浏览器中可用

css
/* 渐变边框必须同时满足:border-width + border-style + border-image: 渐变 1 */
.gradient-border {
  padding: 20px;
  border: 4px solid;
  border-image: linear-gradient(45deg, #ff6b6b, #4ecdc4) 1;
  border-radius: 8px;
  background: white;
}

.gradient-border-2 {
  padding: 20px;
  background: linear-gradient(white, white) padding-box, linear-gradient(
        45deg,
        #ff6b6b,
        #4ecdc4
      ) border-box;
  border: 4px solid transparent;
  border-radius: 8px;
}

文字溢出省略

此演示仅在桌面端浏览器中可用

css
/* 单行文字溢出省略 */
.single-line-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 多行文字溢出省略 */
.multi-line-ellipsis {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

自定义选择文本样式

此演示仅在桌面端浏览器中可用

css
/* 自定义选择文本样式 */
::selection {
  background-color: #ff6b6b;
  color: #fff;
}

滤镜效果

此演示仅在桌面端浏览器中可用

css
.image-filters {
  transition: filter 0.3s ease;
}

/* 灰度效果 */
.grayscale {
  filter: grayscale(100%);
}

.grayscale:hover {
  filter: grayscale(0%);
}

/* 多个滤镜组合 */
.multiple-filters {
  filter: brightness(1.2) contrast(0.8) saturate(1.5);
}

/* 模糊效果 */
.blur-effect {
  filter: blur(2px);
}
#Css