0

だから私はcss3仕様について知り、すぐにそれを使って動的に生成されたテーブルを使用するフォーラムリストcolumnsを「近代化」できることに気づきました。

テーブルを生成するコードは、次のデータベース行のデータをテーブルの新しい行に配置するか、新しい列に配置するかを決定するため、非常に複雑です。css3列の方法を使用すると、コードにデータをページに読み取らせ、css3をそのままにして、どの列に何を入れるかを決定できると思います。

しかし、私は少し問題に遭遇しました。これを使用する場合、コンテンツは指定された数の列に分割されません。

参照用のコードは次のとおりです。

.2col {
    column-count: 2;
    column-width: 400px;
    column-gap: 10px;
    column-rule: 1px solid #e1e1e1;
}


<div class="cats 2col">
    <div class="title">
        <div class="t">
            <h2><a href="#" class="sh" id="t1">-</a> Title 1</h2>
        </div>
        
        <section>
            <div class="cat">
                <p>Category 1<span>This is the first category</p>
            </div>
            
            <div class="cat">
                <p>Category 2<span>This is the second category</p>
            </div>
            
            <div class="cat">
                <p>Category 3<span>This is the third category</p>
            </div>
        </section>
    </div>
    
    <div class="title">
        <div class="t">
            <h2><a href="#" class="sh" id="t1">-</a> Title 2</h2>
        </div>
        
        <section>
            <div class="cat">
                <p>Category 1<span>This is the first category</p>
            </div>
            
            <div class="cat">
                <p>Category 2<span>This is the second category</p>
            </div>
        </section>
    </div>
</div>

テスト用にこのJSFiddleを設定しました:http://jsfiddle.net/LYoung/JLVEs/1/

明らかに私は何か間違ったことをしている。誰かが私がそれが何であるか、そしてなぜそれが間違っているのかを特定するのを手伝ってもらえますか?

4

3 に答える 3

0
section {
    position: relative;
    width: 450px;
    border:1px solid red;
    display:block;
}

dl.2col {
    -moz-column-count: 2;
    -webkit-column-count: 2;
    column-count: 2;

    -moz-column-gap: 10px;
    -webkit-column-gap: 10px;
    column-gap: 10px;

    column-rule: 1px solid #e1e1e1;
}

dl.2col dd {
     -moz-column-width: 200px;
     -webkit-column-width: 200px;
     column-width: 200px; 
     display:inline-block ! important;
    float:none;
}​

<section>
<dl class="cats title 2col">
    <dd class="t"><h2><a href="#" class="sh" id="t1">-</a> Title 1</h2></dd>

    <dd class="cat">Category 1<span>This is the first category</span></dd>

    <dd class="cat">Category 2<span>This is the second category</span></dd>

    <dd class="cat">Category 3<span>This is the third category</span></dd>

    <dd class="t"><h2><a href="#" class="sh" id="t1">-</a> Title 2</h2></dd>

    <dd class="cat">Category 1<span>This is the first category</span></dd>

    <dd class="cat">Category 2<span>This is the second category</span></dd>
</dl>
</section>

</ p>

于 2012-12-04T08:46:48.827 に答える
0
section dl.directory {
    margin-left:1em;
    margin-bottom:7px;
    -moz-column-count:2;
    -webkit-column-count:2;
    column-count:2;
    -moz-column-gap:7px;
    -webkit-column-gap:7px;
    column-gap:7px;
    -moz-column-rule:1px solid #D0D2D3;
    -webkit-column-rule:1px solid #D0D2D3;
    column-rule:1px solid #D0D2D3;
}

section dl.directory dd {
    display:inline-block;
    -moz-column-width:225px;
    -webkit-column-width:225px;
    column-width:225px;
    margin:0 5px;
    padding:5px 0;
    border-bottom:1px solid #D0D2D3;
}

section dl.directory dd em {
    font styling here
}
于 2012-12-05T08:34:35.233 に答える
0

私はあなたの例で2つの問題を見つけました:

  • まず、-webkitと-mozのルール
  • そしてあなたのクラスの2col名

JSFiddleでtwoColの2colクラスの名前を変更し、-webkitルールと-mozルールを追加してみましたが、機能しているようです(Fiddleの例はこちら

スタイルにはまだいくつかの問題がありますが、ウィンドウが十分に大きい場合、コンテンツが2列に分割されます

    <div class="cats twoCol">
    <div class="title">
        <div class="t">
            <h2><a href="#" class="sh" id="t1">-</a> Title 1</h2>
        </div>

        <section>
            <div class="cat">
                <p>Category 1<span>This is the first category</p>
            </div>

            <div class="cat">
                <p>Category 2<span>This is the second category</p>
            </div>

            <div class="cat">
                <p>Category 3<span>This is the third category</p>
            </div>
        </section>
    </div>

    <div class="title">
        <div class="t">
            <h2><a href="#" class="sh" id="t1">-</a> Title 2</h2>
        </div>

        <section>
            <div class="cat">
                <p>Category 1<span>This is the first category</p>
            </div>

            <div class="cat">
                <p>Category 2<span>This is the second category</p>
            </div>
        </section>
    </div>
</div>​

                body {
        background: #000;
    }
    .title {
        padding-bottom: 10px;
    }
.twoCol {
    -webkit-column-count: 2;
    -moz-column-count: 2;
    column-count: 2;
    -webkit-column-width: 400px;
    -moz-column-width: 400px;
    column-width: 400px;
    -webkit-column-gap: 10px;
    -moz-column-gap: 10px;
    column-gap: 10px;
    -webkit-column-rule: 1px solid #e1e1e1;
    -moz-column-rule: 1px solid #e1e1e1;
    column-rule: 1px solid #e1e1e1;
}
    h2 {
        font-weight: bold;
        font-size: 20px;
        color: #bede06;
    }
    .t {
        width: 800px;
        column-span: all;
    }
    .t a {
        color: #bede06;
        text-decoration: none;
        font-size: 22px;
    }
    t:after {
        content: '';
        display: table;
    }
    .cat {
        color: #000;
        font-size: 18px;
        border-radius: 5px;
        box-shadow: 0 0 2px #b6bcc6;
        text-shadow: 2px 2px #fff;
        background-image: linear-gradient(bottom, rgb(225,225,225) 37%, rgb(255,255,255) 69%);
        background-image: -o-linear-gradient(bottom, rgb(225,225,225) 37%, rgb(255,255,255) 69%);
        background-image: -moz-linear-gradient(bottom, rgb(225,225,225) 37%, rgb(255,255,255) 69%);
        background-image: -webkit-linear-gradient(bottom, rgb(225,225,225) 37%, rgb(255,255,255) 69%);
        background-image: -ms-linear-gradient(bottom, rgb(225,225,225) 37%, rgb(255,255,255) 69%);

        background-image: -webkit-gradient(
            linear,
            left bottom,
            left top,
            color-stop(0.37, rgb(225,225,225)),
            color-stop(0.69, rgb(255,255,255))
    );
    }
    .cat {
        width: 400px;
        height: 50px;
        margin: 0 0 10px 10px;
        padding-left: 5px;
    }
    .cat span {
        display: block;
        font-style: italic;
        font-size: 14px;
    }​
于 2012-12-05T20:58:38.333 に答える