I am creating an 2 column grid using jquery mobile. By default both the columns take 50% width. I want to customize in such a way that first column will take content size and the remaining space is allotted to column B. Any help as how this can be achieved.
You can do this easily with a TABLE:
<table class="tblcontainer">
<tr>
<td class="fluidCell"><input type="search" name="search" id="txt" placeholder="Search something" /></td>
<td class="fixedCell" >Go</td>
</tr>
</table>
.tblcontainer {
width: 100%;
}
.tblcontainer .fixedCell {
width: 1%;
padding-left: 8px;
}
Working DEMO
Related
the first column is clickable and works fine. But now, I'd like to make the entire row clickable based on that same URL. And as each row prints, I'd like each row clickable with that respective URL that is dynamically created.
Sort of like wrapping all the td's for each row within "< a > < /a >"
But not sure how to do ... I saw an example using a databind click in the < tr >. But I'm not sure how to wrap all the tds within that URL, etc.
TIA.
<tbody data-bind="foreach: items">
<tr>
<td style="width: 300px"><h4><a data-bind="text: Name, attr: {href: $root.rootBaseUrl() + 'Items/' + ID}"></a></h4></td>
<td style="width: 400px"><h4><span>Link this as well</span></h4></td>
<td style="width: 400px"><h4><span>Link this as well</span></h4></td>
</tr>
</tbody>
I want to create a table that has drag-and-drop sortable items within a single column but where the movement of an item in an individual column will not impact the position of items in other columns.
The code below sorts entire rows (both left and right columns), not just the right column. It doesn't seem to be addressed in the JQuery UI docs. Has anyone tried to do this before?
<script>
$(function() {
$("table tbody").sortable({
handle: '.handle'
}).disableSelection();
});
</script>
<table>
<tbody id="sortable">
<tr>
<td>1 - Column Item I Want to Stay In Place</td>
<td class="handle">Item 1 - The Part That Should Be Draggable/Sortable</td>
</tr>
<tr>
<td>2 - Column Item I Want to Stay In Place</td>
<td>Item 2 - The Part That Should Be Draggable/Sortable</td>
</tr>
<tr>
<td>3 - Column Item I Want to Stay In Place</td>
<td class= "handle">Item 3 - The Part That Should Be Draggable/Sortable</td>
</tr>
</table>
I don't believe you can do that with table cells (at least I couldn't get it to work with normal sortables).
There is another option though. Instead of using a table, you could use lists that look like tables.
You can set up a style for columns to define their widths:
.column {
width: 100px;
list-style: none;
float: left;
}
Then, define each column as a list:
<ul class="column">
<li>Fixed 1</li>
<li>Fixed 2</li>
</ul>
<ul class="sortable column">
<li>Sortable 1</li>
<li>Sortable 2</li>
</ul>
<ul class="sortable column">
<li>Sortable 3</li>
<li>Sortable 4</li>
</ul>
Then all you have to do is apply your sortable to the sortable lists:
$(".sortable").sortable();
Here is a fiddle to illustrate: demo
Another option would be to disregard sortables completely and use draggable and droppable controls instead. You would have to manually alter the DOM though using the "drag" and "drop" events of these controls.
As you can see here: http://jsfiddle.net/kralco626/3BYDu/
The icon does not show up when you use display:inline
How do I get around this?
Useui-icon, before of the ui-icon-ICON and use the CSS display:inline-block should work properly
<span class="ui-icon ui-icon-home" style="display: inline-block"/>
<table>
<thead>
<th>
<div style="float:left">My Header</div>
<div style="float:left" class="ui-icon ui-icon-triangle-1-n"></div>
</th>
</thead>
</table>
Edit for formatting.
Well, I guess you could try inline-block instead of inline.
I'm using jQuery UI icons in a table and they take up the size of the table cell, which is elongated horizontally.
Q: What html/css is necessary to make the icon have the same width as it's height?
Here's what I have so far:
<td class="delete">
<div class="ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-circle-minus"></span>
</div>
</td>
If the result you are expecting is the icon wrapped in a rounded box then you have to do set the container div a width of 16px, like here:
http://jsfiddle.net/marcosfromero/n2tYP/
#wanted .delete div {
width: 16px;
}
Not entirely sure if this is what you want, but maybe you need to set the behaviour of the div so that it does not fill 100%. Like this:
<table>
<td class="delete">
<div class="ui-state-default ui-corner-all" style="display:table">
<span class="ui-icon ui-icon-circle-minus"></span>
</div>
</td>
</table>
The div's display style is changed so that it does not scale to full width.
I can't tell if you want a jQuery specific answer or just a css answer. Since I don't know the former here's the latter. If you want to limit the width to known pixels and have the height adjusted so that it maintains the proper aspect ratio, a style like
img{width=32px; height= auto;}
should do the trick. Since most icons are square and of known size I would think
img{width=32px; height=32px;}
would work out too.
I don't understand. Are you sure some other CSS in your page isn't causing this problem?
jQuery UI CSS uses the background-image property to display images, and generally those images shouldn't be "taking up the size" of its parent.
I put together a quick jsFiddle with the following contents:
Dependencies:
jQuery 1.5.1
jQuery UI 1.8.9
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/ui-lightness/jquery-ui.css
HTML:
<table>
<tr>
<td class="delete">
<div class="ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-circle-minus"></span>
</div>
</td>
<td class="delete">
<div class="ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-arrowthick-1-w"></span>
</div>
</td>
</tr>
</table>
<br />
<table>
<tr>
<td class="delete">
<div class="ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-circle-minus"></span>
Hello
</div>
</td>
<td class="delete">
<div class="ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-arrowthick-1-w"></span>
world!
</div>
</td>
</tr>
</table>
CSS:
/* Extend the width ... */
td.delete { width: 100px; }
And it came out looking fine in Google Chrome:
Is there a particular browser this is happening on for you? Can you provide a concrete example?
I am creating an Index page in an MVC 1.0 application and want to right-align the text in one of the columns. I have tried to do this by creating an extra class in the td style and setting the "text-align: right" in this but this doesn't appear to be being applied to that element.
In my CSS file I have:
table td
{
padding: 5px;
border: solid 1px #e8eef4;
}
table td.numeric
{
text-align: right;
}
In my view I have:
<table>
<tr>
<th>Location</th>
<th>Duration</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td><%= Html.Encode(item.Location.Description) %></td>
<td class="numeric"><%= Html.Encode(itemDuration) %> min</td>
</tr>
<% } %>
</table>
Why wouldn't the text-align style be being used?
It works for me. Are you sure you don't have another CSS property overriding this one?
Also, have you checked to make sure your table width is such that you can actually see that the second td is right aligned? My guess is that your table isn't expanding properly. Try changing it's tag to:
<table width="100%">
Make sure you are importing the style sheet in your view.
That should do it. Check for other conflicting styles in your stylesheet. If you're using a CSS reset, it might be in that.