当前位置:网站首页>【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
2022-07-02 07:15: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
边栏推荐
- [TS] 1368 seconds understand typescript generic tool types!
- 02-taildir source
- [SUCTF2018]followme
- KS009基于SSH实现宠物管理系统
- Mysql database remote access permission settings
- 对话吴纲:我为什么笃信“大国品牌”的崛起?
- (5) Gear control setting of APA scene construction
- [Fantasy 4] the transformation from U3D to UE4
- What are the popular frameworks for swoole in 2022?
- UVM - usage of common TLM port
猜你喜欢
对话吴纲:我为什么笃信“大国品牌”的崛起?
[jetbrain rider] an exception occurred in the construction project: the imported project "d:\visualstudio2017\ide\msbuild\15.0\bin\roslyn\microsoft.csh" was not found
简洁、快速、节约内存的Excel处理工具EasyExcel
Flink calculates topn hot list in real time
Kustomize user manual
HDU1228 A + B(map映射)
618再次霸榜的秘密何在?耐克最新财报给出答案
13.信号量临界区保护
互联网快讯:腾讯会议应用市场正式上线;Soul赴港递交上市申请书
JSP webshell免杀——webshell免杀
随机推荐
UWA report uses tips. Did you get it? (the fourth bullet)
sqoop创建job出现的一系列问题解决方法
Solution of mysql8 forgetting password file in Windows Environment
Considerations for Apache deploying static web page projects
PCL 投影点云
Transport Optimization abstraction
面对不确定性,供应链的作用
《MySQL 8 DBA基础教程》简介
MYSQL关键字
MongoDB-快速上手MongoDB命令行的一些简单操作
Set the playback speed during the playback of UOB equipment
PCL 从一个点云中提取一个子集
Session cookies and tokens
Retrofit's callback hell is really vulnerable in kotlin synergy mode!
快速做出原型
转换YV12到RGB565图像转换,附YUV转RGB测试
集成学习概览
学习open62541 --- [66] UA_String的生成方法
Easyexcel, a concise, fast and memory saving excel processing tool
Windows环境MySQL8忘记密码文件解决方案