0

の右に表示したい#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>
4

2 に答える 2

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>
于 2013-07-23T03:43:51.947 に答える
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;
} ....

完全なコードについては、このフィドルを確認してください。お役に立てれば。

于 2013-07-23T03:57:53.797 に答える