簡體   English   中英

如何設置div的水平滾動,以便在通過jQuery添加項目時

[英]how to set horizontal scroll for div such that when adding items by jQuery

我在jQuery的div中添加了復選框。 Div是溢出時滾動。 但是我看到,當復選框名稱較大時,div不會水平滾動,但是多余的內容會進入下一行,而垂直滾動會很好。 下面是一些代碼

下面是div創建的代碼

<div id="legendBox" style="overflow:scroll;width:145px;height:300px;"></div>

此代碼是在DIV中添加復選框

if (legendChecked == "T")
                {
                    legendtest = "<input type='checkbox' class='" + legendClass + "' name='" + legendName + "' style='background-color:" + legendColor + "' value='" + legendName + "' checked onClick=legendChanged();  title='" + legendName + "' />" + legendName;
                } else
                {
                    legendtest = "<input type='checkbox' class='" + legendClass + "' name='" + legendName + "' style='background-color:" + legendColor + "' value='" + legendName + "' onClick=legendChanged();  title='" + legendName + "' />" + legendName;
                }
                $("#legendBox").append(legendtest+"</br>");

請告訴我哪里錯了。

或添加display:inlinehttp : //jsfiddle.net/eq3r9/

編輯:這是一個更好的解決方案: http : //jsfiddle.net/eq3r9/1/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM