javascript - 使用单选按钮在面板中对齐

标签 javascript html css

我正在使用它来显示多个产品并使其正常工作,除了我试图让我的副标题与它上面的产品标题对齐。

我希望标题在第一行,子标题在第二行,但不希望子标题在单选按钮下方换行。

还希望将面板标题行的单选按钮垂直居中。

<div class="pull-right">
    Some image or <br />
    images will go <br />
    over here.
</div>
<div class="panel-group pull-left" id="products">
    <div class="panel panel-default">
        <div class="panel-heading" data-toggle="collapse" data-parent="#products" href="#partnumber1">
            <h4 class="panel-title">
                <div>
                    <input type="radio" name="specs"> Some Product Title #1<br />
                        Some Product Subtitle
                </div>
            </h4>
        </div>
        <div id="partnumber1" class="panel-collapse collapse">
             <div class="list-group">
                 <ul class="list-group">
                     <li class="list-group-item">Some product data</li>
                     <li class="list-group-item">Some product data</li>
                </ul>
             </div>
        </div>
        <div class="panel-heading" data-toggle="collapse" data-parent="#products" href="#partnumber2">
            <h4 class="panel-title">
                <div>
                    <input type="radio" name="specs"> Some Product Title #2 <br />
                        Some Product Subtitle
                </div>
            </h4>
        </div>
        <div id="partnumber2" class="panel-collapse collapse">
             <div class="list-group">
                 <ul class="list-group">
                     <li class="list-group-item">Some product data</li>
                     <li class="list-group-item">Some product data</li>
                </ul>
             </div>
        </div>
    </div>
</div>

https://jsfiddle.net/blaine109/um7m89hp/

最佳答案

我建议您为单选按钮使用绝对位置 link .如果你只支持现代浏览器,你可以使用

transform: translateY(-50%)

代替

margin-top: -6px; // half of the height of the radio button

关于javascript - 使用单选按钮在面板中对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32257915/

相关文章:

jquery - 在 JQuery 中使用 !important 更改 CSS - 使用 Bootstrap 3

html - 如何为元素或 div 的内容设置样式?

html - 使内部 div 占据外部响应式 div 的 100%( float 问题)

javascript - 每次在 Rails 5 应用程序中加载 turbolinks 时执行 JS

javascript - 在选中时更改 td 的背景颜色

python - 将 matplotlib png 转换为 base64 以便在 html 模板中查看

html - knitr/rmarkdown - 减少 html 文件大小

javascript - 如何为新添加的行添加背景颜色angularjs

javascript - 一切都是对象?

javascript - 筛选 ui-grid 后选择第一个可见行