Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

CSS grid layout

From Wikipedia, the free encyclopedia
CSS properties for complex responsive webpages
This article may be written in a style that istoo abstract to be readily understandable bygeneral audiences. Pleaseimprove it by using words and phrases that have precise, specific meanings within a particular field, as well as by adding examples.(October 2017)
CSS Grid
CSS Grid Layout Module Level 1
A depiction of a typical webpage layout usingCSS floats.
AbbreviationGrid, grid layout
Native name
CSS Grid Layout Module Level 1
StatusW3C Candidate Recommendation Draft
First publishedApril 7, 2007 (2007-04-07)[1]
Latest versionLevel 1
December 18, 2020 (2020-12-18)[2]
Preview versionLevel 2
March 14, 2023 (2023-03-14)[3]
OrganizationW3C
CommitteeCSS Working Group
Editors
  • Tab Atkins Jr.
  • Elika J. Etemad
  • Rossen Atanassov
  • Oriol Brufau
  • Alex Mogilevsky
  • Phil Cupp
  • Markus Mielke[4][5]
[3]
Base standardsCSS
DomainCSS
Websitewww.w3.org/TR/css-grid-1/
Cascading Style Sheets
Concepts
Philosophies
Tools
Comparisons

InCascading Style Sheets,CSS grid layout orCSS grid creates complexresponsive web designgrid layouts more easily and consistently across browsers.[6] Historically, there have been other methods for controlling web page layout methods, such astables,floats, and more recently,CSS Flexible Box Layout (flexbox). CSS grid is currently not an official standard (it is aW3C Candidate Recommendation) although it has been adopted by the recent versions of all current major browsers.[7]

Motivation

[edit]

CSS grid can create more robust and flexible layouts than the previous options likeCSS floats. It also allows for more standardized code that works across browsers. This is in contrast to relying on specific browser hacks or complicated workarounds.[2]

One issue with exploiting floats in CSS is that if content gets added to one portion of the page it could disrupt the flow of the page and break the layout. This is due to the varying heights for layout elements.[2] Though flexbox supports flexible layouts and provides the flexibility of creating complex layouts, it fails when the need for creating responsive layouts in 2-dimensional space arises.

History

[edit]

The first comprehensive draft of a grid layout for CSS was created byPhil Cupp,Markus Mielke andAlex Mogilevsky atMicrosoft in 2011 and implemented inInternet Explorer 10 behind a-ms-vendor prefix. The syntax was restructured and further refined through several iterations in theCSS Working Group, led primarily byElika Etemad andTab Atkins Jr. The feature was widely adopted byweb developers afterevangelism led primarily byRachel Andrew andJen Simmons.[8]

Browser support

[edit]

As of October 2017, Chrome, Firefox, Safari and Edge all support CSS grid without vendor prefixes.[9][10][11] IE 10 and 11 support CSS grid but with an outdated specification. On mobile, all modern browsers support CSS grid except forOpera Mini.[12] Web developers targeting older browsers can utilizeModernizr 3.5.0 to detect and gracefully degrade the webpage as needed.[13]

Utilization in frameworks

[edit]

Tailwind CSS incorporates CSS grid into its utilities for controlling how elements are sized and placed.[14] However many other current web frameworks do not incorporate CSS grid, such asBootstrap 4 andFoundation 6.[15]

The fr unit

[edit]

The "fr" unit is often used with CSS grid layout.[16][17][18]The "fr" unit, part of the CSS grid layout specification, represents a fraction of the leftover space in the grid container.[2]

Examples

[edit]

"Holy grail" layout

[edit]

The following is an example of the"holy grail" layout:

HTML
<html><style>div{border:1pxsolid;}body{display:grid;grid-template-columns:10emauto10em;grid-template-areas:"header header header""left   middle right""footer footer footer";}</style><body><divstyle="grid-area: header">The header</div><divstyle="grid-area: footer">The footer</div><divstyle="grid-area: left">The left panel</div><divstyle="grid-area: middle; height: 200px">The main content area</div><divstyle="grid-area: right">The right panel</div></body></html>
OutputCSS Grid Holy Grail Layout

Table of values

[edit]

