I'm trying to create a table using divs and I want them to be sortable (alphabetically).
Here's a snippet of two rows:
<div grid-row="" grid-pad="1.5" grid-gutter="3" grid-responsive="">
<div grid-col="1" grid-pad="1.5">*image*</div>
<div grid-col="4" grid-pad="1.5">A-title</div>
<div grid-col="4" grid-pad="1.5">B-author</div>
<div grid-col="3" grid-pad="1.5">C-tag</div>
</div>
<div grid-row="" grid-pad="1.5" grid-gutter="3" grid-responsive="">
<div grid-col="1" grid-pad="1.5">*image*</div>
<div grid-col="4" grid-pad="1.5">D-title</div>
<div grid-col="4" grid-pad="1.5">E-author</div>
<div grid-col="3" grid-pad="1.5">F-tag</div>
</div>
Using divs makes the table responsive and neatly integrated with the Cargo site - I tried out using <td> elements, but I did not get the responsive result i wished for.
Is there a way to code this using these kind of divs? The most important cell to have sortable is the ones with the "title" in them. Should there be something telling which columns to be sorted too?
The site is running on the Cargo Collective platform using jQuery 2.1.3.
Related
This may seem weird, I want to create a header as simple as this of Stack Overflow so I've been struggling writing the right codes.
<template name="DashboardLayout">
<hr>
<div class="row">
<div col-md-8 col-md-offset-9><center><input type="text" name="search" placeholder="Search.."></center> </div>
<div col-md-4 ><center><label>Profile</label></center> </div>
<div col-md-4 ><center><label>Settings</label></center> </div>
<div col-md-4 ><center><label>Videos</label></center> </div>
<div col-md-4 ><center><div class="dropdown">
<div class="dropbtn">Dropdown</div>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div></center> </div>
</div>
<hr>
</template>
How can I achieve this using Bootstrap?
What are you asking for ? to give you the full HTML CSS and JS is needed ?
Check this link in Bootstrap the default example es basically what you want.
Logo, links (text or icon links), search bar and dropdown.
All responsive.
Then just play around the styles to get a better copy of this.
What you can do is add some custom classes for existing tags and write your own styles for corresponding classes.
or If you need simple customised version of this you can use this to build it easier
or this one https://work.smarchal.com/twbscolor/
read this if you want even mature look for your nav bar http://blog.jetstrap.com/2013/07/less-like-bootstrap/
I've built a standard layout with a sidebar using Bootstrap's grid system (EDIT: I'm using Bootstrap 4 but could still switch). It looks like this:
<div class="row">
<div class="col-md-3">
...
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-4">...</div>
<div class="col-md-4">...</div>
<div class="col-md-4">...</div>
</div>
</div>
</div>
On mobile, the red area would be above the green one. I need to be able to switch between them in a way that is more convenient than scrolling, for example a switch button:
Also note the different oder of elements in the green area.
Is there a smart way to do this? Or do I have to alter the dom with JavaScript? Thanks in advance :)
You can use jQuery to toggle one of the BS4 flexbox utility classes. For example, apply the flex-last on the first (col-md-3) column.
To switch the order on mobile using a button, toggle the flex-last class...
$('#btnToggle').click(function(){
$('.col-md-3').toggleClass('flex-last');
})
EDIT: To show only one at a time (switch the visibility of the 2 divs using a button) toggle the hidden-sm-down class instead...
$('#btnToggle').click(function(){
$('.col-md-3, .col-md-9').toggleClass('hidden-sm-down');
})
Demo
In Bootstrap 4, column order can be toggled using CSS only, but this switches the cols based on screen width, and therefore is not triggered by the button.
<div class="row">
<div class="col-md-3 flex-last flex-md-unordered">
...
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-4">...</div>
<div class="col-md-4">...</div>
<div class="col-md-4">...</div>
</div>
</div>
</div>
Update
As of Bootstrap 4 Beta 3, the ordering classes are named order-*, such as order-1, order-md-2, etc..
Bootstrap 4 uses Flexbox, which means you could utilise the order in which things are displayed.
As usual, you can specify how it's displayed on different viewports using classes like order-last and order-sm-unordered.
flexbox/order documentation
I wonder if there's a way to render responsively elements created by *ngFor in Angular 2?
I use Bootstrap 4 grid system based on flex property. And I've got this code in my Angular2 app:
<div class="outlet container">
<div class="row itemsBlock">
<div *ngFor="let item of items" class="itemRender">
<img class="itemImage" src="{{item.image}}" />
<span class=itemitle">{{item.title}}</span>
</div>
</div>
What I want is to get my items rendered responsively, say
3 divs in the row on large and middle-sized displays
2 divs in the row on small ones
1 div in the row on x-small displays
You can't really relate that stuff with looping over items collection. You could take use xl, lg,md & sm class with col-size-number(like col-xs-12) class on same row. Bootstrap will take care about to applying a class over element based on screen resolution.
Markup
<div class="row itemsBlock">
<div *ngFor="let item of items" class="col-md-4 col-sm-6 col-12">
<img class="itemImage" src="{{item.image}}" />
<span class=itemitle">{{item.title}}</span>
</div>
</div>
Note: The Bootstrap v4 grid system has five tiers of classes: xs
(extra small), sm (small), md (medium), lg (large), and xl (extra
large). You can use nearly any combination of these classes to create
more dynamic and flexible layouts.
I'm using bootstrap grid system for building a website, i'm not using the row class but the padding between divs is not working!
<div class="container">
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
</div>
Can anyone help me with that?
In Bootstrap there are 12 columns in a row. You have 4 * 4 = 16, and that's not correct.
It’s based on a 12 column layout and has multiple tiers, one for each media query range.
So you should change your code to:
<div class="container">
<div class="row">
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
</div>
</div>
See docs here.
To start with - assuming you are wanting a single row- you need to either change these divs to a "3" each or have one less of them - remember that 12 is the magic number for the Bootstrap grid.
Also the reason for containing the cols in a .row is to control the margin on either side. The padding is INSIDE the divs - not between them so the following will give you a row with 3 divs that are positioned adjacent to each other to give a full row and will have left / right padding of 15px inside each div:
<div class="container">
<div class="row">
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
</div>
</div>
The .row class has a -15px margin on either side so that each of the side divs will aligns with the edge of the parent container div. Remember that you can use container-fluid to expand the parent div across the entire viewport.
So to summarise - the Bootstrap .col-* divs do NOT have padding between them, but rather padding inside them. Unless of course your CSS overrides that.
According to Bootstrap documentation:
Row is mandatory
Every row has 12 columns
You are using 16 columns, change your code to:
<div class="container">
<div class="row">
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
</div>
</div>
I am currently learning Bootstrap. I came across a piece of code where I was trying to create a bunch of rows to create a kind of table. But when I ran the code on the browser, the margins of the rows start of behind the screen. Look at the very simple piece of 'Hello World' code below in JS Fiddle.
<div class="row">Hello World!</div>
http://jsfiddle.net/x8y50sas/
Why is the text starting from behind the margins? An detailed explanation could help?
You need to include a cell inside the row:
<div class="container">
<div class="row">
<div class="col-xs-12">Hello World!</div>
</div>
</div>
The reason for the offset is that rows in bootstrap have a negative margin. They should always contain a cell which adds additional padding.
More info in the docs: http://getbootstrap.com/css/#grid
Because to be able to use the grid system you need to wrap your element inside class container. Read this article: http://getbootstrap.com/css/#overview-container
Example:
<div class="container">
<div class="row">Hello World!</div>
</div>
You must enclose the block "row" in the block "container" as:
<div class="container">
<div class="row">
<!-- Example: 3 Cell -->
<div class="col-lg-4">...</div>
<div class="col-lg-4">...</div>
<div class="col-lg-4">...</div>
</div>
</div>