获取html跟节点的font-size

本文介绍了一种通过JavaScript获取HTML文档根元素字体大小的方法。使用getComputedStyle(window.document.documentElement)['font-size']可以轻松实现这一目标。

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

getComputedStyle(window.document.documentElement)['font-size']
 
<template> <view class="container"> <view class="title"> <view class="headSpan">照明</view> <view class="lineSpan">行业智能供应链</view> </view> <view class="search-top search-normal"> <view class="search-box"> <input placeholder="请输入" type="text" v-model="searchText" /> </view> </view> <IndustryData></IndustryData> </view> </template> <script setup> import IndustryData from "@/components/IndustryData.vue" import { ref } from 'vue'; let searchText = ref('') </script> <style lang="scss"> @import "../../static/scss/publicContainer.scss"; $boxs-margin: 10px; //每个盒子之前的margin距离 .title { text-align: center; font-family: "PangMenZhengDao"; font-style: normal; display: flex; flex-direction: column; height: 50px; .headSpan { font-family: "PangMenZhengDao"; display: flex; width: 88px; height: 25px; flex-direction: column; justify-content: center; font-size: 22px; font-weight: 800; line-height: 22px; letter-spacing: 2.4px; background: linear-gradient(90deg, #E9BC82 12.5%, #FFEECB 51.09%, #E9BC82 89.67%); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .lineSpan { display: flex; width: 88px; height: 15px; flex-direction: column; justify-content: center; flex-shrink: 0; font-family: "PangMenZhengDao"; font-size: 10px; font-weight: 800; line-height: 12px; letter-spacing: 1px; background: linear-gradient(90deg, #E9BC82 12.5%, #FFEECB 51.09%, #E9BC82 89.67%); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; } } .search-top { position: sticky; top: calc(var(--status-bar-height) + $marginHead + $boxs-margin); } .search-normal { width: 65vw; } .search-box { display: flex; padding: 6px 12px; height: 28px; align-items: center; flex: 1 0 0; align-self: stretch; border-radius: 30px; background-color: #E6E6E6; color: black; z-index: 999; margin: $boxs-margin auto; } </style> 帮我修改代码,做到sticky触发的时候searchbox宽度为width: 65vw;,但是正常时候是100
06-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值