如何去除列之间的空间Card?
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Sample"),
),
body: Column(
children: <Widget>[
Card(
child: Padding(
padding: EdgeInsets.all(15),
child: Text("Card 1"),
)),
Card(
child: Padding(padding: EdgeInsets.all(15), child: Text("Card 2")),
)
],
),
);
}
Run Code Online (Sandbox Code Playgroud)
输出
我在 SO 上搜索了很多,但找不到任何 100% 有效的答案。我的问题是,我的 NextJs 应用程序中有一个围绕<Link>
标签的卡片组件。我里面还有一个<Link>标签、2 个外部链接(<a>标签)和一个按钮。但这些都不起作用。我尝试放置position: relative按钮和锚标记,但它部分解决了问题(只有使用鼠标中键单击才能导航到链接,这会打开指向新选项卡的链接)。我想让它起作用,以便记录任何点击。
卡组件
<Link href={`/${song.singer}/${song.title}`} passHref>
<div className={style.cardOutter}>
<div className={style.cardHeader} style={{ backgroundImage: `url(${sdDefault(song.thumbnail)})` }}></div>
<div className={style.cardBody}>
<p>{song.title}</p>
{song.fts !== '' ?
<div className={style.card_fts}>
<span>{song.fts}</span>
</div>
:
null
}
<div className={style.cardInfoCont}>
<small>[{song.lang}] {song.album} - {song.genre}</small>
</div>
</div>
<div className={style.cardButtons}>
<a href={`https://www.youtube.com/watch?v=${song.thumbnail}`} target='_blank' rel='noreferrer' title='Listen On YouTube'><YouTubSimpleIcon color='#ff0000' width={30} height={30} /></a>
<button disabled={!authContext.isAuth} title='Add To Favouarites'><HeartIcon color='#ff0000' width={30} height={30} /></button>
<a href={`https://open.spotify.com/${song.spotifyURL === undefined ? …Run Code Online (Sandbox Code Playgroud) 我有一个卡片列表,但是当我更改卡片的宽度时,它仍然采用与父容器相同的宽度。我尝试过用大小合适的盒子或容器包装列表视图、卡片甚至滚动视图,但没有任何效果。
Container(
height: MediaQuery.of(context).size.height * 0.6,
width: MediaQuery.of(context).size.width * 0.8,
decoration: BoxDecoration(
color: kWhiteColor,
borderRadius: BorderRadius.all(
Radius.circular(MediaQuery.of(context).size.height * 0.02)),
),
child: Padding(
padding:
EdgeInsets.all(MediaQuery.of(context).size.height * 0.015),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return SizedBox(
width: MediaQuery.of(context).size.width*0.001,
height: MediaQuery.of(context).size.height*0.3,
child: Card(
color: Colors.black,
),
);
},
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
白卡后面是父容器,或者我们可以说是最外层的容器。
我有使用 Material UI 的卡片组件。该卡在悬停时会发生变化,并且卡上也应该出现阴影。但是当我把盒子阴影放在转换之前的盒子上时,阴影就会出现,并且转换后的卡片和阴影之间有空白。我怎样才能解决这个问题?
const CardStyle = styled(Card)`
background: red;
transition: transform 50ms;
&:hover {
transform: scale(1.02) perspective(0px);
box-shadow: ${({ theme }) => theme.shadows[4]};
}
`;
Run Code Online (Sandbox Code Playgroud)
其他方式相同的输出:
:hover {
transform: scale(1.02) perspective(0px);
box-shadow: 4px 4px 4px rgba(60, 60, 93, 0.33)
}
Run Code Online (Sandbox Code Playgroud) 如何删除 Card 或 Material 小部件内的顶部高程阴影。
我将 Material 小部件用于容器并给出了高程值。它从四面八方反射到我的容器。但我只想要左侧、底部和右侧的高度阴影。我怎样才能得到它或去除顶侧立面阴影。来自 Material 或 Card Widget 的示例会很有用。
Material(
elevation: 3,
child: Container(
height: 100,
width: 300,
),
)
Run Code Online (Sandbox Code Playgroud)