css - 如何使用 Bootstrap 在容器内制作带有内联图像的文本

标签 css twitter-bootstrap

我一直在寻找这个解决方案,甚至尝试过自己但没有运气。

我想使图像从半宽到浏览器的右边缘

<section class="map-cont">
            <div class="container">
                <div class="row">
                    <div class="col-md-6">
                        <h2 class="main-heading">heading</h2>
                        <p>text</p>
                    </div>
                    <div class="col-md-6">
                        <img src="img/map.jpg" alt="" class="map" />
                    </div>
                </div>
            </div>
        </section>

我想实现这个,请看下图。

enter image description here

最佳答案

您不必编写任何额外的 CSS。只需将 Bootstrap 类“img-responsive”添加到您的图像即可。

<img src="img/map.jpg" alt="" class="map img-resonsive" />

来自Bootstrap 3 documentation :

Images in Bootstrap 3 can be made responsive-friendly via the addition of the .img-responsive class. This applies max-width: 100%;, height: auto; and display: block; to the image so that it scales nicely to the parent element.

To center images which use the .img-responsive class, use .center-block instead of .text-center. See the helper classes section for more details about .center-block usage.

编辑:要给类从 col-md-6 的右侧留出边距,只需像这样覆盖 CSS:

.img-responsive {
   max-width: 50% !important;
}

请注意,这会更改此类的所有图像,因此如果您不希望出现这种情况,您可能需要更具体地定位它。

关于css - 如何使用 Bootstrap 在容器内制作带有内联图像的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39839276/

相关文章:

css - div 和页面底部的 Div 问题

javascript - 如何从原始元素中删除 Bootstrap 标签输入事件

javascript - 使用 jQuery 和 bootstrap 更改复选框的 'checked' 属性(AdminLTE 主题)

javascript - 双击 Bootstrap 图标时防止事件触发

html - 反转侧边栏的 Bootstrap 行行为

html - Bootstrap 3,左侧边栏菜单,重影边框

css - 如何将文本放在两个表格单元格的顶部?

html - 具有特定类的元素的选择器,如果它是其父元素的唯一 "visible"子元素?

php - 下拉隐藏值

javascript - 避免文本因折叠而发生分歧