style="direction:inherit"的作用

本文介绍CSS中direction属性的作用及用法,包括ltr、rtl和inherit三个取值的意义,并解释了这些选项如何影响文本的流向。此外还提到了unicode-bidi属性的应用场景。

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

语法:direction : ltr | rtl | inherit

取值:

ltr : 默认值。文本从左到右流入

rtl : 文本从右到左流入

inherit : 文本流入方向由继承获得

说明:

用于设置文本流入的方向。请参阅对象的 dir 属性。

此属性不会影响拉丁文的字母数字字符,它们总是以 ltr 值被呈递。

但是此属性会作用于拉丁文的标点符号。假如您想应用此属性于内联文本,您必须设定 unicode-bidi 属性为 embed 或 bidi-override 。

此属性对于 currentStyle 对象而言是只读的。对于其他对象而言是可读写的。对应的脚本特性为 direction 。

<template> <div class="home"> <p>DeepSeek V3二次接入(0.5元/百万tokens)</p> <!-- 显示回复 --> <div class="response-area"> <div v-if="error" class="error">{{ error }}</div> <pre v-else-if="reply">{{ reply }}</pre> <div v-else class="placeholder">当前版本:DeepSeek V3</div> </div> <div class="input-area"> <textarea v-model="inputText" @keydown.enter.prevent="handleEnter" maxlength="500" placeholder="请输入您的问题(Shift+Enter换行)" rows="4"></textarea> <div class="counter">{{ inputText.length }}/500</div> <button @click="sendRequest" :disabled="loading"> {{ loading ? '请求中...' : '发送' }} </button> </div> </div> </template> <script setup lang="ts"> import { ref } from 'vue' import OpenAI from "openai"; // 初始化 OpenAI 客户端 const openai = new OpenAI({ baseURL: 'https://api.deepseek.com', apiKey: 'sk-41bf7dd7e3de48fe929bdee673bac3cb', dangerouslyAllowBrowser: true }); // 响应式数据 const inputText = ref('') const reply = ref('') const loading = ref(false) const error = ref('') const handleEnter = (event: KeyboardEvent) => { if (!event.shiftKey) { sendRequest(); } else { inputText.value += '\n'; } }; // 发送请求方法 const sendRequest = async () => { if (!inputText.value.trim() || loading.value) return try { loading.value = true error.value = '' const completion = await openai.chat.completions.create({ messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: inputText.value } ], model: "deepseek-chat", }); const content = completion.choices[0].message.content reply.value = content ? content : '' } catch (err) { let message = '未知错误' if (err instanceof Error) { message = err.message } else if (typeof err === 'string') { message = err } error.value = `请求失败: ${message}` reply.value = '' } finally { loading.value = false } } </script> <style scoped> .home { display: flex; flex-direction: column; gap: 20px; padding: 20px; max-width: 100%; max-height: 100%; margin: 0 auto; } .input-area { position: relative; display: flex; flex-direction: column; gap: 10px; } textarea { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 6px; resize: vertical; min-height: 100px; max-height: 300px; overflow-y: auto; font-family: inherit; } .counter { position: absolute; right: 15px; bottom: 50px; color: #666; font-size: 0.8em; background: rgba(255, 255, 255, 0.9); padding: 2px 5px; border-radius: 3px; } input { flex: 1; padding: 10px; border: 1px solid #ccc; border-radius: 4px; } button:disabled { background: #ccc; cursor: not-allowed; } .response-area { border: 1px solid #eee; padding: 20px; border-radius: 4px; min-height: 100px; } button { align-self: flex-end; padding: 10px 30px; transition: background 0.3s ease; } button:hover:not(:disabled) { background: #0056b3; } pre { line-height: 1.6; font-family: 'Courier New', Courier, monospace; } .error { color: #dc3545; padding: 10px; background: #f8d7da; border-radius: 4px; } .placeholder { color: #6c757d; opacity: 0.6; } .response-area { max-height: 400px; overflow-y: auto; border: 1px solid #eee; padding: 20px; border-radius: 8px; background: #f9f9f9; } /* 自定义滚动条样式 */ ::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; } ::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; } ::-webkit-scrollbar-thumb:hover { background: #666; } </style> 页面通过<RouterLink被切换之后原先内容会被清空,请修改,使其保留
03-08
<div class="nav"> <ul> <li class="menu">首页 <ul class="subMenu"> <li><a href="https://www.csgo.com.cn/main.html">游戏官网</a></li> <li><a href="https://www.pwesports.cn/association">高校电竞社</a></li> <li><a href="https://csgo.wanmei.com/communityserver">社区中心</a></li> </ul> </li> <li class="menu"><a href="#">充值</a></li> <li class="menu">新闻 <ul class="subMenu"> <li><a href="https://www.csgo.com.cn/activity/index.html">活动中心</a></li> <li><a href="https://www.csgo.com.cn/match">赛事中心</a></li> <li><a href="https://www.csgo.com.cn/news/index.html">新闻中心</a></li> </ul> </li> <li class="menu"><a href="#">赛事</a></li> <li class="menu">资料 <ul class="subMenu"> <li><a href="https://www.csgo.com.cn/hd/1704/newerguide/index.html">新手指南</a></li> <li><a href="https://www.csgo.com.cn/hd/1610/info/index.html">官方资料站</a></li> <li><a href="https://www.csgo.com.cn/show">游戏特色</a></li> </ul> </li> <li class="menu"><a href="//wmsjdj.tmall.com/category-1465876517.htm">商城</a></li> <li class="menu">服务 <ul class="subMenu"> <li><a href="https://www.csgo.com.cn/faq/index.html">常见问题</a></li> <li><a href="javascript:void(0);">客服支持</a></li> <li><a href="#">礼包码兑换</a></li> </ul> </li> <li class="menu">注册 <ul class="subMenu"> <li><a href="#">游戏下载</a></li> <li><a href="#">账户注册</a></li> </ul> </li> </ul> </div> /* 导航栏样式 */ /* 基础样式 */ .nav { width: 100%; height: 55px; background-color: #3498db; /* 灰蓝色背景 */ height: 50px; } .nav ul { list-style-type: none; margin: 0; padding: 0; display: flex; /* 横向布局 */ justify-content: flex-start; /* 菜单项 */ } .nav li.menu { position: relative; /* 设置相对定位以便子菜单定位 */ padding: 15px 40px; /* 菜单项内边距 */ cursor: pointer; text-align: center; /* 文本居中 */ color: white; /* 默认字体颜色为白色 */ } .nav li.menu:hover { background-color: white; /* 鼠标悬停时背景变为白色 */ color: black; /* 鼠标悬停时字体颜色变为灰蓝色 */ } .nav li.menu a { text-decoration: none; /* 去掉链接下划线 */ color: white; /* 链接默认颜色为白色 */ } .nav li.menu a:hover { color: #3498db; /* 链接悬停时颜色变为灰蓝色 */ } /* 二级菜单样式 */ .subMenu { display: none; /* 默认隐藏二级菜单 */ position: absolute; /* 绝对定位以确保在父菜单下方显示 */ top: 100%; /* 在父菜单正下方显示 */ left: 0; background-color: #3498db; /* 灰蓝色背景 */ width: 110px; /* 二级菜单宽度 */ z-index: 1000; /* 确保二级菜单在其他内容之上 */ } .subMenu li { padding: 10px; /* 二级菜单项内边距 */ color: white; /* 默认字体颜色为白色 */ text-align: left; /* 二级菜单文本左对齐 */ } .subMenu li:hover { background-color: orange; /* 鼠标悬停时背景变为白色 */ color: #3498db; /* 鼠标悬停时字体颜色变为灰蓝色 */ } /* 鼠标悬停时显示二级菜单 */ .menu:hover .subMenu { display: block; /* 显示二级菜单 */ } 没有实现打开网页二级菜单默认隐藏,修改代码给出实现二级菜单默认隐藏只有鼠标悬停才显示二级菜单,给出HTML,CSS,JS文件
最新发布
06-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值