vue3中css使用script中定义的变量

代码

javascript 复制代码
<template>
  <div class="box">haha</div>
</template>

<script setup lang="ts">
const boxWidth = '500px'
</script>

<style lang="scss">
.box {
  width: v-bind(boxWidth);
  height: 200px;
  background-color: red;
}
</style>

效果

相关推荐
labixiong1 小时前
告别scroll 监听:CSS 滚动驱动动画,主线程堵死也仍跟手
前端·css·html
King of fraud7 小时前
HTML 页面的 CSS 选择器详解
前端·css·html
我的div丢了肿么办7 小时前
grid布局justify-items和align-items、justify-content和align-content
前端·css
BillKu1 天前
全局样式变量:CSS 自定义属性(--border-color)和SCSS 变量($border-color)的说明
javascript·css·scss
兜里只有三分钱~1 天前
翻卡_3D 的仪式感,和三个让它穿帮的写法
javascript·css·3d
Beyond_System|系统之外1 天前
一个网页如何同时适配投影仪、1366×768 和 1920×1080?我重新理解了“自适应布局”
开发语言·css·html
Claire_881 天前
从零搭建网页:我用AI生成HTML/CSS/JS的实践与工具整理
css·人工智能·html
平头哥~1 天前
Day 21 | animation 与 keyframes:把动画从 A 到 B 变成多点编排
前端·css·css3·css学习
里欧跑得慢2 天前
Flutter主题与样式详解
前端·css·flutter·web
toooooop82 天前
智慧文旅数字人体验平台demo html
css·css3