当前位置:网站首页>【快应用】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
边栏推荐
- Find all missing numbers in the array
- Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester
- Lumiprobe 生物分子定量丨QuDye 蛋白定量试剂盒
- Image acquisition and playback of coaxpress high speed camera based on pxie interface
- 《Go题库·16》读写锁底层是怎么实现的
- NSI packaging script add file details
- Relational database management system of easyclick
- Leetcode-21 combines two ordered linked lists
- GameFramework食用指南
- Solution: you can ping others, but others can't ping me
猜你喜欢

Using OpenSSL encryption to rebound shell traffic

Lumiprobe Lumizol RNA 提取试剂解决方案

6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷

Livedata postvalue will "lose" data

Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester

3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT

Leetcode-83 delete duplicate elements in the sorting linked list

12. Design of power divider for ads usage record

Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?

What designs are needed in the architecture to build a general monitoring and alarm platform
随机推荐
6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷
如何在自有APP内实现小程序实现连麦直播
创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
研究了11种实时聊天软件,我发现都具备这些功能…
After studying 11 kinds of real-time chat software, I found that they all have these functions
Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester
Mysql database of easyclick
Thread forced join, thread forced join application scenarios
[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter
AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖
R语言caTools包进行数据划分、scale函数进行数据缩放、class包的knn函数构建K近邻分类器、table函数计算混淆矩阵
Leetcode-83 删除排序链表中重复的元素
Lumiprobe 双功能交联剂丨Sulfo-Cyanine5 双-NHS 酯
Unity learning fourth week
Privacy sandbox is finally coming
每周推荐短视频:警惕“现象”与“问题”相互混淆
[Chongqing Guangdong education] basic psychology reference materials of Tianjin Normal University
Halcon image calibration enables subsequent image processing to become the same as the template image
OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习
R语言ggplot2可视化:gganimate创建动态柱状图动画(gif)、在动画中沿给定维度逐步显示柱状图、enter_grow函数和enter_fade函数控制运动内插退出(渐变tweening)