当前位置:网站首页>[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
2022-07-16 09:16:00 【Huawei Developer Forum】
【 Phenomenon description 】
When text When the content of components is more than one line , The adjacent div The style displays an exception , Will change from a normal circle to an ellipse .
The code is as follows :
<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 When there is too much text, the circle on the left will be stretched ' }, onInit() { }, } </script>As shown in the figure
abnormal

normal

【 Problem analysis 】
When text When there are too many components ,flex When the width exceeds the layout, it will be automatically compressed , Which leads to div The label is stretched
【 resolvent 】
You can give div Label settings flex-shrink: 0 attribute , To solve the problem
The sample code is as follows :
<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; /* Add this attribute to solve the stretching problem */ }</style><script> module.exports = { data: { text:'text When there is too much text, the circle on the left will be stretched ' }, onInit() { }, } </script>As shown in the figure :

For more technical articles , Welcome to visit https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh
边栏推荐
猜你喜欢
随机推荐
babylon. JS height map
Audio and video learning (VII) -- aac audio code stream
dtcloud的消息機制(一)
林子雨spark scala版编程小结
华为应用强制更新中,偶现点击“退出应用”退不出应用
The use of lambda function in odoo
go grpc: connection reset by peer 的一种解决方案
老树开花——用ImageProcessor快速搭一个图床应用
odoo的约束
选择排序法
Problems encountered when using yolov5
曹洁 Spark编程Scala版本课后习题答案
ODOO form视图详解(一)
input获取焦点
Detailed explanation of odoo form view (I)
音视频学习(六)——PCM音频基础
常用邮箱访问协议
How to set various displays in 3dmax2021?
解释初始化列表
Unlock Web3.0 on the cloud Alibaba cloud XR platform helps Bizhen technology present an immersive concert








