2017-06-19 53 views
0

enter image description here不动向右

我需要的+按钮移动到下面的代码的权利side.But不working.Can你告诉我为什么?

.scss

.plusButton { 
     position: absolute; 
     z-index: 11; 
     color: white; 
     float: right; 
    } 

的.html

<button ion-button clear class="plusButton"> <ion-icon name="add-circle"></ion-icon></button> 
+0

这个什么:'.plusButton { 的位置是:绝对的; z-index:11; 颜色:白色; top:16px; right:16px; }'? – sebaferreras

+1

是的,这是working.But你能告诉我你是怎么决定应该是正确的':16px'?这不是'ipad'(即更大的设备)的问题吗?@sebaferreras – Sampath

+0

离子通常在内容中使用“16px”的填充(当您将'padding'属性添加到内容' ... ...“时,我总是在需要时使用相同的填充所以东西*外面*离子... – sebaferreras

回答

1

这个怎么样的项目高端物业:

.plusButton { 
    position: absolute; 
    z-index: 11; 
    color:white; 
    top: 16px; 
    right: 16px; 
} 

请注意topright值。离子通常使用16像素的填充的内容(当您添加padding属性内容<ion-content padding>...所以,我总是使用相同的填充,当我需要做的事情离子。

也请注意,如果按钮是一个navbar里面,我建议使用<ion-buttons end>...<ion-buttons>容器放置在右边,但在这种情况下,似乎是按钮是不是navbar/toolbar的一部分,所以我想我们就可以通过使用CSS修复

+1

是的,你对'navbar'用例说得对。不在这里使用'navbar'.Thanks :) – Sampath

+1

Np,很高兴帮助:) – sebaferreras

0

使用权财产对齐元素分辩。并指派相对到要设置右对齐哪个位置。

.plusButton { 
    position: absolute; 
    z-index: 11; 
    color: white; 
    right: 0px; 
} 
0

你可以尝试用离子键

<button ion-button item-end>...</button> 
0

首先,您不能同时使用absolutefloatfloat将不起作用,因为absolute在那里。 你有很多选择,使其工作,更好的办法我宁愿是用marginabsolute。请确保该按钮在DOM箭头后写的,那么你可以使用margin-leftmargin-top调整此按钮的位置。

.plusButton { 
    position: absolute; 
    z-index: 11; 
    color: white; 
    margin-left: 25px; 
    margin-botton: 10px; 
} 

当然你也可以使用right:0作为@Vijay库马尔乙说,但你必须定义父DIVrelative