question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow elements to stretch vertically to make it possible to align content to the bottom of a fixed-height card

See original GitHub issue

Implementation status

Problem

Currently, it is not really possible to align content at the bottom of a fixed-height card. Card authors have to recourse to hacks such as inserting an invisible image of a specific height to reserve some blank space. Such hacks are very fragile because they rely on knowing what the actual height of the target container is; cards authored using such hacks risk breaking if the container’s height changes.

Design

Add a new height property to all element types:

Property name Type Description
height string. Allowed values are “auto” and “stretch” Defines how the element’s height is computed within its parent container. When set to “auto” (default), the height of the element is what it needs. When set to “stretch”, the element stretches to the available height in its parent container. When multiple elements have their height property set to “stretch”, they share the available height equally.

Because we are introducing a “height” property, it makes sense to also rename the “size” property of a Column to “width”

Example

Card payload

{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"height": "stretch",
	"body": [
		{
			"type": "Container",
			"items": [
				{
					"type": "TextBlock",
					"text": "This is the top container.",
					"wrap": true
				}
			]
		},
		{
		    "type": "Container",
			"spacing": "large",
			"separator": true,
		    "items": [
		        {
		            "type": "TextBlock",
		            "text": "This is the middle container. Its **height** property is **stretch** so it uses all the remaining vertical space.",
		            "wrap": true
		        }
		    ]
		    
		},
		{
			"type": "ColumnSet",
			"height": "stretch",
			"columns": [
			    {
			        "width": "auto",
			        "items": [
						{
							"type": "Image",
							"url": "http://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg",
							"size": "small",
							"style": "person"
						}
			        ]
			    },
			    {
			        "width": "stretch",
			        "spacing": "large",
			        "separator": true,
			        "items": [
	                    {
	                        "type": "TextBlock",
	                        "height": "stretch",
	                        "text": "It also works within a ColumnSet",
	                        "wrap": true
	                    },
			            {
			                "type": "TextBlock",
			                "text": "This text aligns with the bottom of the column",
	                        "wrap": true
			            }
			        ]
			    }
			]
		},
		{
		    "type": "Container",
			"spacing": "large",
			"separator": true,
			"items": [
				{
					"type": "TextBlock",
					"text": "This is the bottom container.",
					"speak": "",
					"wrap": true
				}
			]
		}
	]
}

As rendered in the Windows Live Tile container:

image

Another example

Card payload

{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"height": "stretch",
	"body": [
		{
			"type": "ColumnSet",
			"columns": [
				{
					"width": 1,
					"items": [
						{
							"type": "TextBlock",
							"text": "The left column has a very, very long text which makes it very tall. Because it is tall, the right column is also very tall. The right column contains two TextBlocks; one is displaying at the top of the column, while the other one is displayed at the bottom. That is achieved by setting the first TextBlock's **height** property to **stretch**.",
							"wrap": true
						}
					]
				},
				{
					"width": 1,
					"spacing": "large",
					"separator": true,
					"items": [
						{
							"type": "TextBlock",
							"height": "stretch",
							"text": "First TextBlock displayed at the top",
							"wrap": true
						},
						{
							"type": "TextBlock",
							"text": "Second TextBlock displayed at the bottom",
							"wrap": true
						}
					]
				}
			]
		}
	]
}

As rendered

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:25 (25 by maintainers)

github_iconTop GitHub Comments

1reaction
dclauxcommented, Jul 18, 2017

@danmarshall first let me go back to the “bottom then top” example. We can totally make it work, that is what I was alluding to above. The logic would be:

  • Before rendering a container, the renderer groups top-aligned, center-aligned and bottom-aligned elements into 3 distinct collections
  • Each collection is rendered as an individual container (a stack of elements) in the order the elements were found in the payload
  • These individual containers are positioned at the top, center and bottom of the original container.

But the drawback is now that the first element in the payload is rendered visually below the second one. Not the end of the world though. Also, please don’t forget that to support center alignment we’d still need the height property as spece’d here.

Now I assume this is what you’re asking - notice how effortless is to evenly spread these text blocks:

image

{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"height": "stretch",
	"body": [
		{
			"type": "Container",
			"items": [
				{
					"type": "TextBlock",
					"text": "This is the top container.",
					"wrap": true
				}
			]
		},
		{
		    "type": "Container",
			"spacing": "large",
			"separator": true,
		    "items": [
		        {
		            "type": "TextBlock",
		            "text": "This is the middle container. Its **height** property is **stretch** so it uses all the remaining vertical space.",
		            "wrap": true
		        }
		    ]
		    
		},
		{
			"type": "ColumnSet",
			"height": "stretch",
			"columns": [
			    {
			        "width": "auto",
			        "items": [
						{
							"type": "Image",
							"url": "http://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg",
							"size": "small",
							"style": "person"
						}
			        ]
			    },
			    {
			        "width": "stretch",
			        "spacing": "large",
			        "separator": true,
			        "items": [
	                    {
	                        "type": "TextBlock",
	                        "height": "stretch",
	                        "text": "It also works within a ColumnSet",
	                        "wrap": true
	                    },
	                    {
	                        "type": "TextBlock",
	                        "height": "stretch",
	                        "text": "Other text",
	                        "wrap": true
	                    },
	                    {
	                        "type": "TextBlock",
	                        "height": "stretch",
	                        "text": "And one more",
	                        "wrap": true
	                    },
			            {
			                "type": "TextBlock",
			                "text": "This text aligns with the bottom",
	                        "wrap": true
			            }
			        ]
			    }
			]
		},
		{
		    "type": "Container",
			"spacing": "large",
			"separator": true,
			"items": [
				{
					"type": "TextBlock",
					"text": "This is the bottom container.",
					"speak": "",
					"wrap": true
				}
			]
		}
	]
}
0reactions
paulcam206commented, Sep 24, 2018

Documentation is done and in the mahiding/site1.1 branch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make Bootstrap card stretch to screen height inside ...
To center the right Card add className = "align-items-center" on the Row ... To enable scrolling only when needed, set the css property ......
Read more >
align-content - CSS: Cascading Style Sheets - MDN Web Docs
The CSS align-content property sets the distribution of space between and around content items along a flexbox's cross-axis or a grid's ...
Read more >
align-items
The align-items property is related to CSS layout. It effects how elements are aligned both in Flexbox and Grid layouts.
Read more >
Bootstrap Vertical alignment - examples & tutorial
Bootstrap 5 vertical alignment utilities position elements on the y-axis. You can center your content with it or align it to the top...
Read more >
Make Cards the Same Height Using Bootstrap
Learn how to make cards the same height using bootstrap's card-deck class and flexbox's d-flex and align-items-stretch.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found