0

ここに JSFiddle があります: http://jsfiddle.net/PEHbr/1 何らかの理由で、画像の高さを 50% に設定できません。

<div class="column img">
    <div class="images right">
        <img src="{path-to-image}" />
    </div>
</div>

CSS:

.row {
    display: table-row;
    width: 100%;
}
.column { display: table-cell; height: 100%; position: relative; }
.img {  width: 22%; }
.txt { width: 50%; vertical-align: middle; }
.text p {
    width: 90%;
    margin: 10px auto;
    line-height: 1.5;
    white-space: pre-wrap;
    font-size: 18px;
    font-family: Lato;
}
.right { text-align: right; }
.images { height: 100%; position: relative; }
.images img { height: 50%; }

画像の高さを正しく編集できないのはなぜですか?

編集:

画像の を置き換えました。src高さと正方形よりも幅の広い画像で動作しますが、使用したい画像は背の高い長方形であり、機能しません。どうしてこれなの?

4

2 に答える 2

0

下のページの左フレームでこのコードを確認してください

http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro

<style type="text/css">
    .row {
        display: table-row;
        width: 100%;
    }

    .column {
        display: table-cell;
        height: 100%;
        position: relative;
    }

    .img {
        width: 22%;
    }

    .txt {
        width: 50%;
        vertical-align: middle;
    }

    .text p {
        width: 90%;
        margin: 10px auto;
        line-height: 1.5;
        white-space: pre-wrap;
        font-size: 18px;
        font-family: Lato;
    }

    .right {
        text-align: right;
    }

    .images {
        height: 100%;
        position: relative;
    }

        .images img {
            height: 50%;
        }

    .images20 img {
        height: 20%;
    }
    /* 50% */
</style>

<div class="column img">
    <div class="images right">
        <img src="http://2.179.254.185/images/button/signout.png" />
    </div>
</div>


<div class="column img">
    <div class="images20 right">
        <img src="http://2.179.254.185/images/button/signout.png" />
    </div>
</div>

于 2013-09-28T23:45:51.837 に答える
0

それは私のために働いた。プロジェクトに別の css ファイルまたはコードがあり、画像のサイズが変更されている可能性があります!!!

<style type="text/css">
    .row {
        display: table-row;
        width: 100%;
    }

    .column {
        display: table-cell;
        height: 100%;
        position: relative;
    }

    .img {
        width: 22%;
    }

    .txt {
        width: 50%;
        vertical-align: middle;
    }

    .text p {
        width: 90%;
        margin: 10px auto;
        line-height: 1.5;
        white-space: pre-wrap;
        font-size: 18px;
        font-family: Lato;
    }

    .right {
        text-align: right;
    }

    .images {
        height: 100%;
        position: relative;
    }

        .images img {
            height: 50%;
        }

    .images20 img {
        height: 10%;
    }
</style>

<div class="column img">
    <div class="images right">
        <img src="img.jpg" />
    </div>
</div>


<div class="column img">
    <div class="images20 right">
        <img src="img.jpg" />
    </div>
</div>

于 2013-09-28T23:42:23.943 に答える