当前位置:首页 > CSS

css制作熊大

2026-03-12 12:52:43CSS

使用CSS绘制熊大

通过CSS的border-radiusbox-shadow和伪元素等属性,可以绘制卡通形象的熊大。以下是实现步骤:

HTML结构

css制作熊大

<div class="bear">
  <div class="ear left-ear"></div>
  <div class="ear right-ear"></div>
  <div class="face">
    <div class="eye left-eye"></div>
    <div class="eye right-eye"></div>
    <div class="nose"></div>
    <div class="mouth"></div>
  </div>
</div>

CSS样式

css制作熊大

.bear {
  position: relative;
  width: 200px;
  height: 180px;
  background-color: #8B4513;
  border-radius: 50% 50% 45% 45%;
  margin: 50px auto;
}

.ear {
  position: absolute;
  width: 50px;
  height: 50px;
  background-color: #5D2E0F;
  border-radius: 50%;
  top: -15px;
}

.left-ear {
  left: 30px;
}

.right-ear {
  right: 30px;
}

.face {
  position: absolute;
  width: 150px;
  height: 120px;
  background-color: #A0522D;
  border-radius: 50%;
  top: 50px;
  left: 25px;
}

.eye {
  position: absolute;
  width: 20px;
  height: 25px;
  background-color: #000;
  border-radius: 50%;
  top: 40px;
}

.left-eye {
  left: 40px;
}

.right-eye {
  right: 40px;
}

.nose {
  position: absolute;
  width: 30px;
  height: 20px;
  background-color: #000;
  border-radius: 50%;
  top: 60px;
  left: 60px;
}

.mouth {
  position: absolute;
  width: 60px;
  height: 20px;
  border-bottom: 3px solid #000;
  border-radius: 0 0 50% 50%;
  top: 80px;
  left: 45px;
}

添加动画效果

通过CSS动画让熊大更生动:

.bear {
  animation: sway 3s infinite alternate;
}

@keyframes sway {
  from { transform: rotate(-5deg); }
  to { transform: rotate(5deg); }
}

.eye::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: white;
  border-radius: 50%;
  top: 5px;
  left: 5px;
  animation: blink 4s infinite;
}

@keyframes blink {
  0%, 48%, 52%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.1); }
}

响应式调整

通过媒体查询适配不同屏幕:

@media (max-width: 600px) {
  .bear {
    width: 150px;
    height: 135px;
  }
  .face {
    width: 112px;
    height: 90px;
    top: 38px;
    left: 19px;
  }
}

最终效果会呈现一个棕色卡通熊形象,包含耳朵、眼睛、鼻子和嘴巴等特征元素,并有轻微的摇摆和眨眼动画。颜色和尺寸可根据实际需求调整。

标签: css
分享给朋友:

相关文章

css制作菜单

css制作菜单

水平菜单制作 使用display: inline-block或flexbox布局创建水平菜单。设置list-style: none移除默认列表样式,添加padding和margin调整间距。 <…

css 导航栏制作

css 导航栏制作

水平导航栏制作 使用无序列表<ul>和<li>标签构建基础结构,通过CSS将列表项横向排列 <nav> <ul class="horizontal-na…

css制作六边形

css制作六边形

使用CSS创建六边形的方法 通过CSS的clip-path属性可以轻松实现六边形效果。以下是一个基础示例: .hexagon { width: 100px; height: 55px;…

css页脚制作

css页脚制作

CSS页脚制作方法 固定定位页脚 使用position: fixed将页脚固定在页面底部,适用于需要始终显示的页脚。 footer { position: fixed; bottom: 0;…

css右导航栏制作

css右导航栏制作

CSS右导航栏制作方法 固定定位法 使用position: fixed将导航栏固定在视窗右侧,结合right和top属性控制位置。示例代码: .right-navbar { position:…

制作css选择器

制作css选择器

CSS选择器基础语法 CSS选择器用于定位HTML文档中的元素,以便为其应用样式。常见的基础选择器包括: 元素选择器:直接使用HTML标签名(如p、div) 类选择器:以.开头(如.header)…