当前位置:网站首页>【快应用】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
边栏推荐
- Write an open source, convenient and fast database document query and generation tool with WPF
- Technology implementation and Architecture Practice
- Li Kou daily question - Day 32 -1232 Dotted line
- 搭建一個通用監控告警平臺,架構上需要有哪些設計
- [image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter
- Is Alipay wallet convenient to use?
- Lumiprobe biomolecular quantification - qudye Protein Quantification Kit
- Leetcode203 remove linked list elements
- 毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
- Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester
猜你喜欢
用GSConv+Slim Neck改进Yolov5,将性能提升到极致!
12 data dimensioning processing methods
透过华为军团看科技之变(六):智慧公路
Localization through custom services in the shuttle application
Leetcode-83 删除排序链表中重复的元素
Leetcode-83 delete duplicate elements in the sorting linked list
Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)
540. Single element in ordered array / 1684 Count the number of consistent strings
[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter
C# SelfHost WebAPI (2)
随机推荐
Mysql database of easyclick
华为云专家详解GaussDB(for MySQL)新特性
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
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
Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)
Lumiprobe非荧光炔烃丨EU(5-乙炔基尿苷)
Facebook聊单,SaleSmartly有妙招!
Write an open source, convenient and fast database document query and generation tool with WPF
js找出数字在数组中下一个相邻的元素
code
R语言caTools包进行数据划分、scale函数进行数据缩放、class包的knn函数构建K近邻分类器、table函数计算混淆矩阵
Relational database management system of easyclick
Altair HyperWorks 2022软件安装包和安装教程
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
Roll out! Enlightenment!
1. "Create your own NFT collections and publish a Web3 application to show them." what is NFT
太爱速M源码搭建,巅峰小店APP溢价寄卖源码分享
力扣每日一题-第32天-589.N×树的前序遍历
Lumiprobe biomolecular quantification - qudye Protein Quantification Kit
如何运营好技术相关的自媒体?