Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                ul
	li
	li
	li
	li
	li
	
// In detail explanation - https://dev.to/prvnbist/css-grid-cards-layout-aspect-ratio-45ni
              
            
!

CSS

              
                $dark: #19191c;
$lessDark: #303035;
$gutter: 16px;
$minWidth: 320px;
$maxWidth: 1fr;

/*
1. 1:1 - 100%
2. 16:9 - 56.25%
3. 4:3 - 75%
4. 3:2 - 66.66%
5. 8:5 - 62.5%
*/
$ratio: 56.25%;

body {
	padding: 16px;
	background: $dark;
}

ul {
	display: grid;
	grid-gap: $gutter;
	/*
	Minimum Width = 368px
	Maximum Width = 1fr i.e full width
	A card will wrap to next row if the browser can not fit cards with their minimum width
	
	auto-fill - this will try to fill all the columns or leave an empty columns if there aren't enough cards
	*/
	grid-template-columns: repeat(auto-fill, minmax($minWidth, $maxWidth));

	// auto-fit - this will fit all the cards in single row if the browser's width is equal to width of all the cards combine + gap
	// grid-template-columns: repeat(auto-fit, minmax($minWidth, $maxWidth));
	
	@media screen and (max-width: 320px) {
		grid-template-columns: repeat(auto-fill, minmax(100%, $maxWidth));
	}
}

li {
	background: $lessDark;
	padding-top: $ratio;
	border-radius: 8px;
	overflow: hidden;
	position: relative;
	img {
		top: 0;
		left: 0;
		width: 100%;
		position: absolute;
	}
}

              
            
!

JS

              
                
              
            
!
999px

Console