当前位置:网站首页>【快应用】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
边栏推荐
- Leetcode-83 delete duplicate elements in the sorting linked list
- 毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
- 2020,最新手机号码手机验证正则表达式,持续更新
- About enterprise middle office planning and it architecture microservice transformation
- R语言epiDisplay包ordinal.or.display函数获取有序logistic回归模型的汇总统计信息(变量对应的优势比及其置信区间、以及假设检验的p值)、write.csv函数保存csv
- 搭建一個通用監控告警平臺,架構上需要有哪些設計
- 毕业总结
- R language ggplot2 visualization: gganimate package transition_ Time function to create dynamic scatter animation (GIF), shadow_ The wake function configures the gradient falloff tailing effect of the
- docker 部署mysql8.0
- Sanfeng cloud 0215 I often use
猜你喜欢
![[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter](/img/bf/f8759195ea67832835e84c851b5e81.jpg)
[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter

Go Technology Daily (2022-02-14) - go language slice interview real questions 8 consecutive questions

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

C# SelfHost WebAPI (2)

用GSConv+Slim Neck改进Yolov5,将性能提升到极致!

Memo - about C # generating barcode

Lumiprobe Lumizol RNA 提取试剂解决方案

如何在自有APP内实现小程序实现连麦直播

Li Kou daily question - Day 32 -589 N × Preorder traversal of tree

Leetcode203 remove linked list elements
随机推荐
Case study on comprehensive competitiveness of principal components
Solution: you can ping others, but others can't ping me
华为云专家详解GaussDB(for MySQL)新特性
如何运营好技术相关的自媒体?
Database foundation: select basic query statement
ACM MM 2022视频理解挑战赛视频分类赛道冠军AutoX团队技术分享
2. Create your own NFT collections and publish a Web3 application to show them start and run your local environment
Leetcode-128 longest continuous sequence
Halcon image calibration enables subsequent image processing to become the same as the template image
R language epidisplay package ordinal or. The display function obtains the summary statistical information of the ordered logistic regression model (the odds ratio and its confidence interval correspo
用GSConv+Slim Neck改进Yolov5,将性能提升到极致!
3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
golang 错误处理
Usage and underlying implementation principle of PriorityQueue
如何运营好技术相关的自媒体?
R语言ggplot2可视化:gganimate包transition_time函数创建动态散点图动画(gif)、shadow_wake函数配置动画的渐变效果(gradual falloff)拖尾效应
搭建一個通用監控告警平臺,架構上需要有哪些設計
Evaluation of 6 red, yellow and black list cameras: who is the safest? Who has good picture quality? From now on, let you no longer step on thunder
隐私沙盒终于要来了
LeetCode-21合并两个有序链表