当前位置:网站首页>【快应用】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
边栏推荐
- Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)
- NSI packaging script add file details
- 为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
- C# SelfHost WebAPI (2)
- 12 data dimensioning processing methods
- 6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷
- lefse分析
- Financial judgment questions
- code
- R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses PCH parameters to customize the shape o
猜你喜欢

Localization through custom services in the shuttle application

Must see, time series analysis

研究了11种实时聊天软件,我发现都具备这些功能…

Relational database management system of easyclick

Leetcode-160相交链表

Leetcode-160 intersecting linked list

Three. JS learning - basic operation of camera (learn from)

磁盘的基本知识和基本命令

搭建一个通用监控告警平台,架构上需要有哪些设计

Leetcode-141 circular linked list
随机推荐
Leetcode-83 删除排序链表中重复的元素
Leetcode-141 circular linked list
Is Alipay wallet convenient to use?
GameFramework食用指南
How to change guns for 2D characters
Basic knowledge and commands of disk
Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?
Popular science: what does it mean to enter the kernel state?
每周推薦短視頻:警惕“現象”與“問題”相互混淆
Leetcode-141环形链表
Five degrees easy chain enterprise app is newly upgraded
Memo - about C # generating barcode for goods
Vidéos courtes recommandées chaque semaine: méfiez - vous de la confusion entre « phénomène » et « problème »
Navicat premium 15 permanent cracking and 2021 latest idea cracking (valid for personal testing)
C language learning notes: type definition typedef and declaration external CSDN creation punch in
3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
Go Technology Daily (2022-02-14) - go language slice interview real questions 8 consecutive questions
12. Design of power divider for ads usage record
Memo - about C # generating barcode
如何在自有APP内实现小程序实现连麦直播