One row of divs with ng-repeat - css

I need to create a list of divs as looking like below sample:
I'm using Bootstrap grid system and augularjs. I create divs dynamically, using angularjs ng-repeat directive.
What I want is an endless list of divs containing attribute 'class"col-md-2"' inside a div containing attribute 'class"col-md-12"'. Then I want to use a scrollbar to scroll all the divs in the outer div.
Example code:
<div class="col-md-12" scrollablebar>
<div ng-repeat="newview in newviewslist" class="col-md-2">
Here goes the date from newview...
</div>
</div>
This doesn't work and "off course" is creating new rows each time ng-repeat is creating a div.
How do I prevent that from happen?

I solved the problem like this:
<div class="container-fluid">
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10 col-xs-11" scrollablehorizontal>
<table class="borderless">
<tbody>
<tr>
<td ng-repeat="newviews in newviews" valign="top" class="shadowbox" scrollableverticall>
<p>
all the things...
</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-1"></div>
</div>
</div>

in a col-md-12, there can be 6 x col-md-2 after that there is a linebreak.
try to change "col-md-12" to "row-fluid"
<div class="row-fluid" scrollablebar>
<div ng-repeat="newview in newviewslist" class="col-md-2">
Here goes the date from newview...
</div>
</div>
and add css:
.row-fluid{
white-space: nowrap;
}
.row-fluid .col-md-2{
display: inline-block;
margin-left:10px;
}
jsfiddle

Related

how to reduce space between two bootstrap col without using float

I have got a very annoying problem with bootstrap. I need to divide the page into two parts, left side is my pic and right side is specification. I thought I can simply use row and col, so I have done this:
<div class="layoutProb">
<div class="container" style="width: 1920px;">
<div class="row" >
<div class="col-sm-7" >
<img src="../assets/Img/Beer.jpg" alt="..." class="pic"/>
</div>
<div class="col-sm-5" style="width: 600px;">
<table id="cart" class="table table-hover table-condensed" >
<thead>
<tr>
<th ><h1> The first <br>Tshirt>Here</span></h1></th>
</tr>
</div>
</div>
</div>
</div>
Here is my layout class:
.layoutProb {
top: 0px;
left: 0px;
width: 1920px;
height: 1080px;
}
I have attached the screen here to show what I mean. The gap between is too much. If I use float left then when I decrease the size of the page then the left side overflows, another problem is horizontal scroll and I want to get rid of it as well.
add a class when you need to remove spaces use it
.p-0{
padding-right:0;
padding-left:0;
}
in HTML write this class
<div class="row">
<div class="col-md-2 p-0">
//stuff here for this column
</div>
<div class="col-md-10 p-0">
//stuff here for columns
</div>
</div>
Also, you can use this method
Simple add .no-gutter class on row.
https://getbootstrap.com/docs/4.0/layout/grid/#how-it-works

how to scroll content of flex row that is flex-grow-1

I have a layout with bootstrap in there are 3 rows wrapped in a flex col, like this:
<div class="row" style="height:100vh;">
<div class="col d-flex flex-column">
<div class="row">...</div>
<div class="row flex-grow-1">
<table>
...many rows...
</table>
</div>
<div class="row">...</div>
</div>
</div>
The first row inside flex col will be up, the second will use all the space between, and the thirth will be at bottom. In the second row I want to put a table with many rows, and contain the table inside to make somthing like a "window" to see the content of the table, scrolling the table.
But, the second div grows with table content, I tried to wrap the table inside a div and setting max-height to 100% but always the flex row grows due the table content.
¿How can I make the flex row scrolling its table inside but taking the max avalaible space of its parent with fixed height?
It should work like this with max-height and overflow-auto...
<div class="row">
<div class="col d-flex flex-column vh-100" style="max-height: 100vh">
<div class="row">
top row
</div>
<div class="row flex-grow-1 overflow-auto">
<div class="col">
<table>
<tbody>
<tr>
<td>table row</td>
</tr>
..
</tbody>
</table>
</div>
</div>
<div class="row">bottom row</div>
</div>
</div>
https://www.codeply.com/go/v6AH817CoZ
Related: Bootstrap 4: Scrollable row, which fills remaining height

