CSS3 4个带方向箭头的标注框

本文介绍如何使用 CSS3 实现带有指向指示器的 callouts 动画效果,包括底部、顶部、左侧和右侧的指向箭头,并通过关键帧动画实现平滑过渡。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

html:
<script src="http://wow.techbrood.com/libs/jquery/jquery-1.11.1.min.js"></script>
<div style="width:100%;overflow:hidden;background-color:#FFF;">
    <h1 class="title-style text--center">Css3 callouts</h1>
    <div class="wrap">
        <div class="box pointer--bottom">
            <p class="text--center">Pointer bottom</p>
        </div>
        <div class="box pointer--top">
            <p class="text--center">Pointer top</p>
        </div>
        <div class="box pointer--left">
            <p class="text--center">Pointer left</p>
        </div>
        <div class="box pointer--right">
            <p class="text--center">Pointer right</p>
        </div>
    </div>
</div>
CSS:
.text--center {
    text-align: center;
}
.wrap {
    padding-left: 7%;
}
.title-style {
    font-weight: 100;
    font-size: 3em;
    color: #346BB3;
}
.box {
    width: 32.40741%;
    float: left;
    margin-left: 0.46296%;
    margin-right: 0.46296%;
    position: relative;
    background: #346BB3;
    color: #fff;
    padding: 1%;
    margin: 5%;
    white-space: nowrap;
    border-radius: 5px;
}
.box:after {
    content: " ";
    position: absolute;
    height: 0;
    width: 0;
    border: solid transparent;
    pointer-events: none;
    border-width: 16px;
    border-color: #fff;
}
.pointer--bottom {
    animation: animimate-pointer--bottom 500ms ease-in-out;
    animation-transform-origin: bottom center;
}
.pointer--bottom:after {
    margin-left: -16px;
    border-top-color: #346BB3;
    top: 100%;
    left: 50%;
}
.pointer--top {
    animation: animimate-pointer--top 500ms ease-in-out;
    transform-origin: top center;
}
.pointer--top:after {
    margin-left: -16px;
    border-bottom-color: #346BB3;
    top: -32px;
    left: 50%;
}
.pointer--left {
    animation: animate-pointer--left 500ms ease-in-out;
    transform-origin: left center;
}
.pointer--left:after {
    border-right-color: #346BB3;
    top: 25%;
    left: -32px;
}
.pointer--right {
    animation: animate-pointer--right 500ms ease-in-out;
    transform-origin: right center;
}
.pointer--right:after {
    border-left-color: #346BB3;
    top: 25%;
    right: -32px;
}
@keyframes animimate-pointer--bottom {
    0% {
        opacity: 0;
        transform: scale(0.1) rotate(30deg) translateY(50px) rotateX(90deg);
    }
    50% {
        transform: rotate(-10deg) rotateX(-2deg);
        opacity: 1;
    }
    70% {
        transform: rotate(3deg);
    }
    100% {
        transform: scale(1);
    }
}
@keyframes animimate-pointer--top {
    0% {
        transform: scale(0.1) rotate(-30deg) translateY(-50px) rotateX(-90deg);
        opacity: 0;
    }
    50% {
        transform: rotate(10deg) rotateX(2deg);
        opacity: 1;
    }
    70% {
        transform: rotate(-3deg);
    }
    100% {
        transform: scale(1);
    }
}
@keyframes animate-pointer--left {
    0% {
        transform: rotate(0deg) rotateX(-30deg);
        opacity: 0;
    }
    50% {
        transform: rotate(-10deg);
        opacity: 1;
    }
    70% {
        transform: rotate(10deg) rotateX(30deg);
    }
    100% {
        transform: rotate(0deg);
    }
}
@keyframes animate-pointer--right {
    0% {
        transform: rotate(0deg) rotateX(30deg);
        opacity: 0;
    }
    50% {
        transform: rotate(10deg);
        opacity: 1;
    }
    70% {
        transform: rotate(-10deg) rotateX(-30deg);
    }
    100% {
        transform: rotate(0deg);
    }
}
/* work in progress */

