logo
down
shadow

Cannot manage to have heights relative to items contents with css grid


Cannot manage to have heights relative to items contents with css grid

Content Index :

Cannot manage to have heights relative to items contents with css grid
Tag : html , By : Peter Leung
Date : November 26 2020, 06:28 AM

fixed the issue. Will look into that further Currently when I create a css layout with grid, items within this layout will take up the height of the heighest item. Is it possible to make an item take only the height its content needs? , You can use align-self property to fix it:
.div-2 {
  align-self: start;
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

grid layout with different grid heights using Fluid Baseline Grid


Tag : javascript , By : orlandoferrer
Date : March 29 2020, 07:55 AM
it should still fix some issue You can probably tackle this by applying a clear: left via an nth-child selector on your columns. Using your media-queries, you should be able to mimic 2 or 3 column layouts like so:
// 2 column layout
@media only screen and (max-width: 767px) {
  .g1:nth-child(2n+1) {
    clear: left;
  }
}

// 3 column layout
@media only screen and (min-width: 768px) {
 .g1:nth-child(3n+1) {
        clear: left;
      }
}

<!DOCTYPE html> prevents relative css heights


Tag : html , By : user109127
Date : March 29 2020, 07:55 AM
To fix the issue you can do A doctype enforces a certain set of standards for the browser. If a page does not include a doctype, browsers will usually use some kind of quirks or transitional mode, which is more lenient about markup mistakes (but is bad practice and may display items incorrectly).
Essentially, strictly speaking, you can't set that element to height 100% using that browser's set of standards. It'll try to predict what you wanted to do if you don't include a doctype or include a transitional one and adjust the page's styling accordingly.

Responsive div layout with relative heights


Tag : html , By : woxorz
Date : March 29 2020, 07:55 AM
This might help you I'm trying to setup a webpage with a fixed header at the top of the page and two grids stacked over each other underneath the header. I want the top grid to occupy 75% of the space underneath the header and the bottom grid should occupy the remaining 25%. These relative heights should be respected when the browser window is vertically resized. I don't want any scrolling on the page and the bottom grid shouldn't overflow out of the window. My html,css looks like this: , Easy way to do so:
1) add zero margins & paddings:
html,body{
  height:100%;
  overflow:hidden;
  margin: 0;
  padding: 0;
}
.wrapper{
  position:relative;
  height:calc(100% - 85px);
  top:85px;
}

Align items with different heights in a grid and have them match lines of alignment


Tag : html , By : lili
Date : March 29 2020, 07:55 AM
To fix the issue you can do With your current HTML structure, I'm not familiar with any pure CSS ways of achieving your end result. The key issue is that the individual elements in each adjacent column have no way of relating themselves to their surroundings. If your cells were horizontal, we might be able to use CSS like table-row - because "cells are descendants of rows, never of columns." (W3)
With that said, you didn't mention you were looking for a pure CSS solution, and as you already are using jQuery, I thought that would be a fine solution for keeping your HTML structure while achieving your desired layout.
var back = ["red", "blue", "gray", "black", "green", "cyan", "brown", "magenta"];
var i = 0;

$('#container .card').children().each(function() {
  $(this).css('background-color', back[i++]);
  if (i == back.length) i = 0;
});

var components = ['image', 'text', 'list'];
$.each(components, function(i, j) {
  var $elements = $('.card .' + j);
  var heights = [];
  var tallest = 0;

  $elements.each(function(i) {
    var height = $(this).height();
    heights[i] = height;
    if (height > tallest) {
      tallest = height;
    }
  });

  $.each(heights, function(i, j) {
    var diff = tallest - j;
    if (diff) {
      $elements.eq(i).css('margin-bottom', diff);
    }
  });
});
#container {
  display: flex;
}

.card {
  max-width: 200px;
  width: 100%;
}

.card .image {
  height: 150px;
}

.card .text {
  height: 100px;
}

.card .list {
  height: 50px;
}

#z1 .image {
  height: 175px;
}

#z2 .text {
  height: 120px;
}

#z3 .list {
  height: 60px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container">
  <div id="z1" class="card">
    <div class="image"></div>
    <div class="text"></div>
    <div class="list"></div>
  </div>
  <div id="z2" class="card">
    <div class="image"></div>
    <div class="text"></div>
    <div class="list"></div>
  </div>
  <div id="z3" class="card">
    <div class="image"></div>
    <div class="text"></div>
    <div class="list"></div>
  </div>
