简体   繁体   English

右 alignment 用于 ion-col 中的按钮

[英]right alignment for a button in ion-col

I have this grid in my Ionic 2 application.我的 Ionic 2 应用程序中有这个网格。 Is there any ionic-specific attribute to make the button shown on the right side of the column (row)?是否有任何特定于离子的属性使按钮显示在列(行)的右侧?

<ion-grid>
  <ion-row>
    <ion-col>col 1</ion-col>
    <ion-col>col 2</ion-col>
  </ion-row>
  <ion-row>
    <ion-col>
      <button ion-button>My button</button>
    </ion-col>
  </ion-row>
</ion-grid>

In your case you can add the attribute float-right like so:在您的情况下,您可以像这样添加属性float-right

<button ion-button float-right>My button</button>

float-{modifier}浮动{修饰符}
The documentation says you can add the attribute float-{modifier} to position an element inside its container. 文档说您可以添加属性float-{modifier}以在其容器内定位元素。

{modifier} can be any of the following: {modifier}可以是以下任何一种:
right : The element will float on the right side of its container. right :元素将浮动在其容器的右侧。
left : The element will float on the left side of its container. left :元素将浮动在其容器的左侧。
start : The same as float-left if direction is left-to-right and float-right if direction is right-to-left. start : 如果方向是float-left则与float-left相同,如果方向是从右到float-left则与 float-right 相同。
end : The same as float-right if direction is left-to-right and float-left if direction is right-to-left. end : 如果方向是从左到右,则与 float-right 相同,如果方向是从右到左,则与 float-left 相同。

Example:示例:

<div>
    <button ion-button float-right>My button</button>
</div>

item-{modifier}项目-{修饰符}
To position an element inside an ion-item the documentation says you can use item-{modifier} .要在ion-item定位元素,文档说您可以使用item-{modifier}

Where {modifier} can be any of the following:其中{modifier}可以是以下任何一项:
start : Placed to the left of all other elements, outside of the inner item. start :放置在所有其他元素的左侧,在内部项目之外。
end : Placed to the right of all other elements, inside of the inner item, outside of the input wrapper. end :放置在所有其他元素的右侧,内部项目内部,输入包装器外部。
content : Placed to the right of any ion-label, inside of the input wrapper. content : 放置在任何离子标签的右侧,输入包装器的内部。

Example:示例:

<ion-item>
    <button ion-button item-end>My button</button>
</ion-item>

Deprecation弃用
According to the documentation these names are deprecated:根据文档,这些名称已被弃用:

item-right & item-left item-right item-left

The new names are :新名称是:

  • item-start & item-end item-startitem-end
  • padding-start & padding-end padding-startpadding-end
  • margin-start & margin-end margin-startmargin-end
  • text-start & text-end text-starttext-end
  • start and end for FABs FAB 的startend

The accepted solution didnt work for me.接受的解决方案对我不起作用。 I think it is relevant to ionic v3 and not the current.我认为它与 ionic v3 而不是当前有关。 I solved my problem like this:我这样解决了我的问题:

page.html:页面.html:

<div class="test">
    <ion-button>My button</ion-button>
</div>

page.scss:页面.scss:

.test {
    float: right;
}

I'm using ionic 6.18.2 where this works for me:我正在使用 ionic 6.18.2,这对我有用:

<ion-button class="ion-float-right">Button Text</ion-button>

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

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