2016-03-17 148 views
2

我正在寻找一种方法来包装文本填充div div围绕另一个div。 Like this.如何在另一个div上包含包含文本的div?

看来我可能错过了一个重要的细节。文字需要包裹嵌入的YouTube视频。这似乎不适用于你提供的所有答案,我已经尝试了所有给出的例子,一旦我嵌入视频,文本消失。

+0

看起来你只是想

在CSS .litle {浮动:剩下;} – Seichi

回答

1

将两个div都包装在'容器'div中,并给'div1'使用float作为样式。这会给你想要的结果。请参阅下面的代码。

<div class="container"> 
    <div class="div1" style="float:left; width: 150px; height: 150px; margin: 10px; background-color: #ff0000;"></div> 
    <div class="div2">Wrapping text comes here.</div> 
</div> 
1

你可以把DIV 1 DIV 2

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8" /> 
    <title>Div Test</title> 
    <style> 
     .outer { 
      width:800px; 
      height:600px; 
      background-color:#22e; 
     } 

     .inner { 
      width:300px; 
      height:200px; 
      background-color:#e22; 
     } 
    </style> 
</head> 
<body> 
    <div class="outer"> 
     <div class="inner"> 
     </div> 
    </div> 
</body> 
</html> 
2

您可以使用float: left,然后.content会,如果它在DOM未来把它包

.wrapper { 
 
    border: 1px solid blue; 
 
} 
 
.left { 
 
    float: left; 
 
    width: 100px; 
 
    height: 100px; 
 
    background: red; 
 
    margin: 0 10px 10px 0; 
 
}
<div class="wrapper"> 
 
    <div class="left"></div> 
 
    <div class="content"> 
 
    The English word world comes from the Old English weorold (-uld), weorld, worold (-uld, -eld), a compound of wer "man" and eld "age," which thus means roughly "Age of Man."[3] The Old English is a reflex of the Common Germanic *wira-alđiz, also reflected in Old Saxon werold, Old High German weralt, Old Frisian warld and Old Norse verǫld (whence the Icelandic veröld).[4] 
 

 
The corresponding word in Latin is mundus, literally "clean, elegant", itself a loan translation of Greek cosmos "orderly arrangement." While the Germanic word thus reflects a mythological notion of a "domain of Man" (compare Midgard), presumably as opposed to the divine sphere on the one hand and the chthonic sphere of the underworld on the other, the Greco-Latin term expresses a notion of creation as an act of establishing order out of chaos. 
 

 
'World' distinguishes the entire planet or population from any particular country or region: world affairs pertain not just to one place but to the whole world, and world history is a field of history that examines events from a global (rather than a national or a regional) perspective. Earth, on the other hand, refers to the planet as a physical entity, and distinguishes it from other planets and physical objects. 
 

 
'World' distinguishes the entire planet or population from any particular country or region: world affairs pertain not just to one place but to the whole world, and world history is a field of history that examines events from a global (rather than a national or a regional) perspective. Earth, on the other hand, refers to the planet as a physical entity, and distinguishes it from other planets and physical objects. 
 
    </div> 
 
</div>