Wrap text around an image on bootstrap 3

你离开我真会死。 提交于 2020-02-01 19:02:24

问题


I came across an issue with wrapping the text around my image on my column. I have a template that It's running multiple pages. some of the images are not long enough so it wont be able to over the entire column... I realize that they are in 2 different divs but if anyone has a solution to this please let me know.

If you read and see what the issue is, you'll see its not a duplicate....

here's what my code looks like

    <div class="row" data-sf-element="Row">
  <div id="contentPlaceholder_C002_Col00" class="sf_colsIn col-md-6" data-sf-element="Column 1">
    <div>
      <div>
        <h2>Contrary to popular belief, Lorem Ipsum is not simply r</h2>
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during th</p>
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during th</p>
      </div>
    </div>
  </div>
  <div id="contentPlaceholder_C002_Col01" class="col-md-6" data-sf-element="Column 2"> <img src="/images/default-source/careers/careers_1.jpg?sfvrsn=2" title="careers_1" alt="careers_1"> </div>
</div>

回答1:


When using 2 columns the text will never get wrapped around the image.

You should put the image and text in one column and give it full with. Then wrap the text and image in a div and float them to the left. Something in the line of this (code is an example and not tested):

<div class="col-md-12">
   <div class="pull-left"><img src="YourImage.png"/></div>
   <div class="pull-left">Your text goes here......</div>
</div>

You might need some margin on the image so the text doesn't stick to close to the image




回答2:


This works for me.

<div class="col-md-12">
<img src="img/image.jpg" class="pull-left">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste molestiae aliquam optio mollitia, unde quas eaque voluptatem dignissimos eos maiores magni reprehenderit nisi, corrupti nemo hic id cum quasi officiis!</p>
</div>



回答3:


I have 2 columns on this page, each with a text-wrapped image, a title, subtitle, text and link. I nest the image in its own column within the text column to wrap the text. This code converts to full column width when displayed on mobile. I'm sure you could pull-right if you wanted to, but this works for me. See code in action at http://www.lbch.org/_Employment.html.

<div class="container">
  <div class="row">
    <div class="col-xs-12">Page Head Title & Text</div>
    <div class="col-xs-12 col-md-6">
      <div class="col-xs-12 col-md-5">
        <img src="image" class="img-responsive" alt=""/> <br> 
      </div>
      <div class="text-left">
        <h4 class="text-center">
            <strong>Article Title</strong><br>
            <small>Article sub-title</small>
        </h4>
        <p>Text</p>
        <p><a href="link">link text</a><strong> </p>
      </div>
    </div>
    <div class="col-xs-12 col-md-6">
      <div class="col-xs-12 col-md-5">
        <img src="image" class="img-responsive" alt=""/> <br> 
      </div>
      <div class="text-left">
        <h4 class="text-center">
          <strong>Article Title</strong><br>
          <small>Article sub-title</small>
        </h4>
        <p>Text</p>
        <p><a href="link">link text</a><strong> </p>
      </div>
    </div>
  </div> <!--row-->
</div> <!--container-->



回答4:


It's far easier to just add a small margin to the image in Adobe Photoshop, then use the img src="img/blog/image.png" class="pull-left The copy flows round the image without you needing to add any styling.

I just add a 10px white space to the left and bottom of the image.




回答5:


None of these worked for me. My working code using rails 5.2 and bootstrap 4.1:

<div class="row">
  <div class="col">
    <img src="<%=url_for(@user.image)%>" class="float-left" style="height:150px;margin-right:10px">
       <p>A bunch of text</p>
       <p>More text</p>
  </div>
</div>



回答6:


But if you want your text and image side by side, Then this would help you.

<div class="row">
<p class="col-md-8">Text goes here....</p>
<img class="img-circle col-md-4" src="image goes here..." alt="image text">
</div>


来源:https://stackoverflow.com/questions/33003868/wrap-text-around-an-image-on-bootstrap-3

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