当前位置:网站首页>[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
边栏推荐
- Binary tree topic -- p1030 [noip2001 popularization group] find the first order
- AppGallery Connect场景化开发实战—图片存储分享
- 1287_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
- OpenMLDB Meetup No.4 会议纪要
- 【付费推广】常见问题合集,推荐榜单FAQ
- Leetcode 182 Find duplicate email (2022.07.01)
- Operator-1 first acquaintance with operator
- Is the account above changtou school safe?
- 华为联机对战服务玩家掉线重连案例总结
- Learn open62541 -- [66] UA_ Generation method of string
猜你喜欢
14. Code implementation of semaphore
Dialogue Wu Gang: why do I believe in the rise of "big country brands"?
LabVIEW为什么浮点数会丢失精度
Uncover the secrets of Huawei application market application statistics
Overview of integrated learning
集成学习概览
二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)
Hdu1228 a + B (map mapping)
Special topic of binary tree -- acwing 19 The next node of the binary tree (find the successor of the node in the tree)
Mysql database remote access permission settings
随机推荐
PCL point cloud to depth image
计算序列之和
HDU1236 排名(结构体排序)
Pywin32 opens the specified window
华为游戏初始化init失败,返回错误码907135000
Learn open62541 -- [66] UA_ Generation method of string
(5) Gear control setting of APA scene construction
Static variables in static function
最详细MySql安装教程
Matlab processing of distance measurement of experimental electron microscope
JVM garbage collector
In the face of uncertainty, the role of supply chain
点云投影图片
【AppLinking实战案例】通过AppLinking分享应用内图片
二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
《实习报告》Skywalking分布式链路追踪?
华为快应用中如何实现同时传递事件对象和自定义参数
Hdu1236 ranking (structure Sorting)
Special topic of binary tree -- acwing 1589 Building binary search tree
6种单例模式的实现方式