简体   繁体   English

如何使文本环绕重叠的div标签

[英]how do make text wrap around a overlapping div tag

This is what I have so far: http://imgur.com/gucAcBM 这是我到目前为止: http//imgur.com/gucAcBM

I want the text to wrap around the sidesideheading and sideside elements that overlap the side element instead of going under it. 我希望文本环绕侧面元素和侧面元素重叠而不是在它下面。

HTML: HTML:

<div>
    <div>
        Text Text Text Text Text Text Text Text Text Text Text Text Text
    </div>
    <br>
    <div id="sidesideheading">
    </div>
    <div id="sideside">
    </div>
</div>

You will not be able to float the text around the fixed position element. 您将无法在固定位置元素周围浮动文本。 Fixed or absolute positioning will take the element out of it's natural flow and the text can not detect where to wrap around. 固定或绝对定位将使元素脱离其自然流动,并且文本无法检测到环绕的位置。

You have to come up with another solution if you want pure css or use Javascript to position the element inside the wrapper as a user scrolls the page, which is not ultimately the best solution. 如果你想要纯CSS或者在用户滚动页面时使用Javascript将元素放在包装器内,你必须提出另一个解决方案,这最终不是最好的解决方案。 You could also just set padding or margin on the right side of pside div and forget about wrapping text - this will lead the text to not wrap around the aside element but neither will the text go under it. 您也可以在pside div的右侧设置paddingmargin ,并忘记包装文本 - 这将导致文本不包围在旁边元素,但文本也不会在其下面。

One more note. 再说一遍。 You should not have multiple divs with the same id on the same page. 您不应该在同一页面上有多个具有相同ID的div。 Use classes instead. 请改用类。

HTML: HTML:

<div class="pside"></div>

CSS: CSS:

.pside {
  // What ever css declarations here
}

You cannot assign, same id to multiple elements. 您不能为多个元素分配相同的ID。 But now quick fix is 但现在快速修复了

#pside{
    padding-right:16%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM