我希望#text1
右侧显示#video1
个展示,#text2
右侧显示#video2
,但现在,#text2
也显示在右侧#video1
。所以有人可以解释为什么会这样吗?以及如何解决它?
<style>
#video1, #video2
{
float: left;
margin: 20px 20px 0 0;
}
</style>
<div id="video1">
<iframe src="http://player.vimeo.com/video/65706935" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
<div id="text1">
this is text1
</div>
<div id="video2">
<iframe src="http://player.vimeo.com/video/67739892" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
<div id="text2">
this is text2
</div>
答案 0 :(得分:0)
你应该用“wrap”id将你的部分包装到单独的div中,并将#text #video Div浮现在其中:
<style>
#text1, #text2 {
float: right;
margin: 20px 20px 0 0;
}
#video1, #video2 {
float: left;
width: 100px;
}
.wrap {
width: 650px;
float: left;
border: 1px solid red;
margin: 20px 20px 0 0;
}
</style>
<div class="wrap">
<div id="video1">
<iframe src="http://player.vimeo.com/video/65706935" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
<div id="text1">
this is text1
</div>
<div style="clear: both"></div>
</div>
<div class="wrap">
<div id="video2">
<iframe src="http://player.vimeo.com/video/67739892" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
<div id="text2">
this is text2
</div>
<div style="clear: both"></div>
</div>
答案 1 :(得分:0)
我编辑了你的代码,它运行正常。首先编辑 html :
<div id="video1">
<span class="desc">this is text1</span>
<iframe src="http://player.vimeo.com/video/65706935" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<div class="endfloat"></div>
</div> ....
CSS :
.endfloat{ clear: both; margin: 0; padding: 0; }
#video1, #video2
{
float: left;
margin: 20px 10px 0 0;
} ....
检查this fiddle是否有完整代码。希望这会有所帮助。