当前位置:网站首页>【快应用】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
边栏推荐
- 力扣每日一题-第32天-589.N×树的前序遍历
- JS find the next adjacent element of the number in the array
- How to find the optimal learning rate
- Leetcode-141 circular linked list
- [image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter
- Principal component calculation weight
- Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?
- The R language uses the tablestack function of epidisplay package to make statistical summary tables (descriptive statistics based on the grouping of target variables, hypothesis testing, etc.). If th
- 2. Create your own NFT collections and publish a Web3 application to show them start and run your local environment
- 华为云专家详解GaussDB(for MySQL)新特性
猜你喜欢

Navicat premium 15 permanent cracking and 2021 latest idea cracking (valid for personal testing)

11、用户、组和权限(1)

Force buckle day33

Salesmartly has some tricks for Facebook chat!

LiveData postValue会“丢”数据

创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)

After studying 11 kinds of real-time chat software, I found that they all have these functions

linux下清理系统缓存并释放内存

实现一个Prometheus exporter

Lumiprobe Lumizol RNA 提取试剂解决方案
随机推荐
实现一个Prometheus exporter
摄像头的MIPI接口、DVP接口和CSI接口[通俗易懂]
Leetcode203 remove linked list elements
ACM MM 2022视频理解挑战赛视频分类赛道冠军AutoX团队技术分享
Lumiprobe 双功能交联剂丨Sulfo-Cyanine5 双-NHS 酯
Leetcode-128 longest continuous sequence
Three.js学习-相机Camera的基本操作(了解向)
创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
华为云专家详解GaussDB(for MySQL)新特性
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
Altair HyperWorks 2022软件安装包和安装教程
2020,最新手机号码手机验证正则表达式,持续更新
Weekly recommended short videos: be alert to the confusion between "phenomena" and "problems"
ES6数组去重的三个简单办法
隐私沙盒终于要来了
Five degrees easy chain enterprise app is newly upgraded
12 data dimensioning processing methods
[Chongqing Guangdong education] basic psychology reference materials of Tianjin Normal University
Excel之VBA简单宏编程
ES6 summary "suggestions collection" of array methods find(), findindex()