1

実際に別の JS プラグインをロードすることなく、石積みに似たタイルの列を作成しようとしています。最後の手段として、できると思います。現在の私の問題は、列コンテナー内の div が長い場合にラップされることです。

私のフィドルを参照してください:

http://jsfiddle.net/dLM6A/3/

青いタイルが列全体にまたがっていることに注意してください。強制的に同じ列に残す方法はありますか?

HTML

    <form id="member-form" class="form-standard" action="" method="post">
    <div id="Misc" class="tile-columns">
        <div class="tile">
             <h2 class="tile-title">Notes</h2>

            <textarea id="Notes" name="Notes"></textarea>
        </div>
        <div class="tile" style="background: #5fe;">
             <h2 class="tile-title">Info</h2>

            <div class="field-section">
                <label for="SecQuestion1">Question 1</label>
                <textarea id="SecQuestion1" name="SecQuestion1"></textarea>
                <label for="SecQuestion1Answer">Answer</label>
                <input id="SecQuestion1Answer" name="SecQuestion1Answer" type="text" value="">
            </div>
            <div class="field-section">
                <label for="SecQuestion2">Question 2</label>
                <textarea id="SecQuestion2" name="SecQuestion2"></textarea>
                <label for="SecQuestion2Answer">Answer</label>
                <input id="SecQuestion2Answer" name="SecQuestion2Answer" type="text" value="">
            </div>
        </div>
        <div class="tile">
             <h2 class="tile-title">Reference</h2>

            <textarea id="Reference" name="Reference"></textarea>
        </div>
        <div class="tile">
             <h2 class="tile-title">Another Tile</h2>

            <p>More Content Here</p>
        </div>
    </div>
    <!-- end columns -->
</form>

CSS

body {
    background: #ddd;
    padding: 10px;
    font-family:"roboto condensed";
    font-size: 12px;
}
h2.tile-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
}
.tile {
    background: #ffffff;
}
.tile, .tile-notice {
    margin-bottom: 2px;
    vertical-align: top;
}
.tile-columns {
    -moz-column-count: 2;
    -moz-column-gap: 1;
    -webkit-column-count: 2;
    -webkit-column-gap: 1;
    column-count: 2;
    column-gap: 1;
    width: 689px;
}
.tile-columns .tile {
    width: 323px;
    height: 100%;
    padding: 10px;
}
.form-standard .field-section {
    display:inline-block;
    margin-bottom: 10px;
    vertical-align: top;
}
.form-standard label, .form-standard input, .form-standard textarea {
    display: block;
}
.form-standard input {
    border: 1px solid #ddd;
    padding: 5px;
}
.form-standard textarea {
    width: 300px;
    height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
}
4

1 に答える 1

1

コンテンツを強制的に同じ列に保持する (列をまたがらないようにする) ために、次の行を.tileクラスに追加しました (必要に応じて別の場所に追加できます)。

break-inside: avoid-column;
-webkit-column-break-inside: avoid;
page-break-inside: avoid;

これは Chromium と Firefox で動作しました (テストする IE はありませんが、IE 10 まで動作するはずです)。更新されたフィドルで結果を確認できます: http://jsfiddle.net/dLM6A/11/

page-break-insideプロパティについては、こちらをご覧ください: http://www.w3schools.com/cssref/pr_print_pagebi.asp

于 2014-07-20T03:46:20.160 に答える