简体   繁体   English

如何在Ruby on Rails中将按钮放在中心?

[英]How can I put my button in the center in Ruby on rails?

I have a button that has a link on the left side of screen. 我有一个在屏幕左侧具有链接的按钮。

<div class="col-md-4" text-center>
<%=  button_to("Bay Area Time", { action: "index" , :timezone=>'west'}, class: "btn btn-primary")  %>
</div>

I want to put this button in the center of a certain box. 我想将此按钮放在某个框的中央。 Where should I make modifications to achieve this? 我应该在哪里进行修改以实现这一目标? How can I center my button, especially when I'm trying to incorporate action, and the variable inside the hyper link? 如何将按钮居中,尤其是当我尝试合并动作以及超链接中的变量时? :) :)

<div class="col-md-4 text-center"'>

您忘记了在该标签的类双引号中包含文本中心。

You need to put the text-center inside the class declaration. 您需要将文本中心放在类声明中。 In your code it is outside of the quotes and will have no effect. 在您的代码中,它在引号之外,并且无效。 This should do what you want if the area in which you are trying to center the button is indeed the col-md-4 gridspace. 如果您要使按钮居中的区域确实是col-md-4网格空间,则这应该可以执行您想要的操作。 I am assuming you are including the Bootstrap css code correctly as that is a bootstrap grid class. 我假设您正确地包含了Bootstrap CSS代码,因为这是一个Bootstrap网格类。

<div class="col-md-4 text-center" > 
<%=  button_to("Bay Area Time", { action: "index" , :timezone=>'west'}, class: "btn btn-primary")  %>
</div>

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

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