0

画像と入力フィールドの配置に問題があります。それらは千鳥状に配置されています。それらをまっすぐな水平線上に並べて配置したい. 下の画像で問題を確認できます。

画像

ライブデモ

HTML:

    <div id="wrapper">

            <!--Inbox list and button to add a card-->
            <div id="inboxList" class="cellContainer">
                <p style="display: inline">Inbox</p> 
                <!--Button to add a Card-->
                <input type="button" id="AddCardBtn" value="+ Add a Card..."/> 
                <hr class="fancy-line"/> <br/>

                <!--Card div-->
                <div id="userAddedCard"> <br/>
                    <div>

                    </div>
                </div>
            </div>


        </div>

Jクエリ:

var $div = $('<div />').addClass('sortable-div'); 
    $('<img />', { "src": "/Pages/Images/calendar.png" }).addClass('image').appendTo($div);
    $('<input/>', { "type": "text", "class": "ctb" }).addClass('ctb').appendTo($div);

CSS:

.ctb {
    display:inline-block;
    width: 20px;    
    padding-left:2%;
}

.image {
    display:inline-block;
    height:19px;
    width:19px;
    padding-top:7%;
    padding-left:5%;

}
4

5 に答える 5

2

vertical-align: bottom を .image 要素に追加すると、すべてが正しく整列するはずです。

于 2014-04-04T08:26:48.337 に答える
1

クラスCSSに追加

.ctb
{
vertical-align: bottom;
padding: 0px 0px 0px 2%;
margin: 0px;
}
.image
{
vertical-align: bottom;
}
于 2014-04-04T08:30:12.023 に答える
1

これが私のFiddleです。次のクラスを更新しました

CSS:

.image {
    display:block;
    float:left;
    height:19px;
    width:19px;
    padding-left:5%;
     margin-top: 0.4%;
}


#inboxList {
    width: 275px;
    height: 700px;
    background-color: #f0f0f0;
    border: 1px solid black;
    margin-left: 0.5%;
    margin-top: 0.4%;
    border-radius: 10px;
    box-shadow: 7px 7px 7px #828282;
    overflow: auto;
    display:inline-block;
}
于 2014-04-04T08:30:44.667 に答える
1

更新された Fiddle を確認してください。

デモ更新

<!--Card div-->
        <div id="userAddedCard"> <br/>

        </div>
  .image {
   display:inline-block;
   height:19px;
   width:19px;
   /*padding-top:7%;
   padding-left:5%;
   padding-right:2%;*/
   vertical-align:top;

}

乾杯 :)

于 2014-04-04T08:29:00.083 に答える
1

display: block;代わりにテキストと画像の両方に適用する必要がありますdisplay:inline-block;

.ctb {
    display: block;
    width: 20px;    
    padding-left:2%;
}

.image {
    display: block;
    height:19px;
    width:19px;
    padding-top:7%;
    padding-left:5%;

}

更新されたフィドル

于 2014-04-04T08:29:44.247 に答える