【问题标题】:setting image next to text without text wrapping around image with tailwind将图像设置在文本旁边,而不用顺风环绕图像
【发布时间】:2021-04-24 20:56:07
【问题描述】:

我有这个网页布局,我希望文本在图像的右边 但是如果按高度文本扩展它不会像这样溢出到图像下方的左侧:

我的代码如下所示:

 <div class="content py-2 px-10">
            <img class="w-48 h-48 float-left " src="#" alt="">
            <div class="item-body ">
              lorem ...
            </div>
          </div>

我在我的图像上使用 float-left,它让文本位于右侧,但如果文本远离图像高度,它会像这样低于图像:

我尝试将float-right 添加到我的项目正文中,但随后整个文本都位于我的图片下方。

我尝试添加 clear 属性,但似乎没有任何效果。

【问题讨论】:

    标签: css tailwind-css


    【解决方案1】:

    <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"/>
    <div class="content flex py-2">
                <img class="w-48 h-48" src="#" alt="">
                <div class="item-body px-2 ">
                  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 the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
    
    The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
                </div>
              </div>

    请从图像中删除 float-left 类并将 flex 类添加到您的父 div 中

    【讨论】:

      猜你喜欢
      • 2015-06-15
      • 2016-12-11
      • 2016-01-06
      • 1970-01-01
      • 2017-11-11
      • 2013-09-16
      • 2013-05-10
      • 2021-05-06
      • 1970-01-01
      相关资源
      最近更新 更多