当前位置:网站首页>【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
2022-07-16 10:52: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/?ha_source=zzh
边栏推荐
- npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
- 微信小程序下拉刷新功能--onPullDownRefresh
- 抢效率!上云规划时间缩短一半,这家企业的CTO做对了什么?
- Economic Daily praised Hongji, a leading RPA enterprise, for helping financial institutions with their digital transformation
- Basis for comprehensive administrative law enforcement reform
- [deep learning] 40000 word notes! Yann Lecun deep learning open class 125 pages of dry goods are here
- 现代化个人博客系统 ModStartBlog v5.3.0 留言接口新增,富文本升级
- C语言位域
- Linked list - [delete all duplicate elements]
- Error-yolov5 pt转onnx报错
猜你喜欢

Unity 基础 之 Camera摄像机属性介绍

With "technology as the boat", rpa+ai injects surging momentum into the new retail digital transformation

Debugging of diagnostic function of analog power amplifier 75610

Enough speed, passion! The July 2022 Amazon deeperacer competition is high-profile

UE4 blueprint learning chapter (6) -- branch, switch, filpflop, sequence

考研人暑期行为大赏top5

内行,阿里大咖离职带出内部“高并发系统设计”学习手册

记录一个温度曲线的View

一站式 DevOps 平台,让开发大不同

SFF1602-MHCHXM(海矽美)二极管SFF1602
随机推荐
Introduction to camera attributes of unity Foundation
JVM architecture resolution
【HMS Core】【FAQ】【Health Kit】集成运动健康服务过程中,遇到一些小问题,今天分享给大家(华为手表、手环+运动健康服务问题合集)
OSPF(Open Shortest Path First開放式最短路徑優先)防環以及計算錯誤帶來的組網應用隱患
INSET: Sentence Infilling with INter-SEntential Transformer
Apple商业网站封锁Firefox浏览器
UE4 blueprint learning chapter (6) -- branch, switch, filpflop, sequence
【HarmonyOS】【ARKUI】鸿蒙 ets方式tabs+tabcontent 实现底部导航栏
新职业“数据库运行管理员”职业标准启动开发
JMeter如何使用MD5加密并且对body进行指纹签名
One stop Devops platform makes a big difference in development
Cv2.resize pit
【深度学习】4 万字笔记!Yann LeCun 深度学习公开课 125 页干货都在这了
10张图教你同步与异步(转载)
Introduction to Cisco CCNP certification
PGSQL中的limit n在sql语句中的位置
健康防猝指南2:饮食健康
Que se passe - t - il exactement de l'entrée d'URL à la présentation de page?
AP statistics
[Xilinx ax7103 microbalze learning notes 7] DDR reading and writing experiment of MicroBlaze axi4 interface