gwtbootstrap3。如何用Button按钮组合ButtonGroup元素

时间:2015-07-10 15:15:48

标签: css twitter-bootstrap gwtbootstrap3

我想将我的按钮组合理为父级的整个宽度。

我正在尝试Justified button groups

这是我的代码:

ButtonGroup buttonGroupHelper = new ButtonGroup();

Button loginButton = new Button("Log in");
Button resetButton = new Button("Reset");
Button forgotCredentialsButton = new Button("Forgot credentials?");

buttonGroupHelper.add(loginButton);
buttonGroupHelper.add(resetButton);
buttonGroupHelper.add(forgotCredentialsButton);

我得到了这个: enter image description here

当我添加这一行时:

buttonGroupHelper.setJustified(true);

我得到了这个: enter image description here

我使用bootstrap css darkly theme

这是我的gwtbootstrap3框架产生的html:

<div class="btn-group btn-group-justified">
    <button type="button" class="btn btn-success"><i class="fa fa-play-circle-o"></i> Log in</button>
    <button type="button" class="btn btn-danger"><i class="fa fa-times-circle-o"></i> Reset</button>
    <button type="button" class="btn btn-warning"><i class="fa fa-key"></i> Forgot credentials?</button>
</div>

我做错了什么。或者这只是一个错误?

请帮忙。

1 个答案:

答案 0 :(得分:2)

您应该将按钮放在按钮组中,然后将按钮组放在帮助按钮组中。

ButtonGroup buttonGroupHelper = new ButtonGroup();
ButtonGroup loginBtnGroup = new ButtonGroup();
ButtonGroup resetBtnGroup = new ButtonGroup();
ButtonGroup forgotBtnGroup = new ButtonGroup();

Button loginButton = new Button("Log in");
Button resetButton = new Button("Reset");
Button forgotCredentialsButton = new Button("Forgot credentials?");

loginBtnGroup.add(loginButton);
resetBtnGroup.add(resetButton);
forgotBtnGroup.add(forgotCredentialsButton);

buttonGroupHelper.add(loginBtnGroup);
buttonGroupHelper.add(resetBtnGroup);
buttonGroupHelper.add(forgotBtnGroup);

buttonGroupHelper.setJustified(true);