当前位置:首页 > CSS

css制作静态气泡

2026-04-02 00:34:55CSS

使用CSS制作静态气泡效果

气泡效果常见于聊天界面或提示框,通过CSS的border-radiusbox-shadow和伪元素实现。

基础气泡结构

css制作静态气泡

<div class="bubble">Hello, this is a bubble!</div>

圆形气泡样式

.bubble {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: #4CAF50;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

对话框气泡样式

css制作静态气泡

.bubble {
  position: relative;
  max-width: 200px;
  padding: 12px;
  background: #f1f1f1;
  border-radius: 10px;
  margin: 20px;
}

.bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 20px;
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: #f1f1f1 transparent;
}

添加阴影和渐变效果

.bubble {
  background: linear-gradient(135deg, #6e8efb, #a777e3);
  box-shadow: 0 3px 5px rgba(0,0,0,0.2);
  color: white;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

多个气泡排列示例

.bubble-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.bubble.left {
  align-self: flex-start;
}

.bubble.right {
  align-self: flex-end;
  background: #0084ff;
}

.bubble.right::after {
  left: auto;
  right: 20px;
  border-color: #0084ff transparent;
}

这些CSS代码片段可以组合使用,通过调整尺寸、颜色和定位创建各种静态气泡效果。

标签: 气泡静态
分享给朋友:

相关文章

vue实现页面静态化

vue实现页面静态化

Vue 实现页面静态化的方法 使用 Nuxt.js 进行静态化生成 Nuxt.js 是一个基于 Vue 的框架,支持静态化生成(Static Site Generation, SSG)。通过配置 nu…

如何将react打包成静态页面

如何将react打包成静态页面

使用 Create React App 构建 React 项目可以通过 create-react-app 工具快速生成,并内置了打包功能。运行以下命令生成生产环境代码: npm run build…

smarty实现php静态化

smarty实现php静态化

Smarty 实现 PHP 静态化方法 使用 Smarty 的 fetch 方法生成静态文件 通过 Smarty 的 fetch 方法获取模板渲染后的内容,再将其写入静态文件。 $smarty =…

js实现气泡

js实现气泡

实现气泡效果的方法 使用CSS和JavaScript可以轻松创建气泡效果。以下是一个简单的实现方法: // 创建气泡元素 const bubble = document.createElement(…

uniapp提示气泡

uniapp提示气泡

uniapp 实现提示气泡的方法 在 uniapp 中实现提示气泡(Tooltip)效果,可以通过以下几种方式实现: 使用 uni.showToast API uni.showToast 是 uni…

vue实现静态博客

vue实现静态博客

Vue 实现静态博客的方法 使用 Vue 实现静态博客可以通过多种方式完成,以下是几种常见的方法: 使用 VuePress VuePress 是一个基于 Vue 的静态网站生成器,非常适合构建博客或…