Make column heights equal to the smallest column [duplicate] - css

This question already has answers here:
One flex/grid item sets the size limit for siblings
(6 answers)
Closed 3 years ago.
There a ton of answers on SO on how to make columns equal height based upon the content of the largest column, however I am looking to make all columns equal height based upon the smallest column.
In this example, I want all columns to have the same height as the middle column and the content within the two larger columns to scroll. I am using Bootstrap 4 but am open to any other solutions.

You might have to use javascript.
Store all the column heights into an array.
Loop through and pick the smallest height.
Set the height of the other divs based on the smallest height.
// Get all the columns
const columns = document.querySelectorAll('.column');
// Array for storing height values for columns
var columnHeights= [];
// Add Column Heights to array
for(index=0; index<columns.length; index++) {
column= columns[index];
columnHeights.push(column.getBoundingClientRect().height);
}
// Get the minimum column height
Array.min = function(heightsArray){
return Math.min.apply( Math, heightsArray );
};
var minimumHeight = Array.min(columnHeights);
// Set the height of the other columns based on the minimum height
columns.forEach(col => {
col.style.height = minimumHeight+'px';
});
A working pen is here

Related

set row height for all rows using phpspreadsheet

Default row height in excel is -1 which show 15 in excel.This row height automatically resize to 15.75 after add content.So, I set new default row height,15 for all rows. Still, row height getting auto resize. Then, I try to set row height for all rows from $sheet->getRowDimensions(). There is no content in $sheet->getRowDimensions(). So, $rd->setRowHeight(15) does not take effect.
$default_rowdimensions =$sheet->getDefaultRowDimension();
$set_newdefaultrowheight=$sheet->getDefaultRowDimension()->setRowHeight(15);
$rowdimension = $sheet->getRowDimensions();
echo '<pre>;
var_dump($rowdimension);
echo '</pre>';
foreach($rowdimension as $rd)
{
$rd->setRowHeight(15);
}
Is there any other ways to set row height for all rows before write to excel.
Thanks in advance.
For PhpSpreadSheet, the correct way to archive this is :
$spreadsheet->getActiveSheet()->getRowDimension('2')->setRowHeight(26);
Where 2 is the number of row and 26 is the height.
Set the default row height with:
$sheet->getDefaultRowDimension()->setRowHeight(15);
Here you go Brother.
// Assuming you have 50 rows or 100 rows above to format
$a = 50;
for($i = 0; $i<$a;$i++){
$spreadsheet->getActiveSheet()->getRowDimension($i)->setRowHeight(14.25);
}
you can use this as shown above my $a variable assigned 50 rows;

Grid with rows that have different number of columns

Is it possible to programmatically create a Grid that has 3 rows and 2 columns, but the last row only has 1 column instead of 2?
public class MyGrid : Grid
{
public void DefineRowsAndColumns()
{
// I know you can add RowDefinitions and ColumnDefinitions here, but how to make them uneven?
}
}
I'm not trying to get someone to do my homework here...I just want to know how I can get a grid to have rows with different number of columns.
you can use the ColumnSpan property to make content span multiple columns
var label = new Label { Text = "Row 1" };
myGrid.Children.Add(label,0,0);
Grid.SetColumnSpan(label,2);
the Label will span 2 columns, effectively making that row contain only a single column

Angularjs calling clearfixes based on screen size with ng-if

I want my columns to display in 3 columns per row on medium and larger screen sizes (col-md-4), 2 columns per row on smaller screen sizes, and 1 column per row on extra small (col-sm-6), but when I view my app on my tablet, I get floating columns in the 2 column rows. I know its possible to use a clearfix class with ng-if to tell it to make a column every so many rows, but if I use:
<div class='clearfix' ng-if='$index % 2 == 0'>
it will make my columns create a new row every 2 columns, even on larger screens, which isn't what I want. Is it possible to make ng-if only add the clearfix after 2 columns strictly on the col-sm class, and not on the col-md class?
Yes you can do it by listing to window resize event, Based on the screen inner width you can attach or detach the div.clearfix to the dom using ng-if.
EX:
Controller:
maintain a variable to represents the window width $scope.windowWidth
app.controller('MainCtrl', function($scope, $window, $timeout) {
$scope.windowWidth = $window.innerWidth;
$window.onresize = function(event) {
$timeout(function() {
$scope.windowWidth = $window.innerWidth;
});
};
});
View:
Attach the div IF windowWidth <= 768 ELSE Remove the div from the DOM.
<div class="tab-only clearfix" ng-if="windowWidth <= 768">
This will show only on min-width : 768px
</div>
here is a DEMO
Please search for if there is any css fixes for this.

Hide ColumnSeries in Flex Chart

I have a clustered chart with 2 column series. The problem is that sometimes one column's values are so large, the other column is dwarfed. So I added checkboxes to show/hide a given column, and set the visibility of the ColumnSeries as such:
visible="{checkbox.selected}" includeInLayout="{checkbox.selected}"
This shows/hides the given column correctly, the problem is that it does not reset the Y-Axis, so the other column never actually grows in height (when the column with the larger values is hidden). I've tried resetting the data provider, validating/invalidating the chart, and nothing seems to work.
Anyone have any ideas?
Thanks!
I would imagine from your description that you actually need to remove the series from the chart. So
public function onToggle(){
var newSeries:Array = [];
if(bigSeries.selected) {
newSeries.push(bigSeries);
}
if(smallSeries.selected) {
newSeries.push(smallSeries);
}
chart.series = newSeries;
}

How to set the same column width in a datagrid in flex at runtime?

HI,
In flex, I have a datagrid with 22 columns. I initially display all the columns. The width of each column right is uniform.
Now when i change the visiblity of a few columns, the width of each column varies. How do i maintain a uniform column width for each column whether or not there are any invisible columns?...
Also how do i get the count of number of visible columns. the ColumnCount property returns total number of columns and not the number of visible ones.
The columns are an array, so you can append code to whatever function makes them invisible and loop through that array setting each ones width. You will just need to keep tabs on your Datagrids width, and the number of visible columns, which you can also do with a loop. Here's some untested code that should put you close to your goal:
function makeAColInvisible():void{
//code you use to set col invisible
var visColCount:number = 0;
for each (var item:DataGridColumn in myDataGrid.columns){
if(item.visible == true){
visColCount++;
}
}
for each (var item2:DataGridColumn in myDataGrid.columns){
item2.width = myDataGrid.width / visColCount;
}
}

Resources