Bootstrap row text pushing columns down

孤者浪人 提交于 2020-01-06 13:58:17

问题


I'm having some issues with a simple layout using twitter bootstrap 3.0. The issue occurs when I have too much text in my content, and it pushes conent down. I'm not sure I'm structuring things quite properly. Here's my HTML

<div data-bind="foreach: items" class="row">
        <div class="col-sm-4" >
            <div >
                <div>
                    <strong>Field:</strong> <span data-bind="text: Field"></span><br />
                    <strong>Field:</strong> <span data-bind="text: Field"></span><br />
                    <strong>Field:</strong> <span data-bind="text: Field"></span><br />
                    <strong data-bind="text: Field">Field</strong>
                </div>
                <div class="container">
                    <img class="img-rounded" data-bind="attr: { src: Field}" />
                </div>
                <div >
                    <button type="button" class="btn btn-danger btn-sm" id="dislike" >
                        <span class="glyphicon glyphicon-thumbs-down"></span>
                    </button>
                    <button type="button" class="btn btn-success btn-sm">
                        <span class="glyphicon glyphicon-thumbs-up"></span>
                    </button>
                    <audio class="audioStream" oncanplay="" preload="none">
                        <source src="" />
                    </audio>
                    <button type="button" class="btn btn-primary btn-sm audioPlayer">
                        <span class="glyphicon glyphicon-play audioPlayerIcon"></span>
                    </button>
                </div>
            </div>
        </div>

I'm expecting to get output like this (Which I do if the text is short)

Instead it shows up like

I imagine I could probably fix the issue by making a new div with class="row" every three records, but I don't think I should really have to do that. Perhaps I'm using the grid system incorrectly with this use case. My intent was to get a responsive design that would turn vertical on smaller screens. This is why I didn't use tables. Any help is appreciated. If I need to provide more info, let me know.


回答1:


Use fixed grid columns classes like "col-md-2" for all these three content divs in a line with a offset between each of them by using "col-md-offset-1", this will give spaces between them and your content's text will never spread like in above image maintaining the fixed width.



来源:https://stackoverflow.com/questions/19946033/bootstrap-row-text-pushing-columns-down

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!