Bootstrap 4文本环绕另一列/图像

时间:2018-02-09 12:02:09

标签: html5 image css3 bootstrap-4 wrapping

嗨我的问题是我的文字没有用引导程序4环绕我的图像。而不是环绕它保持在右边,也许我不应该将图像放在单独的列中?

这两个图像必须在彼此的顶部,但我需要文本在它的右侧,当屏幕变小并且文本高度大于它需要环绕的两个图像的高度时它们。

另外,如何在调整浏览器大小时使图像DONT调整大小,以便它们始终保持相同的大小。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>


<section id="about">
    <div class="container">
        <div class="row">

            <div class="col-lg-6 col-md-12 col-sm-12">
                <h1>About</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
                    Illo suscipit facilis ipsum ullam reiciendis odio error
                    iste neque ratione libero rem accusamus voluptatibus, nihil
                    unde maiores sunt nisi. Assumenda, consectetur.
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
                    Illo suscipit facilis ipsum ullam reiciendis odio error
                    iste neque ratione libero rem accusamus voluptatibus, nihil
                    unde maiores sunt nisi. Assumenda, consectetur.
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
                    Illo suscipit facilis ipsum ullam reiciendis odio error
                    iste neque ratione libero rem accusamus voluptatibus, nihil
                    unde maiores sunt nisi. Assumenda, consectetur.
                </p>
            </div>

            <div class="col-lg-6 col-md-12 col-sm-12">
                <div class="row">
                    <div class="col-12">
                        <h1>About</h1>
                    </div>
                    <div class="col-6">
                        <div class="row">
                            <div class="col-12">
                                <img src="http://via.placeholder.com/350x150" alt="" style="width: 100%;
    margin-bottom: 25px;" class="about-img">
                            </div>
                            <div class="col-12">
                                <img src="http://via.placeholder.com/350x150" alt="" style="width: 100%;
    margin-bottom: 25px;" class="about-img">
                            </div>
                        </div>
                    </div>
                    <div class="col-6">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
                            Illo suscipit facilis ipsum ullam reiciendis odio error
                            iste neque ratione libero rem accusamus voluptatibus, nihil
                            unde maiores sunt nisi. Assumenda, consectetur.
                        </p>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
                            Illo suscipit facilis ipsum ullam reiciendis odio error
                            iste neque ratione libero rem accusamus voluptatibus, nihil
                            unde maiores sunt nisi. Assumenda, consectetur.
                        </p>
                    </div>
                </div>
            </div>

        </div>
    </div>
</section>

1 个答案:

答案 0 :(得分:1)

您应该将图片和文字放在同一个col中。在图像上使用float-left来包围文本。

https://www.codeply.com/go/GNkJjFkPfP

<div class="row">
    <div class="col-12 mb-3">
        <img src="http://via.placeholder.com/350x150" class="float-left mr-3 about-img">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
        Illo suscipit facilis ipsum ullam reiciendis odio error
        iste neque ratione libero rem accusamus voluptatibus, nihil
        unde maiores sunt nisi. Assumenda, consectetur.
    </p>
    </div>
    <div class="col-12 mb-3">
        <img src="http://via.placeholder.com/350x150" class="float-left mr-3 about-img">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
            Illo suscipit facilis ipsum ullam reiciendis odio error
            iste neque ratione libero rem accusamus voluptatibus, nihil
            unde maiores sunt nisi. Assumenda, consectetur.
        </p>
    </div>
</div>

看起来你有很多不必要的行&gt; col嵌套。如果您不希望图片调整大小,请移除width:100%