Centering a button inside a table using css and bulma - html

I am using Bulma as a CSS frame to style my angular app, currently, I have a table that looks like this :
I am trying to make it look more like this :
How do I center the button and make the table look as close as it can to this one?
Here is the code I am using :
<table
class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth"
>
<thead>
<tr>
<th>SESSION_ID</th>
<th>CARD_NUMBER</th>
<th>TRANSACTION_AMOUNT</th>
<th>TERMINAL_ID</th>
<th>EXTERNAL_STAN</th>
<th>TRANSACTION_DATE</th>
</tr>
</thead>
<tbody>
<tr
*ngFor="
let row of MatchTransactions.onlyInFile1
| slice: 0:(page + 1) * 5;
let i = index
"
>
<td>{{ row.SESSION_ID }}</td>
<td>{{ row.CARD_NUMBER }}</td>
<td>{{ row.TRANSACTION_AMOUNT }}</td>
<td>{{ row.TERMINAL_ID }}</td>
<td>{{ row.EXTERNAL_STAN }}</td>
<td>{{ row.TRANSACTION_DATE }}</td>
</tr>
<tr>
<td class="is-centered" colspan="6">
<button
class="button"
*ngIf="
(page + 1) * 5 < MatchTransactions.onlyInFile1.length
"
(click)="page = page + 1"
>
Show more
</button>
</td>
</tr>
</tbody>
</table>

<tr>
<td class="has-text-centered" colspan="6">
<button class="button">Show more</button>
</td>
</tr>

Related

Bootstrap Accordion with a table and dynamic number or rows

Having trouble getting Accordion collapse to work within a table and a dynamic number of rows. For some reason it is only collapsing the first item in the table and ignoring the following rows, even though I have the Id's for hidden rows set to a unique identifier (company number). The amount of rows that are in the table will be dynamic.
<table class="table table-condensed" style="border-collapse:collapse;">
<thead>
<tr>
<th>Company Name</th>
<th>Company Number</th>
<th>View Documents</th>
<th>Region</th>
<th>Type</th>
<th>Time Submitted</th>
<th>Mark as Completed</th>
</tr>
</thead>
<tbody>
{% for job in todo %}
<tr data-toggle="collapse" data-target="#{{ job.company_number }}" class="accordion-toggle">
<td>{{ job.name }}</td>
<td>{{ job.company_number }}</td>
<td><a href="#{{ job.company_number }}" aria-expanded="true">View</button></td>
<td>{{ job.jurisdiction }}</td>
<td>{{ job.job_type }}</td>
<td>{{ job.time_submitted|date:"d M Y"}}</td>
<td><a href="{% url 'mark_as_completed' %}?job_id={{ job.id }}">Mark as Completed</td>
</tr>
<tr>
<td colspan="6" class="hiddenRow">
<div id="{{ job.company_number }}" class="accordion-body collapse">Hello there!</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
The following test works for me with both rows. Is it possible that job.company_number has duplicate values? ID's must be unique for it to work correctly.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<table class="table table-condensed" style="border-collapse:collapse;">
<thead>
<tr>
<th>Company Name</th>
<th>Company Number</th>
<th>View Documents</th>
<th>Region</th>
<th>Type</th>
<th>Time Submitted</th>
<th>Mark as Completed</th>
</tr>
</thead>
<tbody>
<!-- Job 1 -->
<tr data-toggle="collapse" data-target="#company1" class="accordion-toggle">
<td>{{ job.name }}</td>
<td>{{ job.company_number }}</td>
<td><a href="#{{ job.company_number }}" aria-expanded="true">View</button></td>
<td>{{ job.jurisdiction }}</td>
<td>{{ job.job_type }}</td>
<td>{{ job.time_submitted|date:"d M Y"}}</td>
<td><a href="{% url 'mark_as_completed' %}?job_id={{ job.id }}">Mark as Completed</td>
</tr>
<tr>
<td colspan="6" class="hiddenRow">
<div id="company1" class="accordion-body collapse">Hello there!</div>
</td>
</tr>
<!-- Job 2 -->
<tr data-toggle="collapse" data-target="#company2" class="accordion-toggle">
<td>{{ job.name }}</td>
<td>{{ job.company_number }}</td>
<td><a href="#{{ job.company_number }}" aria-expanded="true">View</button></td>
<td>{{ job.jurisdiction }}</td>
<td>{{ job.job_type }}</td>
<td>{{ job.time_submitted|date:"d M Y"}}</td>
<td><a href="{% url 'mark_as_completed' %}?job_id={{ job.id }}">Mark as Completed</td>
</tr>
<tr>
<td colspan="6" class="hiddenRow">
<div id="company2" class="accordion-body collapse">Hello there!</div>
</td>
</tr>
</tbody>
</table>
Update: In response to your comment, would it be better to use job.id for the accordian id's like so?
<tr data-toggle="collapse" data-target="#{{ job.id }}" class="accordion-toggle">
<td colspan="6" class="hiddenRow">
<div id="{{ job.id }}" class="accordion-body collapse">Hello there!</div>
</td>

How to prevent my td stacking below each other?

I am trying to make a table responsive when the screen size gets smaller. It is a table-responsive class inside a col-6, but when the screen gets smaller, the td's and th's get stacked below each other..
I want the table to get smaller, or just wider in some way.
I tried some bootstrap responsive classes, but on a table it seems to be quite hard.
<div class="col-6 col-lg-6 col-xl-6">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Dealtype</th>
<th>Start date</th>
<th>End date</th>
<th>Investment</th>
<th>Price per review</th>
<th>Logistics costs</th>
<th>#Reviews</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ $deal->dealtype }}</td>
<td>{{ $deal->startdate }}</td>
<td>{{ $deal->enddate }}</td>
<td>€ {{ number_format(round($deal->amount, 2), 2) }}</td>
<td>€ {{ number_format(round($deal->reviewprice, 2), 2) }}</td>
<td>€ {{ number_format(round($deal->logisticsamount, 2), 2) }}</td>
<td> {{ $deal->quantity }}</td>
</tr>
</tbody>
</table>
</div>
</div>
I expect the table width to resize with the screen, but obviously the col-6 makes the content stack below each other.
here is a picture of the problem

single th in tr with ng-repeat

Cant I display one value of th element in tr with ng-repeat?
This is how my html looks
<div class="center layout-column flex">
<section layout="row" layout-align="left left">
<md-button class="md-primary" ng-click="vm.showDialogAdd($event)">Add new movie</md-button>
<md-button class="md-primary" ng-click="vm.showDialogDetails($event)">Add details</md-button>
</section>
<div class="simple-table-container md-whiteframe-4dp">
<div class="ms-responsive-table-wrapper">
<table class="simple" ms-responsive-table>
<thead>
<tr>
<th>Title</th>
<th>Year</th>
<th>Country</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="movie in vm.movies">
<td>{{ movie.title }}</td>
<td>{{ movie.year }}</td>
<td>{{ movie.country }}</td>
<td class="text-center">
<md-button class="md-warn" ng-click="vm.deleteMovie(movie)">Remove</md-button>
<md-button class="md-noink" ng-click="vm.showDetails(movie)">Details</md-button>
</td>
</tr>
<tr ng-repeat-end ng-show="movie._detailsVisible" ng-repeat="detail in vm.movieDetails">
<th>Actors: </th>
<td>
{{ detail.name }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
I want to display "Actors:" like a title of all tds, something like that:
How can I do this?
Just move ng-repeat to td
<tr ng-repeat-end ng-show="movie._detailsVisible">
<th>Actors: </th>
<td ng-repeat="detail in vm.movieDetails">
{{ detail.name }}
</td>
</tr>
I'm not sure what do you mean by display "Actors:" in one td, but you can try adding it in front of the detail name so that it will be displayed with the value in one single td.
Edit: Please try the below code to achieve your requirement.
<tr ng-repeat-end ng-show="movie._detailsVisible">
<th>
Actors:
</th>
<td ng-repeat="detail in vm.movieDetails">
{{ detail.name }}
</td>
</tr>

Vue.js component does not receive prop

I would like to pass a ride to the show-ride-modal. When somebody clicks on the button show a modal will pop-up with the ride information.
<table class="table">
<thead>
<tr>
<th>Door</th>
<th>Van</th>
<th>Naar</th>
<th>Type</th>
<th>Datum</th>
</tr>
</thead>
<tbody>
<tr v-for="ride in rides">
<show-ride-modal :ride="ride"></show-ride-modal>
<td>{{ ride.user.name }}</td>
<td>{{ ride.location.from }}</td>
<td>{{ ride.location.to }}</td>
<td>{{ ride.type.name }}</td>
<td>{{ ride.date }}</td>
<td>
<a #click="show" class="btn-show">show</a>
<a v-link="{ name: 'ritten' }" class="btn-edit">Bewerk</a>
<a v-link="{ name: 'ritten' }" class="btn-delete">Remove</a>
</td>
</tr>
</tbody>
</table>
My show ride modal component:
<template>
<modal title="Bekijk rit">
<form class="Modal__form" #submit.prevent="createTopic">
<p>test</p>
<p>{{ ride.user.name }}</p>
</form>
</modal>
</template>
<script>
import Modal from './Modal.vue'
export default {
components: { Modal },
props: ['ride'],
data () {
return {
showLoader: false
}
}
}
</script>
The problem is that the ride is not being passed to the <show-ride-modal>. What could be wrong?

Align thead with td in tbody

I have trouble aligning the thead with the td in tbody. I've tried adjusting the thead using display: table-header-group;. I also found out from here: Why isn't padding applied to table elements?, that padding does not work on 'table-header-group'. Thus when I tried providing padding-left to my th via CSS, nothing is happening. I've also tried using more <th></th> before my <th>Quantity</th> <th>Amount</th> <th>Total</th> so that 'more space' is added. However, I am still not able to align the thead with my content in tbody.
Does anyone know how to fix this issue? If possible, please also let me know if I am not doing things right. Any help is much appreciated.
Thank you!
Screenshot and code is provided below:
thead is too left
Here is my code:
<div class="table-responsive col-lg-12 " ng-show="ngCart.getTotalItems() > 0">
<table class="table-responsive table-striped ngCart cart summaryTable " >
<thead >
<tr cellpadding="10">
<th>Item</th>
<th>Quantity</th>
<th>Amount</th>
<th>Total</th>
</tr>
</thead>
<tfoot>
<tr ng-show="ngCart.getTax()">
<td></td>
<td></td>
<td>Tax ({{ ngCart.getTaxRate() }}%):</td>
<td>{{ ngCart.getTax() | currency }}</td>
</tr>
<tr ng-show="ngCart.getShipping()">
<td></td>
<td></td>
<td>Shipping:</td>
<td>{{ ngCart.getShipping() | currency }}</td>
</tr>
<tr>
<td></td>
<td></td>
<td>Total:</td>
<td>{{ ngCart.totalCost() | currency }}</td>
</tr>
</tfoot>
<tbody>
<tr ng-repeat="item in ngCart.getCart().items track by $index">
<td>{{ item.getName() }}</td>
<td>{{ item.getQuantity() | number }}</td>
<td>{{ item.getPrice() | currency}}</td>
<td>{{ item.getTotal() | currency }}</td>
</tr>
</tbody>
</table></div>
what you did was correct. all you need is to center the text alignment of your thead. or just align the tbody left.