<div>的默认字体

昨天遇到了个问题,用<div>...</div>总是显示不出来,刚从eclipse转到web开发还真有点不适应,郁闷ing~,后来问了同事,于是说div默认的字体非常小,小到足以让人不能看见,oh my god!原来这样,于是乎给div加了css设置了字体。于是乎就出来了~

做web页面很有趣,慢慢积累吧!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<template> <div class="Home"> <div class="index" id="mapTree"></div> <div class="top"> <div class="topLeft"> <div v-bind:class="{ redText: buttonStyle['Rail'], }" @click="toggleComponent('Rail')" > <a>电子围栏</a> </div> <div v-bind:class="{ redText: buttonStyle['Video'], }" @click="toggleComponent('Video')" > 视频监控 </div> <div v-bind:class="{ redText: buttonStyle['Location'], }" @click="toggleComponent('Location')" > 实时定位 </div> <div v-bind:class="{ redText: buttonStyle['Monitor'], }" @click="toggleComponent('Monitor')" > 环境检测 </div> </div> <div class="topRight"> <div>2</div> <div>2</div> <div>2</div> <div>2</div> </div> </div> <Rail v-if="currentComponent === 'Rail'" /> <Video v-if="currentComponent === 'Video'" /> <Location v-if="currentComponent === 'Location'" /> <Monitor v-if="currentComponent === 'Monitor'" /> </div> </template> <script> import Rail from "@/views/rail/rail.vue"; import Video from "@/views/video/video.vue"; import Location from "@/views/location/location.vue"; import Monitor from "@/views/monitor/monitor.vue"; let viewer; Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYzc0OGZjYi03NDY5LTRmMmQtYTc2YS05ZTY2YzZlMTRmYTQiLCJpZCI6MTM5MzQ0LCJpYXQiOjE2ODQzMTI2MjF9.nNF8IyvsjDSdeRJeea8ftf4TC1DOgSa_jue-ZZ0dZ8M"; export default { name: "MineHome", components: { Rail, Video, Location, Monitor, }, data() { return { currentComponent: "Rail", currentTab: "", // 记录当前选中的按钮 buttonStyle: { // 记录按钮样式 Rail: true, Video: false, Location: false, Monitor: false, }, }; }, mounted() { this.toggleComponent("Rail"); this.initMap(); }, methods: { // 初始化地图 initMap() { viewer = new Cesium.Viewer("mapTree", { infoBox: false, // 禁用infoBox }); // 加载倾斜模型 var tileset = new Cesium.Cesium3DTileset({ url: "http://47.104.159.54:8156/out2/tileset.json", }); viewer.scene.primitives.add(tileset); viewer.zoomTo(tileset); }, toggleComponent(componentName) { this.currentComponent = componentName; }, }, }; 根据这段代码实现 默认选中按钮字体颜色为红色 非选中为白色
最新发布
06-09
可以在 `buttonStyle` 对象中设置每个按钮的默认样式,然后在模板中使用 `v-bind:class` 绑定样式类即可。可以尝试以下代码: ```html <template> <div class="Home"> <div class="index" id="mapTree"></div> <div class="top"> <div class="topLeft"> <div :class="{ redText: buttonStyle['Rail'] }" @click="toggleComponent('Rail')" > <a>电子围栏</a> </div> <div :class="{ redText: buttonStyle['Video'] }" @click="toggleComponent('Video')" > <a>视频监控</a> </div> <div :class="{ redText: buttonStyle['Location'] }" @click="toggleComponent('Location')" > <a>实时定位</a> </div> <div :class="{ redText: buttonStyle['Monitor'] }" @click="toggleComponent('Monitor')" > <a>环境检测</a> </div> </div> <div class="topRight"> <div>2</div> <div>2</div> <div>2</div> <div>2</div> </div> </div> <Rail v-if="currentComponent === 'Rail'" /> <Video v-if="currentComponent === 'Video'" /> <Location v-if="currentComponent === 'Location'" /> <Monitor v-if="currentComponent === 'Monitor'" /> </div> </template> <script> import Rail from "@/views/rail/rail.vue"; import Video from "@/views/video/video.vue"; import Location from "@/views/location/location.vue"; import Monitor from "@/views/monitor/monitor.vue"; let viewer; Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYzc0OGZjYi03NDY5LTRmMmQtYTc2YS05ZTY2YzZlMTRmYTQiLCJpZCI6MTM5MzQ0LCJpYXQiOjE2ODQzMTI2MjF9.nNF8IyvsjDSdeRJeea8ftf4TC1DOgSa_jue-ZZ0dZ8M"; export default { name: "MineHome", components: { Rail, Video, Location, Monitor, }, data() { return { currentComponent: "Rail", currentTab: "", // 记录当前选中的按钮 buttonStyle: { // 记录按钮样式 Rail: true, Video: false, Location: false, Monitor: false, }, }; }, mounted() { this.toggleComponent("Rail"); this.initMap(); }, methods: { // 初始化地图 initMap() { viewer = new Cesium.Viewer("mapTree", { infoBox: false, // 禁用infoBox }); // 加载倾斜模型 var tileset = new Cesium.Cesium3DTileset({ url: "http://47.104.159.54:8156/out2/tileset.json", }); viewer.scene.primitives.add(tileset); viewer.zoomTo(tileset); }, toggleComponent(componentName) { this.currentComponent = componentName; // 更新按钮样式 for (let key in this.buttonStyle) { this.buttonStyle[key] = key === componentName; } }, }, }; </script> <style> .redText { color: red; } </style> ``` 这里使用了 `v-bind:class` 动态绑定样式类,当 `buttonStyle` 对象中对应的属性为真时,元素会添加 `redText` 样式类,从而显示为红色字体。在 `toggleComponent` 方法中,更新当前组件并更新按钮样式。注意还需要添加 `.redText` 样式定义才能实现红色字体

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值