在html CSS中,#gone
是否具有display: none;
浏览器将具有不同的显示
.main {
display: flex;
justify-content:space-between;
}
#gone {
visibility: hidden;
/* display: none; */
}
<div class="main">
<div>text 1</div>
<div id="gone">text 1</div>
<div>text 1</div>
<div>text 1</div>
</div>
在扑朔迷离中,使用Visibility with visible: false
会像Without display:none 一样效果
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("test1",
style: TextStyle(fontSize: 10),
),
Visibility(
visible: false,
child: Text("test1",
style: TextStyle(fontSize: 10),
),
),
Text("test1",
style: TextStyle(fontSize: 10),
),
Text("test1",
style: TextStyle(fontSize: 10),
),
],
);
如何在抖动中获得类似With display:none 的效果? 英语很差:-(
答案 0 :(得分:0)
您不仅可以在视觉上隐藏小部件,还可以显示一个大小为0的空容器,如下所示:
bool hide = true;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("test1",
style: TextStyle(fontSize: 10),
),
hide==true?Container():Visibility(
visible: false,
child: Text("test1",
style: TextStyle(fontSize: 10),
),
),
Text("test1",
style: TextStyle(fontSize: 10),
),
Text("test1",
style: TextStyle(fontSize: 10),
),
],
);
在此示例中,如果变量“ hide”为true,则将显示一个空容器,而当变量“ hide”为false时,将显示不可见的文本。
答案 1 :(得分:0)
您必须从mainAxisAlignment
中删除Row
属性,然后自己处理间距:
return Row(
children: <Widget>[
Text(
"test1",
style: TextStyle(fontSize: 10),
),
Spacer(),
Visibility(
visible: false,
child: Flexible(
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
"test1",
style: TextStyle(fontSize: 10),
),
Spacer(),
],
),
),
),
Text(
"test1",
style: TextStyle(fontSize: 10),
),
Spacer(),
Text(
"test1",
style: TextStyle(fontSize: 10),
),
],
);