I have a list of items I want to display in a table (because I want to leverage the styling from bootstrap). But because I am having issues making the table sortable I want each row to essentially contain two rows, one information row and one detail row.
The information row will have some status icons and the item name. The detail row will have any quantity of text.
I'm using this answer to create two div/span rows within each table row:
<style>
.table-row {
display: table-row;
}
.data_column {
display: table-cell;
}
.icon_column {
width: 20px;
display: table-cell;
}
</style>
<table class="table table-condensed>
<thead>
<tr class="table_header">
<th>
<div class='table-row'>
<span class="icon_column"><i class="icon-ok"></i></span>
<span class="icon_column"><i class="icon-star icon-large"></i></span>
<span class="icon_column"></span>
<span class="data_column">Name</span>
<span class="data_column">Date</span>
</div>
</th>
</tr>
</thead>
<tbody>
{% for action in actions %}
<tr class="item_row">
<td>
<div class='table-row'>
<span class="icon_column"><input type="checkbox"></span>
<span class="icon_column"><i class="icon-star-empty icon-large"></i></span>
<span class="icon_column"><i class="icon-exclamation-sign icon-green"></i></span>
<span class="data_column">{{ action }}</span>
<span class="data_column">{{ action.previous_reset_date|date:"M d" }}</span>
</div>
<div class='table-row'>
<span>{{ action.notes|apply_markup:"creole" }}</span>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
My issue is that the second "table-row" is displaying like an individual column. It doesn't span the width of the entire table. If this were a strict table, I would need to do something like colspan="5". How do I change the css so that this portion:
<div class='table-row'>
<span>{{ action.notes|apply_markup:"creole" }}</span>
</div>
is the width of the entire table row?
If I remove the class from the second div row, it works fine.
<div>
<span>{{ action.notes|apply_markup:"creole" }}</span>
</div>
Related
Using vue I dynamically create multiple td elements with v-for.
<table>
<tr>
<td v-for="(item, index) in navLinks" :key="index">
<span v-if="item.vif">
<router-link
:to="{ name: item.name }"
class="router-links"
style="margin-left: 0rem;"
exact
>{{ item.text }}</router-link>
</span>
<span v-if="showPipe(item, index)">|</span>
<span v-if="showMargin(item, index)"></span>
</td>
</tr>
</table>
Now I want to wrap all tds in another html element, without creating another table. Is this possible?
I have a table with a fixed header, and in one of the columns there are delete buttons within a form:
<div class="panel panel-default table-responsive fixedHeader">
<!-- Table -->
<table class="table table-striped">
<thead>
<tr>
<!--table headers are here-->
</tr>
</thead>
<tbody>
{% for row in hoursDb %}
<tr>
<!-- all rows are called here, just saving space -->
<td>
<form action="" method="post">
<button type="submit" class="btn btn-default" name="delete" value="{{ row[7] }}">
<span class="glyphicon glyphicon-remove"></span>
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
I used the following css to get a fixed header:
.fixedHeader {
height:40vh;
overflow-y:auto;
}
.fixedHeader th {
position: sticky;
top: 0;
}
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 16px; }
th { background:#eee; }
The other row data are hidden by the header when scrolled, but the problem is that when I scroll within the table, the remove glyphicon is still showing and I am able to click on the button which deletes the row.
How would I change it so the table header covers the form/button/glyphicon?
Thanks in advance for any answers.
Have you tried using Z-index? Share snapshot if possible.
This has been bugging me a lot and when I try to google anything related to the subject, all I get is Stack Overflow questions about vertical-align not working on divs or similar elements.
I have this HTML table where as you can see, I set the style of each td to vertical-align:middle through an HTML inline style attribute:
<div ng-hide="getShoppingCart().length===0" class="col-md-10 col-md-offset-1">
<table class="table table-striped">
<tr>
<th class="col-md-2"></th>
<th class="col-md-3">Name</th>
<th class="col-md-2">Size</th>
<th class="col-md-2">Price</th>
<th class="col-md-2">Quantity</th>
<th class="col-md-1"></th>
</tr>
<tr ng-repeat="article in getShoppingCart()" style="height:120px;">
<!-- Image -->
<td class="col-md-2" align="center" style="vertical-align:middle;">
<img ng-src="{{article.media.images[0].smallHdUrl}}" class="img-responsive" style="height:120px;" >
</td>
<!-- Name -->
<td class="col-md-3" style="vertical-align:middle;">
<p>{{ article.name }}</p>
</td>
<!-- Size -->
<td class="col-md-2" style="vertical-align:middle;">
<p>{{ article.unit.size }}</p>
</td>
<!-- Price -->
<td class="col-md-2" style="vertical-align:middle;">
<p>£ {{ getTotalPriceForArticle($index) | number : 2 }}</p>
</td>
<!-- Quantity -->
<td class="col-md-2" style="vertical-align:middle;">
<button class="btn minusButtons" ng-click="decrementQuantity(article, $index)">–</button>
<input type="number" class="form-control" style="position:relative;top:2px;width:4vw;display:inline-block;" ng-model="getQuantities()[$index]"/>
<button class="btn plusButtons" ng-click="incrementQuantity(article, $index)">+</button>
</td>
<td class="col-md-1" align="left" style="vertical-align:middle;">
<button ng-click="removeArticleAtIndex($index)" class="btn redButtons" style="margin-left:0;">
<span class="glyphicon glyphicon-trash"></span>
</button>
</td>
</tr>
</table>
<div class="col-md-12" style="font-size:2vw; text-align:right;">
Total Price: £ {{ getTotalPrice() | number : 2 }}
</div>
So naturally I thought I could remove all of these inline styles and add this global rule in my external CSS file:
td {
vertical-align: middle;
}
But when I do that, the contents of the table's cells stop being aligned to the middle. I'm sure that the CSS file is properly linked as other elements are clearly affected by it. Also I checked the rest of the CSS and there are no other rules with higher priority overriding this property for this table. Any ideas?
Note: As you can probably figure out from the code, I'm using AngularJS and the table rows are being generated using ng-repeat, in case it could have something to do with the problem.
It's due to bootstrap overriding this with a higher specificity. This is what I see in the chrome developer console for td's:
.table>tbody>tr>td {
padding: 8px;
line-height: 1.42857143;
vertical-align: top;
border-top: 1px solid #ddd;
}
I would recommend doing something like the following:
.table.td-vertical-center>tbody>tr>td {
vertical-align: middle;
}
Then in your table element you can do this:
<table class="table table-striped td-vertical-center">
This will allow you to wrap this style in a custom class that will not override bootstrap by default, as well as give it enough specificity to update the table cells.
You can see a working example of a bootply here
Try this
td, th {
vertical-align: middle !important;
}
Hello I have two contents in my table, so two boxes that contain contents in html. I want to reduce the distance between these two boxes, but I realized size of one box is too big that they are just white space. I'm having trouble reducing that size. can someone please help me with this?
so, cell x and cell y that's in same row to be located closer.
<table class="table">
<tr id="cell">
---------------------------------------------------------------(one cell)
<td class="vert-align">
<div class="voting-space">
<a href="/post/{{ post.slug }}/vote?is_up=1" class="vote">
<span class="glyphicon glyphicon-triangle-top col-md-12" aria-hidden="true"></span></a>
<br />
<span class="col-md-12" style="height:1px; font-family: 'Passion One', cursive; bottom:10px; padding-left:0.01em;
"><h4 id="vote_count_{{ post.slug }}">{{ post.get_vote_count }}</h4></span> <br>
<a href="/post/{{ post.slug }}/vote?is_up=0" class="vote">
<span class="glyphicon glyphicon-triangle-bottom col-md-12" aria-hidden="true"></span></a>
</div>
</td>
--------------------------------------------------------------------(the other cell)
<td class="vert-align">
{% if post.url %}
<h4 id="line">
<img src="{{post.image}}" height="85" width="85"/><span id="title-font">{{ post.title }}</span>
<span style="margin-left: 15px;" class="domain">({{ post.domain }})</span>
<span class="discuss" style="color:red;">토론장 입장</span>
<br />
<span class="post-info">{{ post.pub_date | timesince }}전/{{ post.moderator.username }}작성/<i class="fa fa-eye"></i>{{post.views}}/{{post.category}}</span>
</h4>
{% else %}
<h4>{{ post.title }}<span style="margin-left: 15px; "class="domain">({{ post.domain }})</span></h4>
{% endif %}
For controlling "cellpadding" in CSS, you can simply use padding on table cells. E.g. for 10px of "cellpadding":
td {
padding: 10px;
}
For "cellspacing", you can apply the border-spacing CSS property to your table. E.g. for 10px of "cellspacing":
table {
border-spacing: 10px;
border-collapse: separate;
}
This property will even allow separate horizontal and vertical spacing, something you couldn't do with old-school "cellspacing".
I am using Zurb Ink to make html emails. With the panel, it looks correct in the browser with it being 601px wide. But on outlook on Safari OS(Mac book)the panel goes all the way to across the email(like a footer or header).
Should it be like this on outlook in Safari? Or is there something wrong with my code?
<table class="row">
<tr>
<td class="panel" style="background: #ECF8FF; border-color: #b9e5ff">
<table class="twelve columns container">
{% for item in object_list %}
<tr>
<td class="four sub-columns">
{% if not item.user_assigned %}
<table class="tiny-button small radius alert">
<tr>
<td>unssigned</td>
{% else %}
<table class="tiny-button small radius success">
<tr>
<td>assigned</td>
{% endif %}
</tr>
</table>
</td>
<td class="eight sub-columns last">
{{ item.date_due }} - {{ item.action }}
</td>
<td class="expander"></td>
</tr>
{% endfor %}
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
Looks like it is because you are missing wrapper and container.
In the docs it mentions the following:
container - Constrains the content to a 580px wrapper on large screens (95% on small screens) and centers it within the body.
wrapper - Wraps each .columns table, in order to create a gutter between columns and force them to expand to full width on small screens.