WebGridLayout
Package: Libraries.Web.Layouts · Inherits from: Libraries.Language.Object, Libraries.Web.Layouts.WebLayout
WebGridLayout places the items inside an element in columns of equal width, filling each row before starting the next. It fits as many columns as the space allows, with none narrower than the smallest width, so a wide screen shows several side by side and a phone shows one. The gap is the space between items, in pixels.
Example Code
use Libraries.Web.Page.all
use Libraries.Web.Layouts.WebGridLayout
class Main is WebPage
action Main
WebGridLayout cards
cards:SetGap(12)
cards:SetSmallestColumnWidth(224)
Division division
SetLayout(division, cards)
Include(division)
end
end
Actions
Generate()
Returns the stylesheet declarations for this grid. WebSite calls this when it writes the stylesheet; people making pages don't.
Returns
text: The declarations for this grid.
SetColumnGap(number pixels)
Sets the space between columns, in pixels, when it should differ from the space between rows. SetGap sets both; this changes only the space across.
Parameters
pixelsnumber: The space between columns. It can't be negative.
SetColumns(integer count)
Sets a fixed number of columns, all the same width, instead of fitting as many as there is room for. Use a grid with fewer columns for small screens, and WebPage:SetLayoutFromWidth for more on wider ones, so nothing gets too narrow.
Parameters
countinteger: The number of columns, 1 or more.
Example
use Libraries.Web.Layouts.WebGridLayout
WebGridLayout oneColumn
oneColumn:SetColumns(1)
WebGridLayout threeColumns
threeColumns:SetColumns(3)
SetGap(number pixels)
Sets the space between items, across and down, in pixels.
Parameters
pixelsnumber: The space between items. It can't be negative.
SetSmallestColumnWidth(number pixels)
Sets the narrowest a column may be, in pixels. The grid fits as many columns as it can at this width or wider.
Parameters
pixelsnumber: The smallest column width. It must be more than 0.
UseFittedFirstColumn()
Makes the grid two columns: the first only as wide as its widest item, and the second the rest of the width. This suits pairs, such as terms and their descriptions, where every description should start at the same place.
Example
use Libraries.Web.Layouts.WebGridLayout
WebGridLayout pairs
pairs:UseFittedFirstColumn()