0

これを適切に説明する方法がわかりませんが、ブロックをラップする要素のリストを取得しようとしています。

ここに私が意味するもののイメージがあります: ここに画像の説明を入力

コードは以下です。ブロックが 2 つしかない場合は左に正しくフロートしますが、さらに追加するとウェルカム ブロックの下に落ちます (画像のように)。

このデザインでは、ウェルカム ボックスの横に 2 つのブロックが表示され、その下に 3 つのブロックが表示されます。したがって、画像では、3 番目のブロックがウェルカム ブロックの下に配置され、後続のブロックは通常どおり続行されます (1 行あたり 3 ブロック)。

CSS

#welcome-block {
float: left;
width: 300px;
background: #fff;
}

#bingo-offers {
float: left;
margin: 0;
padding: 0;
overflow: hidden;
}
    .bingo-offer {
    float: left;
    width: 300px;
    background: #fff;
    margin: 5px;
    }
        .bingo-offer ul {
        margin: 0;
        padding: 0;
        }

HTML

<div>
        <div id="welcome-block">
            <h2>Welcome to Zesty Bingo</h2>
            <p>Zesty Bingo is the home of FREE Bingo!</p>
            <p>We have a huge selection of Bingo games to choose. Simple find a game, and click play. It’s as simple
            as that.</p>

            <p>Ensure you click the read more link on each game to find out more details and customer reviews on all
            of our hosted games.</p>

            <p>Good Luck and we wish you wealth and happiness from all the Zesty Bingo team.</p>
        </div>

        <ul id="bingo-offers">
            <li class="bingo-offer">
                <ul>
                    <li><img src="../img/winkbingo-146.png" alt=""></li>
                    <li><h3>Wink Bingo</h3></li>
                    <li>Free Cash: <span>£20</span></li>
                    <li>Join one of the biggest Bingo sites on the Internet and enjoy a whopping £20 bonus when you deposit £5!</li>
                    <li><a href="#">Play Now</a></li>
                    <li><a href="#">read more</a></li>
                </ul>
            </li>

            <li class="bingo-offer">
                <ul>
                    <li><img src="../img/winkbingo-146.png" alt=""></li>
                    <li><h3>Wink Bingo</h3></li>
                    <li>Free Cash: <span>£20</span></li>
                    <li>Join one of the biggest Bingo sites on the Internet and enjoy a whopping £20 bonus when you deposit £5!</li>
                    <li><a href="#">Play Now</a></li>
                    <li><a href="#">read more</a></li>
                </ul>
            </li>

            <li class="bingo-offer">
                <ul>
                    <li><img src="../img/winkbingo-146.png" alt=""></li>
                    <li><h3>Wink Bingo</h3></li>
                    <li>Free Cash: <span>£20</span></li>
                    <li>Join one of the biggest Bingo sites on the Internet and enjoy a whopping £20 bonus when you deposit £5!</li>
                    <li><a href="#">Play Now</a></li>
                    <li><a href="#">read more</a></li>
                </ul>
            </li>

            <li class="bingo-offer">
                <ul>
                    <li><img src="../img/winkbingo-146.png" alt=""></li>
                    <li><h3>Wink Bingo</h3></li>
                    <li>Free Cash: <span>£20</span></li>
                    <li>Join one of the biggest Bingo sites on the Internet and enjoy a whopping £20 bonus when you deposit £5!</li>
                    <li><a href="#">Play Now</a></li>
                    <li><a href="#">read more</a></li>
                </ul>
            </li>

            <li class="bingo-offer">
                <ul>
                    <li><img src="../img/winkbingo-146.png" alt=""></li>
                    <li><h3>Wink Bingo</h3></li>
                    <li>Free Cash: <span>£20</span></li>
                    <li>Join one of the biggest Bingo sites on the Internet and enjoy a whopping £20 bonus when you deposit £5!</li>
                    <li><a href="#">Play Now</a></li>
                    <li><a href="#">read more</a></li>
                </ul>
            </li>

            <li class="bingo-offer">
                <ul>
                    <li><img src="../img/winkbingo-146.png" alt=""></li>
                    <li><h3>Wink Bingo</h3></li>
                    <li>Free Cash: <span>£20</span></li>
                    <li>Join one of the biggest Bingo sites on the Internet and enjoy a whopping £20 bonus when you deposit £5!</li>
                    <li><a href="#">Play Now</a></li>
                    <li><a href="#">read more</a></li>
                </ul>
            </li>

            <li class="bingo-offer">
                <ul>
                    <li><img src="../img/winkbingo-146.png" alt=""></li>
                    <li><h3>Wink Bingo</h3></li>
                    <li>Free Cash: <span>£20</span></li>
                    <li>Join one of the biggest Bingo sites on the Internet and enjoy a whopping £20 bonus when you deposit £5!</li>
                    <li><a href="#">Play Now</a></li>
                    <li><a href="#">read more</a></li>
                </ul>
            </li>
        </ul>
    </div>
4

4 に答える 4

0
#welcome-block {
float: left;
width: 300px;
background: #fff;
margin-right: 10px;
}

#bingo-offers {
margin: 0;
padding: 0;
overflow: hidden;
}

#bingo-offers > li.bingo-offer{
    float:left;
    width: 300px;
    background: #fff;
    margin: 5px;
}

cssの上に適用します。方法を確認するには、以下のリンクにアクセスしてください。

http://sandalwoodinteriors.com/view.php?name=Bed%20Room%20Set
于 2013-05-07T10:34:44.040 に答える
0

それはあなたが使用しているからです<ul id="bingo-offers">

それ<ul>自体は左に浮いていますが、それもwidth:100%;

を削除した<ul id="bingo-offers">方が効果的かもしれません。<li>また、に変更することもできます<div>

これを試してください:jsfiddle

于 2013-05-07T10:11:59.430 に答える
0

これらを変更します。

<ul id="bingo-offers">

<li class="bingo-offer">

これらに

<div id="bingo-offers">

<div class="bingo-offer">

更新: まったく使用しないでください<div id="bingo-offers">。そこのタグを削除してください。<div class="bingo-offer">の直後に s を置き<div id="welcome-block">ます。

JSFiddle

于 2013-05-07T10:15:09.473 に答える