I just want to set a column to a set px size, and then have the other column take up the rest of the space.
I have the following where I want the first col to be say 10px
<ion-grid>
<ion-row>
<ion-col width-X='10px' style='width:10px;background-color:red'></ion-col>
<ion-col>
<div><b>item 1</b></div>
<div>item 2</div>
<div>item 3</div>
</ion-col>
</ion-row>
</ion-grid>
But the first column is always 50%.
Is there a way to use a fixed px?
Thanks in advance
By default, the grid will take up 100% width. To set a specific width based on the screen size, add the fixed attribute. The width of the grid for each breakpoint is defined in the --ion-grid-width-{breakpoint} CSS variables.
ion-col: Column Component Padding, Size and Other Properties. Skip to main content.
Working with the Ionic Grid System is straightforward. There are two main classes – row for working with rows and col for columns. You can choose as many columns or rows you want. All of them will adjust its size to accommodate the available space, although you can change this behavior to suit your needs.
You could use flex-basis to achieve what you're looking for. In your Sass...
ion-row {
ion-col {
&:first-of-type {
flex: 0 0 10px;
}
}
}
Flex's shorthand property allows you set it to and the you'd like the element to take up.
See here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
You can specify a min width to the column as mentioned in ionic doc. In mycase, the first column will stay fixed and the column around will resize.
<ion-grid>
<ion-col class="accordion" col-2></ion-col>
<ion-col></ion-col>
</ion-grid>
.accordion{
min-width: 224px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With