</div>

Arrange items of different heights in a grid


Tag : css , By : vitorcoliveira
Date : March 29 2020, 07:55 AM
Does that help You can do it without any kind of Bootstrap, just using display: inline-block for the elements.
Below is a demo where I add 12 elements of varying heights in a container div, where the width of the container div is set to a random value every time it is run to show how it will wrap differently each time.
var heights = [100, 20, 80, 140, 65, 90, 30, 70, 130, 55, 75, 100];
for (var i = 0; i < heights.length; i++) {
  $('#x').append($('<div style="height:' + heights[i] + 'px"></div>'))
}
var w = Math.floor((Math.random() * 400) + 100);
$('#x').css("width", w + "px");
#x div {
  display: inline-block;
  vertical-align: text-top;
  width: 50px;
  background: green;
  margin: 10px;
}

#x {
  border: solid 1px #888
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<hr>
<div id="x"></div>
<hr>
Related Posts Related QUESTIONS :
  • How to stop repeating image
  • How do I prevent the GET method from encoding HTML special characters in the URI?
  • CSS/HTML: How do I change the color of the check mark within the checkbox input?
  • attaching a file path in a html form
  • Flip <canvas> (rotate 180deg) after being published on page
  • Is there an application I can show a client the speed of their site via differring internet connections?
  • Html / Email / Distribution list problem from a noob
  • Inspiring web experiments and technical demos
  • Can I load javascript code using <link> tag?
  • Lisp-style quotation in HTML
  • How to put text float around image like some newspapers' format using CSS?
  • Technical reasons for not having large background images in websites
  • HTML 5 Structure tags demo
  • Angular - String interpolation of undefined variable
  • Is there any way to edit specific Column of table using mat-table in Angular material
  • How can I set a text as a shadow for a heading element?
  • How to fix the forms making the buttons overlap
  • Splitting XML into multiple HTML pages with XSLT?
  • How to justify empty divs in flex container
  • How to blur in CSS only one layer of when you have multiple layers in background-image?
  • Scrollable html table with fixed first row and first column, along with angular material controls within the cells of ta
  • In Django, how to extract ID attribute from html Input tag, WITHOUT using django forms
  • how to fix link tag in html after changing css
  • How do I add a top padding to the second row?
  • Is it possible to split XML into multiple HTML pages with page navigation?
  • AngularJS: responsive height in bootstrap
  • Hide second line of text with CSS
  • repeating-linear-gradient not working in Edge browser and internet Explorer Browser
  • how to make search and form category merges like amazon on bootstrap
  • Bootstrap: Rearranging rows into columns and changing the order of elements
  • How can I move a label under a text box?
  • How save LinearGradient To database
  • How to reposition an image with a linear gradient using css?
  • HTML audio will not play when page opened by batch file
  • CSS Three Tone Diagonal Background
  • How to use slots inside of template components in HTML
  • Using span tags in meta description & title, for dual languages
  • How to make an icon/span selectable by pressing Tab key?
  • Add dynamic margins using UI Kit
  • Add margin-top to textbox
  • What is the correct semantic HTML markup for a title (book, movie, etc.), according to the spec? Is it an <em> tag
  • How to make an animation in Geoserver or in Leaflet
  • Buttons overlapping when shrinking window
  • Stretch an element to the end of the automatically calculated grid, not just the explicit grid
  • What relation is there between Angular's <ng-content> and ShadowDOM
  • CSS background for div element is not working
  • CSS Marquee: multiple paragraphs overlaps
  • I want to align search bar to extreme right
  • Getting blank white space to the left of content inside pre tags
  • My viewer.html won't load any css and jss files
  • How to apply multiple styles to HTML to only part of a title?
  • Want to make text div transparent on a parallax area
  • Is there a way to make this ID plus descendants CSS rule less specific?
  • Is there a way to drop in a stylesheet to get a Material theme or similar for all form elements on the page?
  • How do I make a sideways L look in html/css?
  • Why won't the color #e67d22e1 display in Safari?
  • How to select specific tag's attribute value with xPath?
  • How to make div rows fill available height
  • How to fix text inside a block that grows
  • svg hexagon halftone pattern
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com