I try to load some HTML code into a jQueryUI dialog by AJAX. The code itself is a list, where rightmost elements should be absolutely positioned so that the list looks like a table with two columns, but only in some rows. The problem is that jQueryUI plugin does not seem to be correctly resizing the dialog's width, which I think is due to the absolute positioning of some li's. I have read some answers to other similar questions, but none helped me out with this.
This is the code I load:
<style type="text/css">
ul {list-style-type:none;margin:0px;padding:0px;}
ul ul {margin:0px;padding:0px;}
ul>li.fila {margin-bottom:5px;padding-bottom:5px;}
ul li.fila ul li
{
display:inline;
padding-left:20px;
position:relative;
margin-bottom:10px;
}
ul li.fila ul li.O
{
background:url(bullet.gif) 5px 8px no-repeat;
list-style-position:inside;
}
</style>
<ul id="raiz" >
<li class="fila">
<ul >
<li style="position:absolute;left:0px;" class="O">
<label for="col1">Col1:</label>
<input type="text" name="col1" id="col1" value="vCol1" class="text ui-widget-content ui-corner-all" />
</li>
<li style="left:250px;" class="O" >
<label for="col2">Col2:</label>
<input type="text" name="col2" id="col2" value="vCol2" class="text ui-widget-content ui-corner-all" />
</li>
</ul>
</li>
<li class="fila">
<ul >
<li>
<label for="col3">Col3:</label>
<input type="text" name="col3" id="col3" value="vCol3" class="text ui-widget-content ui-corner-all" />
</li>
</ul>
</li>
</ul>
And the Dialog constructor:开发者_Python百科
$("#dialog").dialog({
bgiframe: true,
autoOpen: false,
height: 'auto',
width: 'auto',
modal: true,
buttons:{
'Cancel': function() {
$(this).dialog('close');
}
},
open: function(event,ui){
$("#dialog").load("dialogCode.html");
}
});
Thanks in advance for any suggestions.
if you wish to display your List elements in tabular format, use FLOAT property of CSS and not Absolute positioning.
I have updated the HTML code and it works fine now
<style type="text/css">
ul {list-style-type:none;margin:0px;padding:0px;}
ul ul {margin:0px;padding:0px; clear:both}
ul>li.fila {margin-bottom:5px;padding-bottom:5px;}
ul li.fila ul li
{
display:inline;
padding-left:20px;
position:relative;
margin-bottom:10px;
}
ul li.fila ul li.O
{
background:url(bullet.gif) 5px 8px no-repeat;
list-style-position:inside;
}
</style>
<ul id="raiz" >
<li class="fila">
<ul >
<li style="position:relative; float:left;left:0px;" class="O">
<label for="col1">Col1:</label>
<input type="text" name="col1" id="col1" value="vCol1" class="text ui-widget-content ui-corner-all" />
</li>
<li style="position:relative; float:left;" class="O" >
<label for="col2">Col2:</label>
<input type="text" name="col2" id="col2" value="vCol2" class="text ui-widget-content ui-corner-all" />
</li>
</ul>
</li>
<li class="fila">
<ul >
<li style="position:relative; float:left;">
<label for="col3">Col3:</label>
<input type="text" name="col3" id="col3" value="vCol3" class="text ui-widget-content ui-corner-all" />
</li>
</ul>
</li>
</ul>
精彩评论