当前位置:网站首页>[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-02 11:01: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 details , Please see the :
Huawei official website :
https://developer.huawei.com/consumer/cn/forum/topic/0203908673278080243?fid=23?ha_source=zzh
边栏推荐
- Special topic of binary tree -- Logu p1229 traversal problem (the number of traversals in the middle order is calculated when the pre and post order traversals of the multiplication principle are know
- Easyexcel, a concise, fast and memory saving excel processing tool
- 华为快应用中如何实现同时传递事件对象和自定义参数
- PCL extracts a subset from a point cloud
- 12. Process synchronization and semaphore
- 正则及常用公式
- Oracle notes
- 二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
- HDU1236 排名(结构体排序)
- 最详细MySql安装教程
猜你喜欢

Special topic of binary tree -- acwing 1497 Traversal of the tree (use post and mid order traversal to build a binary tree)

1287_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析

OpenMLDB Meetup No.4 会议纪要

UVM learning - build a simple UVM verification platform

Hdu1228 a + B (map mapping)

MySQL environment configuration

HDU1236 排名(结构体排序)

华为AppLinking中统一链接的创建和使用

V2X-Sim数据集(上海交大&纽约大学)

4. Random variables
随机推荐
Primary key policy problem
LabVIEW为什么浮点数会丢失精度
HDU1234 开门人和关门人(水题)
JSP webshell免殺——JSP的基礎
P1055 [noip2008 popularization group] ISBN number
Overview of integrated learning
[ark UI] implementation of the startup page of harmonios ETS
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)
Uncover the secrets of Huawei application market application statistics
Special topic of binary tree -- acwing 1497 Traversal of the tree (use post and mid order traversal to build a binary tree)
【AI应用】海康威视iVMS-4200软件安装
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
洛谷 P1892 [BOI2003]团伙(并查集变种 反集)
《实习报告》Skywalking分布式链路追踪?
二叉树专题--洛谷 P1229 遍历问题(乘法原理 已知前、后序遍历求中序遍历个数)
2022爱分析· 国央企数字化厂商全景报告
JVM之垃圾回收器
Hdu1236 ranking (structure Sorting)
二叉树专题--AcWing 47. 二叉树中和为某一值的路径(前序遍历)
【快应用】Win7系统使用华为IDE无法运行和调试项目