Vertical alignment of column rows in Bootstrap grid

Suppose you have a two-column layout using Twitter Bootstrap, in which you want to have specific rows vertically aligned with each other:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/css/bootstrap.min.css"/>
<div class="container">
<div class="row">
<div class="col-sm-6">
<h2>Column 1</h2>
<p>Optional content of variable height.</p>
<p><strong>Align this vertically...</strong></p>
</div>
<div class="col-sm-6">
<h2>Column 2</h2>
<p><strong>...with this</strong></p>
</div>
</div>
</div>
Vertical alignment is feasible with table layouts, however, sizing and responsive behaviour of Bootstrap's columns is lost:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/css/bootstrap.min.css">
<div class="container">
<table class="row">
<thead>
<tr>
<th scope="col"><h2>Column 1</h2></th>
<th scope="col"><h2>Column 2</h2></th>
</tr>
</thead>
<tbody>
<tr>
<td><p>Optional content of variable height.</p></td>
</tr>
<tr>
<td><strong>Align this vertically...</strong></td>
<td><strong>...with this</strong></td>
</tr>
</tbody>
</table>
</div>
Another option is to split rows, however, the layout folds in wrong order on smaller resolutions.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-sm-6">
<h2>Column 1</h2>
</div>
<div class="col-sm-6">
<h2>Column 2</h2>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<p>Optional content of variable height.</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<strong>Align this vertically...</strong>
</div>
<div class="col-sm-6">
<strong>...with this</strong>
</div>
</div>
</div>
How do you achieve the same result while still maintaining the behaviour of Bootstrap's columns? Is using table layout the way to go or is it a dead-end? Is it otherwise possible without resorting to JavaScript to position a row to a computed offset?
EDIT: I aim to have the top of the rows aligned as is the case in the table layout.
For what I know, I would test these solutions.
Solution 1 : Using Javascript (Jquery if you want) to detect the height of the left and the right div, and to tell them to have the same height.
You can apply this solution on the second content div to make the espace above your bold text having the same height.
Or to add.. for example as margin-top as needed in the smaller div (with bold text which need to be aligned) after comparing the heights of both.
Anyway, if you have both of theirs heights you will have enought informations to find a way. Multiples solutions are possible here, I let you find the better one for your context and needs.
<div class="container">
<div class="row">
<div class="col-sm-6 leftcolumn">
<h2>Column 1</h2>
<div class="astallas"><p>Optional content of variable height.</p></div>
<p><strong>Align this vertically...</strong></p>
</div>
<div class="col-sm-6 rightcolumn">
<h2>Column 2</h2>
<div class="astallas"></div> // make this empty div have the same height that the left one with variable content
<p><strong>...with this</strong></p>
</div>
</div>
</div>
Solution 2 (but with some browsers incompatibilties) : Use Flexbox <3 which is a native CSS3 fonctionnaly that give you a easy way to have your wanted divs' positions.
http://flexboxfroggy.com/
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
I think that both of these works with bootstrap and will respect responsive needs.
You can do something like this to get rows of equal heights:
<style>
.centered {
text-align: center;
font-size: 0;
}
.centered .myheight{
float: none;
display: inline-block;
text-align: left;
font-size: 13px;
vertical-align: top;
margin-bottom: 5px; /*add this if you want to give some gap between the rows. */
}
</style>
<div class="container-fluid">
<div class="row centered">
<div class="col-sm-4 myheight">
Some content
</div>
<div class="col-sm-4 myheight">
Some content ...<br>
Some more content
</div>
<div class="col-sm-4 myheight">
Some content
</div>
<div class="col-sm-4 myheight">
Some content
</div>
</div>
</div>

Div tags displayed as tables not working how I expected

I'm working on a layout that has multiple tables that I'm trying to put in a much easier to read format than straight down the page. I need different sized cells per row so I'm using the div tag, but I also need the tables within the div tag to be vertically aligned so I'm using the display:table-cell style.
The problem I'm running into is that the first "table row" operates exactly as I'd like it to, but the second table row just smashes everything together to the left. I've made a quick JSFiddle to show what I'm talking about. What am I missing? Or what am I doing wrong?
http://jsfiddle.net/K8AJn/
HTML:
<div class="TR">
<div class="TD" style="width:40%;">
Info
</div>
<div class="TD" style="width:20%;">
Some info
</div>
<div class="TD" style="width:40%;">
More info
</div>
</div>
<br />
<div class="TR">
<div class="TD" style="width:50%;">
Info 1
</div>
<div class="TD" style="width:50%;">
Info 2
</div>
</div>
<br />
CSS:
div.TR {
background-color:blue;
display: table-row;
}
div.TD {
background-color:red;
display: table-cell;
vertical-align: middle;
border: 1px solid black;
}
The problem is that your table rows[sic] and cells don't have a point of reference. Ordinarily they'd rely on the parent table to define their positioning.
To get your TDs to behave as expected, wrap the entire block of TRs in another div, with a class of TABLE and use the following:
.TABLE {
display: table;
}
HTML:
<div class="TABLE">
<div class="TR">
<div class="TD" style="width:40%;height:300px;">Info</div>
<div class="TD" style="width:20%;height:300px;">Some info</div>
<div class="TD" style="width:40%;height:300px;">More info</div>
</div>
<div class="TR">
<div class="TD" style="width:50%;height:300px;">Info 1</div>
<div class="TD" style="width:50%;height:300px;">Info 2</div>
</div>
</div>
Here's a Fiddle
It should be said, however, that this sort of approach to layout is only really appropriate for fringe cases. There are much cleaner ways of achieving flexible layouts (and inline styles should be avoided like the plague).

CSS display:table-cell with div inside table

How to make display:table-cell style works (or look-alike alternative) if divs with style table-row are inside table cells? (see the link)
http://jsfiddle.net/ELKQg/460/
I'd like the container1 div behave like the container2.
code: (if the link were to become unreachable)
html:
<div id="container1" class="container">
<table>
<tr>
<td>
<div class="row">
<div class="cell">aaaa</div>
<div class="cell expand">b</div>
<div class="cell">c</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="row">
<div class="cell">d</div>
<div class="cell expand">eeeee</div>
<div class="cell">f</div>
</div>
</td>
</tr>
</table>
</div>
<div id="container2" class="container">
<div class="row">
<div class="cell">aaaa</div>
<div class="cell expand">b</div>
<div class="cell">c</div>
</div>
<div class="row">
<div class="cell">d</div>
<div class="cell expand">eeeee</div>
<div class="cell">f</div>
</div>
</div>
css:
.container{width: 500px;overflow:hidden; /* instead of clearfix div */}
div { border:1px solid;padding: 1px;}
.row {display:table-row;}
.cell {display:table-cell;}
.expand{overflow:hidden;width:100%;}
The extra <table> containing your <div>s in .container1 needs to have width: 100%
display: table-cell elements don't necessarily need a containing display: table-row as long as the parent is display: table. Set the .row to that (ideally you'd re-name it, seeing as the rule no longer makes sense)
Fixed and forked your demo:
http://jsfiddle.net/barney/ahMg8/
Use display: table for the parent table before using display:table-cell
Use td's instead of divs inside tr:
<div id="container1" class="container">
<table>
<tr>
<td class="cell">aaaa</td>
<td class="cell expand">b</td>
<td class="cell">c</td>
</tr>
<tr>
<td class="cell">d</div>
<td class="cell expand">eeeee</td>
<td class="cell">f</td>
</tr>
</table>
</div>
Working fiddle

Resources