<think>我们正在设计一个有汉语连读技巧标注的网页。根据用户需求,我们需要实现一个能够展示汉语连读技巧(如变调、轻声、儿化等)的标注系统。以下是一些技术建议和实现方法: ### 1. 前端设计 - **标注界面**:使用HTML/CSS/JavaScript构建用户界面,可考虑使用现代前端框架(如Vue.js、React)提高开发效率。 - **文本输入区**:用户输入或粘贴需要标注的汉语句子。 - **标注展示区**:将标注后的文本以可视化形式展示(如不同颜色标记不同连读现象)。 - **交互控件**:提供标注工具(如选择连读类型、手动调整标注范围等)。 ### 2. 连读规则处理 - **规则库**:建立汉语连读规则库(例如:上声变调、“一”和“不”的变调、轻声规则等)。 - **自动标注引擎**:开发一个基于规则的自动标注引擎(或结合机器学习模型),对输入的文本进行连读分析。 - 示例规则:当两个上声字连续出现时,第一个字变为阳平(如“你好”→$n\acute{i}h\check{a}o$ → $n\acute{i}h\acute{a}o$)。 ### 3. 标注表示方法 - **内联标注**:在文本上方或下方添加标注符号(类似拼音注音),例如: - 你好 → <ruby>你<rt>ní</rt></ruby><ruby>好<rt>hǎo</rt></ruby>(正常拼音) - 连读标注:<ruby>你<rt>ní</rt></ruby><ruby>好<rt>háo</rt></ruby>(变调) - **符号系统**:使用国际音标(IPA)或自定义符号系统表示连读变化(如箭头表示变调方向)。 ### 4. 技术实现 - **后端服务**(可选):如果规则复杂或需要大量计算,可使用Python/Node.js等搭建后端服务,提供标注API。 - **纯前端实现**:若规则简单,可将规则库嵌入前端JavaScript直接处理。 ### 5. 示例代码(纯前端简化版) ```html <!DOCTYPE html> <html> <head> <title>汉语连读标注工具</title> <style> .annotated-text { font-size: 24px; } ruby rt { font-size: 12px; color: blue; } .tone-change rt { color: red; } /* 变调用红色标注 */ </style> </head> <body> <textarea id="inputText" rows="4" cols="50">你好,我想买一个苹果。</textarea> <button onclick="annotate()">标注连读</button> <div id="output" class="annotated-text"></div> <script> // 连读规则库(简化示例) const toneRules = [ { pattern: "你好", pronunciation: "ní hǎo", sandhi: "ní háo" }, { pattern: "一个", pronunciation: "yī gè", sandhi: "yí gè" } ]; function annotate() { const text = document.getElementById("inputText").value; let outputHtml = ""; // 简单分词(实际需用更精确的分词库) const words = text.split(/[,。\s]/).filter(w => w); words.forEach(word => { const rule = toneRules.find(r => word.includes(r.pattern)); if (rule) { // 标注连读变化 outputHtml += `<span class="tone-change"><ruby>${word}<rt>${rule.sandhi}</rt></ruby></span> `; } else { // 正常拼音(此处简化,实际需汉字转拼音) outputHtml += `<ruby>${word}<rt>${word}</rt></ruby> `; } }); document.getElementById("output").innerHTML = outputHtml; } </script> </body> </html> ``` ### 6. 进阶优化 - **集成拼音转换**:使用开源库(如pinyin.js)实现汉字自动转拼音。 - **机器学习辅助**:对复杂连读现象(如轻声识别),可训练序列标注模型(CRF/BiLSTM)。 - **用户自定义规则**:允许用户添加/修改连读规则。 §§相关问题§§ 1. 汉语连读规则有哪些常见类型? 2. 如何实现汉字到拼音的自动转换? 3. 有哪些开源工具可用于语音标注? 4. 如何在前端高效地处理中文文本的分词? 5. 如何设计一个允许用户交互式修改标注的系统?</think>### 汉语连读技巧标注网页设计指南 #### 1. 核心功能设计 - **标注可视化** - 使用颜色编码区分不同连读类型:轻声(灰色)、变调(橙色)、儿化(粉色)、省音(蓝色) - 示例:`我们 → 我<em style="color:orange">们</em>`(上声变调) - **交互式标注** ```html <div class="annotation-tool"> <button data-type="tone-change">变调标注</button> <button data-type="erhua">儿化标注</button> <button data-type="reduction">省音标注</button> </div> ``` #### 2. 技术实现方案 - **前端框架** - 使用Vue.js/React实现动态标注 - 集成开源拼音库(如pinyin.js)实现汉字转拼音 $$ \text{汉字} \xrightarrow{\text{pinyin.js}} \text{pīn yīn $$ - **连读规则引擎** ```javascript // 变调规则示例 function applyToneSandhi(text) { return text.replace(/([你我他])们/g, &#39;<span class="tone-change">$1们</span>&#39;); } ``` - **标注数据结构** ```json { "original": "一会儿", "annotated": "一<annot type=&#39;reduction&#39;>会</annot>儿", "pinyin": "yī huìr", "ruleId": "ERHUA_REDUCTION" } ``` #### 3. 关键组件实现 - **标注编辑器** ```html <div contenteditable id="text-editor"> 请输入要标注的句子... </div> <div id="annotation-preview"> <!-- 动态生成标注的文本 --> </div> ``` - **连读规则库** | 类型 | 规则表达式 | 示例 | |------------|------------------|---------------| | 轻声 | \b(的|了|着)\b | 好的 → 好的 | | 上声变调 | 我[们] | 我们 → 我们 | | 儿化音 | \w+(?=儿) | 一会儿 → 会儿 | #### 4. 进阶功能建议 1. **语音同步标注** - 集成Web Speech API实现语音输入 - 波形图显示+时间轴对齐标注 2. **规则自定义系统** ```javascript // 用户自定义规则接口 app.registerRule({ name: "自定义连读", pattern: /你的正则/, apply: (match) => `<span class="custom">${match}</span>` }); ``` 3. **教学辅助功能** - 连读对比播放:正常语速 vs 慢速分解 - 错误标注检测:常见连读错误提示 #### 5. 技术栈推荐 - **前端**:Vue3 + Tailwind CSS - **拼音转换**:pinyin-pro库 - **语音处理**:Web Audio API - **持久化**:IndexedDB(存储用户标注记录) - **构建工具**:Vite
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值