简体   繁体   English

离子2:使离子列表项更小

[英]Ionic 2: make ion-list items smaller

There is a similar question here , but it pertains to ionic 1 where the ion-item still has ion-content . 还有一个类似的问题在这里 ,但它涉及到离子1,其中ion-item仍具有ion-content In ionic-2 there is not ionic-content . 在离子-2中,没有ionic-content I've tried changing the height/padding/margin of the actual ion-item , and the class item-inner and can't seem to get a uniform "skinny-ing" of the ion-items. 我已经尝试改变实际ion-item的高度/填充/边距,以及类item-inner并且似乎无法获得离子项的均匀“瘦身”。

Question : How do I make the ion-items in an ion-list skinnier/smaller/not as tall in ionic 2? 问题 :如何使离子列表中的离子列表更小/更小/离子2中的离子列表更高? Ps. PS。 this is using ionic 2 beta 10 这是使用离子2 beta 10

I found that the main issue with this is in the app.ios.css file native to ionic that the .item class that gets assigned to the ion-item element gets a min-height assigned to it of 4.4 rem. 我发现这个问题的主要问题是app.ios.css文件本身就是离子的,被分配给ion-item元素的.item类获得了4.4 rem的min-height I'm not sure where that value came from or why it's 4.4. 我不确定这个价值来自哪里,或者为什么它是4.4。 So, in my .scss file pertaining to the list, I just added: 所以,在我的.scss文件列表中,我刚刚添加:

.item {
    min-height: 3rem; /* <- this can be whatever you need */
}

This made it so any changes that I made to the margins( I ended up changing the margin to 0 8px 0 0 respectively ) of the inner elements actually changed the height of the list item because they weren't bumping up against a min-height setting. 这使得我对边缘所做的任何更改(我最终将边距更改为0 8px 0 0)内部元素实际上改变了列表项的高度,因为它们没有碰到最小高度设置。 See other answer for where to change the margin. 请参阅其他答案,了解更改保证金的位置。

Without changing the min-height of the list item, any changes to the margins of the inner elements didn't do anything (at least for me ). 在不更改列表项的最小高度的情况下,对内部元素边距的任何更改都没有做任何事情(至少对我而言)。

Change the top-bottom padding on <ion-label> . 更改<ion-label>上的上下填充。 The default is this: 默认是这样的:

ion-label {
  margin: 13px 8px 13px 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM