当前位置:首页 > CSS

CSS模板制作雪糕

2026-04-02 10:28:11CSS

使用CSS绘制雪糕图形

通过CSS的border-radiusgradientbox-shadow属性可以创建一个逼真的雪糕图形。以下是一个完整的示例代码:

CSS模板制作雪糕

<!DOCTYPE html>
<html>
<head>
    <style>
        .ice-cream {
            width: 120px;
            height: 180px;
            position: relative;
            margin: 50px auto;
        }

        .cone {
            width: 60px;
            height: 90px;
            background: linear-gradient(to bottom, #f4a460, #d2691e);
            border-radius: 0 0 30px 30px;
            position: absolute;
            bottom: 0;
            left: 30px;
        }

        .scoop {
            width: 100px;
            height: 100px;
            background: linear-gradient(to bottom, #ff6b6b, #d63031);
            border-radius: 50%;
            position: absolute;
            top: 0;
            left: 10px;
            box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        }

        .scoop::before {
            content: "";
            width: 20px;
            height: 20px;
            background: white;
            border-radius: 50%;
            position: absolute;
            top: 20px;
            left: 30px;
            opacity: 0.7;
        }
    </style>
</head>
<body>
    <div class="ice-cream">
        <div class="cone"></div>
        <div class="scoop"></div>
    </div>
</body>
</html>

添加动画效果

为雪糕添加融化动画效果:

CSS模板制作雪糕

.scoop {
    animation: melt 3s infinite alternate;
}

@keyframes melt {
    0% {
        transform: scaleY(1);
    }
    100% {
        transform: scaleY(0.9) scaleX(1.05);
        border-radius: 50% 50% 30% 30%;
    }
}

多色雪糕球实现

创建多个不同颜色的雪糕球层叠效果:

<style>
    .scoop-top {
        width: 90px;
        height: 90px;
        background: linear-gradient(to bottom, #fdcb6e, #e17055);
        border-radius: 50%;
        position: absolute;
        top: -30px;
        left: 15px;
        z-index: 3;
    }

    .scoop-middle {
        width: 100px;
        height: 100px;
        background: linear-gradient(to bottom, #a29bfe, #6c5ce7);
        border-radius: 50%;
        position: absolute;
        top: 0;
        left: 10px;
        z-index: 2;
    }

    .scoop-bottom {
        width: 110px;
        height: 110px;
        background: linear-gradient(to bottom, #00b894, #008066);
        border-radius: 50%;
        position: absolute;
        top: 30px;
        left: 5px;
        z-index: 1;
    }
</style>

<div class="ice-cream">
    <div class="cone"></div>
    <div class="scoop-bottom"></div>
    <div class="scoop-middle"></div>
    <div class="scoop-top"></div>
</div>

添加装饰元素

为雪糕添加糖粒和巧克力碎片装饰:

.decorations {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 4;
}

.sprinkle {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    position: absolute;
}

.sprinkle:nth-child(1) { top: 20px; left: 30px; }
.sprinkle:nth-child(2) { top: 30px; left: 50px; background: #fdcb6e; }
.sprinkle:nth-child(3) { top: 40px; left: 20px; background: #a29bfe; }
.sprinkle:nth-child(4) { top: 50px; left: 70px; }
.sprinkle:nth-child(5) { top: 60px; left: 40px; background: #00b894; }

标签: 雪糕模板
分享给朋友:

相关文章

vue实现a4打印模板

vue实现a4打印模板

Vue 实现 A4 打印模板 页面布局与样式设置 设置 A4 纸张尺寸(210mm × 297mm)的打印样式,通过 CSS 确保打印内容适配纸张。在 Vue 组件的 <style> 标签…

elementui模板

elementui模板

ElementUI 模板使用指南 ElementUI 是一个基于 Vue.js 的组件库,提供丰富的 UI 组件,适用于快速开发中后台管理系统。以下是 ElementUI 模板的常见用法和资源推荐。…

css制作固定模板

css制作固定模板

固定布局的基本方法 使用CSS的position: fixed属性可以将元素固定在视口的某个位置,不受页面滚动影响。固定布局常用于导航栏、侧边栏或悬浮按钮。 .fixed-element { p…

制作css模板

制作css模板

理解CSS模板的基本概念 CSS模板是一组预定义的样式规则,用于快速统一网站或应用的外观。通常包含颜色、字体、布局等基础样式,可通过复用减少重复代码。 设计模板的结构 将CSS模板分为模块化部分…

CSS模板制作表格

CSS模板制作表格

CSS表格基础结构 HTML表格由<table>标签定义,包含<tr>(行)、<th>(表头)和<td>(单元格)。基础结构如下: <table…

用css制作模板

用css制作模板

使用CSS创建模板的方法 CSS模板可以通过多种方式实现,以下是几种常见的方法: 定义基础样式 在CSS文件中设置全局样式,包括字体、颜色、间距等。例如: body { font-family…