当前位置:网站首页>【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
2022-07-01 18:39:00 【华为开发者论坛】
【现象描述】
当text组件的内容较多多行显示的时候,相邻的div样式会显示异常,会从正常的圆形变为椭圆。
代码如下:
<template> <div class="container"> <div style="align-items: center;"> <div class="typscolor" style="background-color: blue; opacity: 0.26; margin-left: 16px;"></div> <text>{{text}}</text> <div class="typscolor" style="background-color: blue; opacity: 0.26; margin-left: 16px;"></div> <text>{{text}}</text> <div class="typscolor" style="background-color: blue; opacity: 0.26; margin-left: 16px;"></div> <text>{{text}}</text> </div> </div></template><style> .container { flex-direction: column; justify-content: center; height: 100%; } text { font-size: 24px; } .typscolor { border-radius: 50%; width: 30px; height: 30px; background-color: red; margin-right: 8px; }</style><script> module.exports = { data: { text:'text文本内容过多时左边的圆圈会被拉伸' }, onInit() { }, } </script>
如图所示
异常
正常
【问题分析】
当text组件内容过多时,flex布局的时候宽度超出会自动压缩,从而导致div标签被拉伸了
【解决方法】
可以给div标签设置flex-shrink: 0属性,即可解决该问题
示例代码如下:
<template> <div class="container"> <div style="align-items: center;"> <div class="typscolor" style="background-color: blue; opacity: 0.26; margin-left: 16px;"></div> <text>{{text}}</text> <div class="typscolor" style="background-color: blue; opacity: 0.26; margin-left: 16px;"></div> <text>{{text}}</text> <div class="typscolor" style="background-color: blue; opacity: 0.26; margin-left: 16px;"></div> <text>{{text}}</text> </div> </div></template><style> .container { flex-direction: column; justify-content: center; height: 100%; } text { font-size: 24px; } .typscolor { border-radius: 50%; width: 30px; height: 30px; background-color: red; margin-right: 8px; flex-shrink: 0; /*加上该属性即可解决拉伸问题*/ }</style><script> module.exports = { data: { text:'text文本内容过多时左边的圆圈会被拉伸' }, onInit() { }, } </script>
如图所示:
欲了解更多详情,请参见:
华为官网:
https://developer.huawei.com/consumer/cn/forum/topic/0203908673278080243?fid=23?ha_source=zzh
边栏推荐
- Three. JS learning - basic operation of camera (learn from)
- 毕业总结
- 如何运营好技术相关的自媒体?
- Lefse analysis
- Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?
- Navicat Premium 15 永久破解和2021版本最新IDEA破解(亲测有效)
- GAMES202作业0-环境搭建过程&解决遇到的问题
- Usage and underlying implementation principle of PriorityQueue
- [source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
- Basic knowledge and commands of disk
猜你喜欢
创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
Memo - about C # generating barcode
Leetcode-160 intersecting linked list
Leetcode203 remove linked list elements
Leetcode-83 删除排序链表中重复的元素
Halcon image calibration enables subsequent image processing to become the same as the template image
解决方案:可以ping别人,但是别人不能ping我
Leetcode-21 combines two ordered linked lists
信度系数低怎么办?信度系数具体怎么算?
AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖
随机推荐
Go Technology Daily (2022-02-14) - go language slice interview real questions 8 consecutive questions
Create your own NFT collections and publish a Web3 application to show them (Introduction)
Must see, time series analysis
华为云专家详解GaussDB(for MySQL)新特性
解决方案:可以ping别人,但是别人不能ping我
每周推薦短視頻:警惕“現象”與“問題”相互混淆
为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
What designs are needed in the architecture to build a general monitoring and alarm platform
力扣每日一题-第32天-1232. 缀点成线
[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter
Leetcode-141 circular linked list
Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)
R语言epiDisplay包ordinal.or.display函数获取有序logistic回归模型的汇总统计信息(变量对应的优势比及其置信区间、以及假设检验的p值)、write.csv函数保存csv
How to operate technology related we media well?
关于企业中台规划和 IT 架构微服务转型
磁盘的基本知识和基本命令
Li Kou daily question - Day 32 -1232 Dotted line
After studying 11 kinds of real-time chat software, I found that they all have these functions
NSI packaging script add file details
宏观视角看抖音全生态