javascript - 外部 div 内容进入内部 div

标签 javascript jquery html css

您好,我需要一个内嵌 2 个 div。 HTML 代码如下:-

<div style="width: 500px; height: 500px; border: 1px solid red; position: relative">
<div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).


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.



</div>

    <div style="position: absolute; right: 0; top: 0; width: 200px; height: 100px; border: 1px solid green;">
    </div>
</div>

使用上面的代码,我得到以下输出:-

enter image description here

内容进入内部div。

我将如何解决这个问题?

我是 HTML 的新手。所以任何帮助将不胜感激。 谢谢。

最佳答案

试试这个,我稍微更改了你的 html

<div style="width: 500px; height: 500px; border: 1px solid red;">
<div>
     <div style="float:right; width: 200px; height: 100px; border: 1px solid green;">
    </div>
<p >Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).


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.

    </p>

</div>

</div>

关于javascript - 外部 div 内容进入内部 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29183605/

相关文章:

asp.net - JavaScript 中 window.onback 的意外行为?

javascript - 初始化 HandsOntable 时摆脱 TypeError

javascript - JQuery Draggable 对象,设置包含动态 div 标签

javascript - 使用 CSS 将超链接按钮添加到 Jquery Loopedslider

javascript - 未捕获的 TypeError : $(. ..).tooltipster 不是函数

javascript - audio.play() 不是函数。

javascript - 页面刷新时倒计时器重置

javascript - html 元素的 value 属性未定义

html - 如何将容器中的图像链接居中?

html - 播放声音的最有效方法(一页中有许多播放按钮)