The following is an example of a table of values:

HTML
<html><style>.wrapper{display:grid;grid-template-columns:1fr1fr1fr;grid-gap:0.5em;}div{border:1pxsolid;}</style><body><divclass="wrapper"><h3>Header1</h3><h3>Header2</h3><h3>Header3</h3><div>value11</div><div>value12</div><div>value13</div><div>value21</div><div>value22</div><div>value23</div><div>value31</div><div>value32</div><div>value33</div><div>value41</div><div>value42</div><div>value43</div><div>value51</div><div>value52</div><div>value53</div><div>value61</div><div>value62</div><div>value63</div><div>value71</div><div>value72</div><div>value73</div></div></body></html>
OutputA simple implementation of the CSS Grid layout demonstrating a table layout

References

[edit]
  1. ^"CSS Grid Layout Module Level 1 Publication History - W3C".W3C. n.d. Retrieved2021-04-09.
  2. ^abcdAtkins Jr., Tab; J. Etemad, Elika; Atanassov, Rossen; Brufau, Oriol; Mogilevsky, Alex; Cupp, Phil; Mielke, Markus, eds. (2021-12-18)."CSS Grid Layout Module Level 1".W3C. W3C Working Group. Retrieved2021-04-09.
  3. ^abAtkins Jr., Tab; J. Etemad, Elika; Atanassov, Rossen, eds. (2023-03-14)."CSS Grid Layout Module Level 2".W3C. CSS Working Group. Retrieved2023-03-26.
  4. ^Mogilevsky, Alex; Cupp, Phil; Mielke, Markus; Glazman, Daniel, eds. (2011-04-07)."Grid Layout".W3C. CSS Working Group. Retrieved2021-04-09.
  5. ^Mogilevsky, Alex; Mielke, Markus, eds. (2007-09-05)."CSS Grid Positioning Module Level 3".W3C. CSS Working Group. Retrieved2021-04-09.
  6. ^"CSS Grid – Table layout is back. Be there and be square".Google Developers. January 2017. Retrieved2021-04-09.
  7. ^"CSS Grid Layout (level 1) | Can I use... Support tables for HTML5, CSS3, etc".caniuse.com. Retrieved2022-01-12.
  8. ^Gustafson, Aaron (2017-10-19)."The Story of CSS Grid, from Its Creators".A List Apart. Retrieved2022-01-12.
  9. ^Anderson, Kareem (13 September 2017)."Microsoft's newest browser gets a significant boost with EdgeHTML 16". Retrieved7 October 2017.
  10. ^Protalinski, Emil (9 March 2017)."Chrome 57 arrives with CSS Grid Layout and API improvements | VentureBeat".VentureBeat. Retrieved7 October 2017.
  11. ^"CSS Grid Layout".Can I Use. n.d. Retrieved2021-04-09.
  12. ^""grid" | Can I use... Support tables for HTML5, CSS3, etc".
  13. ^Ateş, Faruk (2017-04-13)."Modernizr 3.5.0".Modernizr News. Retrieved2021-04-09.
  14. ^"Grid Column Start / End - Tailwind CSS". Retrieved2021-04-13.
  15. ^Goetter, Raphael (2017-02-16)."Flexbox grids and frameworks".GitHub Gist. Archived fromthe original on 2017-02-16. Retrieved2021-04-09.
  16. ^Alligator.io (2020-09-03)."CSS Grid Layout: The Fr Unit".DigitalOcean. DigitalOcean. Retrieved2021-04-09.
  17. ^Marcotte, Ethan (2018-07-18)."Fractional. — Ethan Marcotte".Ethan Marcotte. Retrieved2021-04-09.
  18. ^Rendle, Robin (2017-06-12)."An Introduction to the 'fr' CSS unit".CSS-Tricks. Retrieved2021-04-09.

External links

[edit]
Products,
standards
Recommendations
Notes
Working drafts
Guidelines
Initiative
Deprecated
Obsoleted
Groups,
organizations
Elected
Working
Community, business
Closed
Software
Browsers
Conferences
Retrieved from "https://en.wikipedia.org/w/index.php?title=CSS_grid_layout&oldid=1329665565"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp