I have a Bootstrap Vue table with a pagination component underneath it. I've currently got it in a separate row in a single column but whilst it looks "fairly" centred, it's actually not centred in the column and there is uneven padding/margin on the right side. Looking like it's from the tag (per image).
How can I horizontally centre the pagination pls?
</b-table>
<b-row align-h="center" align-content="center">
<b-col cols="3">
<b-pagination
v-model="currentPage"
:total-rows="totalRows"
:per-page="perPage"
aria-controls="my-table"
></b-pagination>
</b-col>
</b-row>
You could use cols="auto" instead of cols="3", that way the column will automatically size itself after the content, instead a specific width as you have now.
https://bootstrap-vue.org/docs/components/layout#variable-width-content
<b-row align-h="center" align-content="center">
<b-col cols="auto">
<b-pagination></b-pagination>
</b-col>
</b-row>
You could also use Bootstraps Flex Utilities
<div class="d-flex justify-content-center">
<b-pagination></b-pagination>
</div>
try adding justify-content: center; to your .pagination class
Related
I'm using the Bulma CSS framework with a Rails app. I have a long list of items and would like to display them in tiles. However, the tiles run off the screen instead of wrapping to the next line.
The Bulma Documentation doesn't address this issue. Since I am creating the tiles dynamically from a variable-length list, explicit nesting as described in their docs isn't so easy and I'd rather have it cleanly wrap to the next line.
Here's what my code basically looks like:
<div class="tile is-ancestor">
<div class="tile is-parent">
<% #my_list.each do |item| %>
<div class="tile is-child box">
<p><%= item %></p>
</div>
<% end %>
</div>
</div>
Since Bulma is based on flexbox, I would think there is some equivalent to flex-wrap: wrap;, but I couldn't find this option yet.
Update: It's possible to add the style flex-wrap: wrap;to the parent-container, but is there a Bulma-integrated class flag?
It seems that there is currently no class-flag in Bulma addressing this directly.
However, since Bulma is based on flexbox, it is possible to add the style flex-wrap: wrap; to the parent container to achieve the desired outcome.
For the gridsystem Bulma does have a class for this.
If you add is-multiline to your .columns element it should wrap automatically. (adds flex-wrap: wrap; under the hood)
Source: Bulma column docs
(Not sure how this applies to tiles, but you could always wrap them into columns)
The DevTools inspector shows that Bulma's box p has a default style of white-space: nowrap.
Applying style="white-space: normal!important;" directly onto the <p> tag forced it to wrap as normal and fixed the problem for me.
I understand the problem, as described and answered here.
I have quite a complicated layout with a sidebar navigation, a top navigation, a fluid-container and then page-title and page-body structure for each page. So just adding another container did not solve the problem as suggested in that answer.
Once I get into the page-body, all the rows are stretching 'outside' the parent page-body.
Notice I have added padding to the default container-fluid to 'pull' all the content in from each side of the page. Removing them does not fix it.
I've tried every change I can think of except removing the padding from the default row, because I'm pretty sure that is a no-no.
Anyone have any idea how to get those pesky form controls to stay 'inside' the page body?
There is two solution either give an additional class to row and manipulate its layout or don't use row use <div class="col-md-*" /> without parent .row class div as many times u want and use <div class="clearfix"> if you want to break forcefully to next row
EDIT:-
For example
<div class="row">
<div class="col-md-4">div1</div>
<div class="col-md-4">div2</div>
<div class="col-md-4">div3</div>
</div>
<div class="row">
<div class="col-md-4">div4</div>
<div class="col-md-4">div5</div>
<div class="col-md-4">div6</div>
</div>
The same can be achieved without .row class
<div class="col-md-4">div1</div>
<div class="col-md-4">div2</div>
<div class="col-md-4">div3</div>
<div class="clearfix">div4</div>
<div class="col-md-4">div5</div>
<div class="col-md-4">div6</div>
<div class="col-md-4">div1</div>
I am creating an application and I am using the ReactJS Griddle component. I am trying to create a custom row component but it keep applying an inline style like so:
<div class="myCustomRowClass" data-reactid="react_id" style="clear:both;display:table;width:100%">
I would need to override the style so I can set display: grid;. The reason for this is that I am using Semantic-Ui for the user interface, and when I do something like this:
<div class="ui four cards">
<div class="ui card">
/* content */
</div>
<div class="ui card">
/* content */
</div>
/* etc... */
</div>
instead of display a grid of 4 card per row, it displays one card per row.
Is there a way I can override the style?
Help appreciated.
I have found the answer to this. I should have used customGridComponent instead of customRowComponent and render my data in the CustomGridComponent
I'm trying to adapt bootstrap's standard practices to speed up some of my development but have a quick question related to showing and hiding cols.
I have the following simple layout
<div class="row" id="contactGrid">
<div class="col-sm-2">Sidebar</div>
<div class="col-sm-10">Content</div>
</div>
When I use AngularJS to show/hide the Sidebar col I expect the Content col to stretch the entire width of the container but it doesn't it says at 'col-10'. Do I need to programmically change the class/width to col-sm-12 when I hide the sidebar?
Thanks for your help, I'm sure this is an easy one!
The element with the class col-sm-10 will always have 10/12 of the width of it's parent row. Therefore you need to update it on the fly, when your sidebar changes to hidden. As you already use AngularJS you might have a variable defining if your sidebar should be visible or not. This variable may also define your class conditionally for your content div.
<div class="row" id="contactGrid">
<div class="col-sm-2" ng-show="booleanVariable">Sidebar</div>
<div ng-class="{col-sm-10: booleanVariable, col-sm-12: !booleanVariable}">Content</div>
</div>
Daniel,
Your answer is the reason I'm trying to learn the BS/NG style of UI. It's just knowling where the shortcuts begin and end. To polish it off I used a ternary expression in the ng-class. showFilterSidebar is my hide/show variable. Thanks Again!
<div ng-class="showFilterSidebar ? 'col-sm-10' : 'col-sm-12'">
Yes you need to change class to col-sm-12 and hide for col-sm-2 to avoid problems with floatin .
I know that there are many questions about this issue, but nothing worked for me properly.
I need to align my PanelGrid to center(horizontal).
this is my panelgrid
<p:panelGrid styleClass="panelGridCenter">
and my CSS:
.panelGridCenter td,.panelGridCenter tr {
text-align: center;
}
It just aligns the content to center, but not the panelGrid
The JSF <p:panelGrid> component renders a HTML <table> element which is by default a block level element. To center the block level element itself, you should set its horizontal margin to auto instead of attempting to center its inline contents.
.panelGridCenter {
margin: 0 auto;
}
See also:
Center a div in CSS
The above answer is technically correct but also incomplete.
If you want to center something like a div, the above technique of playing with the left and right margin as auto will work, provided that your DIV has limited width.
E.g. For you to start being any effect you would have to put something like a width=60%.
And then, once you realize you need to play with fixed widths... you immediately are prompted to the next question:
So what exactly should I type in as my fixed width?
That is why I believe the better answer for this question is:
CSS techniques like the one above, are OK for the small details on a web page.
But your coarse grained approach for centering anything on a web page should be to make use of a grid system.
Most grid systems use 12 cells.
If for example your grid system would be by default make 12 cells = 100% width.
You could center something by, for example placing your content to be centered in cells [5-8] leaving out as centurion space cells [1-4] and cells [9-12].
Here is an example based in prime faces grid system:
<h3 id="signInTitle" class="first">Sign in - FIXME - i18n</h3>
<form id="loginFormOld" (ngSubmit)="onLoginFormSubmit()">
<!-- (a) Start a grid system-->
<div class="ui-g ui-fluid">
<!-- (b) Eat the first four cells of the grid -->
<div class="ui-g-12 ui-md-4"></div>
<!-- (c) In the center location of the grid put in the Login form -->
<div class="ui-g-12 ui-md-4">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon"><i class="fa fa-user"></i></span>
<input id="emailInput" pInputText type="email" placeholder="Email" [(ngModel)]="eMail" name="eMail">
</div>
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon"><i class="fa fa-key" aria-hidden="true"></i></span>
<input id="passwordInput" pInputText type="password" class="form-control" placeholder="Password" [(ngModel)]="password" name="password">
</div>
</div>
<!-- (d) Eat the rest of the first row of the grid without setting any contents -->
<div class="ui-g-12 ui-md-4"></div>
<!-- (e) Start the second row and eat the first four cells -->
<div class="ui-g-12 ui-md-4"></div>
<!-- (f) Position a form submit button on the fifth cell -->
<div class="ui-g-12 ui-md-1">
<button id="loginSubmit" pButton type="submit" label="Submit"></button>
</div>
</div>
</form>
The comments on the above form should make it pretty clear what I meant above.
The grid system will normally offer CSS classes to allow your UI to be working across multiple form factors of devices, although ... on this regard I am of the opinion that you can not make a good mobile UI using a desktop UI nor a good desktop UI using a mobile UI.
On my opinion you can get a good Tablet/Desktop UI cooked up, but you should write pages from scratch with the minimal an necessary contents for mobile. But that is a different discussion ... just to say, that the flex grid css classes will only take you so far.
A lot of potential in theory, much better than hard coding some arbitrary fixed length on your div elements ... but not a silver bullet for all of your problems either.
In case if you want right align
.rightAlign{
margin-left: auto;
}