1

我尝试在 Bootstrap 中使用 Collapse元素,但我有一点问题。

这是一个例子在此处输入图像描述

我尝试将我的文本与我的按钮垃圾对齐在同一行中。如您所见,它发生了变化。

如何解决这个问题呢?

<form method="post" action="wbx.php">
    <div class="accordion" id="accordion2">
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                Collapsible Group Item #1
                </a>
                <button class="btn btn-danger pull-right" type="submit" name="supprAlias" value="'.$idValue.'">
                    <i class="icon-trash icon-white"></i>
                </button>
            </div>
            <div id="collapseOne" class="accordion-body collapse in">
                <div class="accordion-inner">
                    Anim pariatur cliche...
                </div>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                Collapsible Group Item #2</a>
                <button class="btn btn-danger pull-right" type="submit" name="supprAlias" value="'.$idValue.'">
                    <i class="icon-trash icon-white"></i>
                </button>

            </div>
            <div id="collapseTwo" class="accordion-body collapse">
                <div class="accordion-inner">
                    Anim pariatur cliche...
                </div>
            </div>
        </div>
    </div>
</form>

在另一个页面的我的控制器中:

if(!empty($_POST['supprUserAlias']))
{
    $savant->deletesUserAlias = $gemel->setDeleteUserAlias($_POST['supprUserAlias'], $username, $domain, $serverMail);
    header('Location: wbx.php?user='.$username.'#alias');
    exit;
}

编辑

最后找到解决方案:

<button>之间<div class="accordion-group"><div class="accordion-heading">

<form method="post" action="wbx.php">
        <div class="accordion" id="accordion2">
            <div class="accordion-group">
                   <button class="btn btn-danger pull-right" type="submit" name="supprAlias" value="'.$idValue.'">
                        <i class="icon-trash icon-white"></i>
            </button>
                <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                    Collapsible Group Item #1
                    </a>
                </div>
                <div id="collapseOne" class="accordion-body collapse in">
                    <div class="accordion-inner">
                        Anim pariatur cliche...
                    </div>
                </div>
            </div>
4

1 回答 1

1

您只需将按钮放在链接 (a) 标记中,如下所示。我认为您还应该使按钮更小(btn-mini),以便它很好地适合折叠链接。

<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
    Collapsible Group Item #1 <button class="btn btn-mini btn-danger pull-right" type="submit"><i class="icon-trash icon-white"></i></button>
</a>

Demo on Bootply

编辑-

按钮的点击可以像..

$('.accordion-toggle .btn').click(function(e){
    e.preventDefault();
    alert("button!");
    return false;
})
于 2013-05-23T12:50:38.013 回答