html - 用 Accordion 对齐 Bootstrap

标签 html css bootstrap-4

我是 bootstrap 的初学者。我正在使用这样的 Bootstrap 设计简单的常见问题解答页面。

enter image description here

这是我的风格。我尝试更改位置和边距,但我无法将标题和箭头缩短到中间。我该怎么办?

<style>
 .faqHeader {
    font-size: 27px;
    margin: 20px;
}

.panel-heading [data-toggle="collapse"]:after {
    font-family: 'Glyphicons Halflings';
    content: "\e072"; /* "play" icon */
    float: right;
    color: #F58723;
    font-size: 18px;
    line-height: 22px;
    /* rotate "play" icon from > (right arrow) to down arrow */
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
    transform: rotate(-90deg);

}



.panel-heading [data-toggle="collapse"].collapsed:after {
    /* rotate "play" icon from > (right arrow) to ^ (up arrow) */
    -webkit-transform: rotate(90deg);
    -moz-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    -o-transform: rotate(90deg);
    transform: rotate(90deg);
    color: #454444;

}
</style>


<div class="panel panel-default">
    <div class="panel-heading">
        <h4 class="panel-title">
            <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseSeven">How did the Self Assessment Test come about?</a>
        </h4>
    </div>
    <div id="collapseSeven" class="panel-collapse collapse">
        <div class="panel-body">
                The Skill Optimiser Project Team has worked with all the Hiring Managers for the various job roles to understand the requirement based on 4 aspects: Product Knowledge, Job Expertise Knowledge/ Skills, Education/ Experience, and Competencies.
        </div>
    </div>
</div>

最佳答案

您可以尝试在您的样式中添加以下代码:

.panel-heading [data-toggle="collapse"] {
    position: relative;
    display: block;
}
.panel-heading [data-toggle="collapse"]:after {
    position: absolute;
    right: 15px;
    top: 5px;
    float: right;  /*remove it*/
}

使用 position 而不是 float: right。删除您的float:right

根据您所附的 zip。我在 index.html 中更改了您的样式,如下所示。它奏效了。

.faqHeader {
    font-size: 27px;
    margin: 20px;
}
.panel-heading [data-toggle="collapse"] {
    display: block;
    position: relative;
    padding-right: 20px;
}
.panel-heading [data-toggle="collapse"]:after {
    position: absolute;
    top: 0;
    right: 0;
    font-family: 'Glyphicons Halflings';
...

enter image description here

关于html - 用 Accordion 对齐 Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52750594/

相关文章:

html - 为移动 View 更正自定义桌面 CSS

javascript - Jquery 动画不透明度和其他元素的边距

html - 我想在 bootstrap 4 中水平滚动

jquery - 当我点击菜单 li 时,菜单未隐藏(jquery)

javascript - 通过 jquery 数据填充 bootstrap html 表

html - Chrome 在少数情况下不遵循@media 打印规则

HTML 下拉多列

html - 响应式 CSS 未加载?

css - 如何使用动态加载的数据创建不同颜色的行?

javascript - 单击动态创建的按钮时如何暂停嵌入式 mp4 的播放?