Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Masonry Test: Masonry layout with `align-self`</title>
<link rel="author" title="Yanling Wang" href="mailto:yanlingwang@microsoft.com">
<link rel="match" href="row-masonry-align-self-003-ref.html">
<style>
.masonry {
display: masonry;
width: 100px;
height: 250px;
grid-template-rows: repeat(4, 1fr);
masonry-direction: row;
gap: 5px;
border: 1px solid black;
margin-bottom: 20px;
}
.item {
background-color: #444;
color: #fff;
padding: 2px;
width: 50px;
}
.img-placeholder {
width: 48px;
height: 30px;
background: linear-gradient(45deg, #666, #999);
display: inline-block;
}
input[type="text"] {
background-color: #f0f0f0;
border: 1px solid #999;
padding: 2px;
height: 20px;
width: auto;
}
button {
background-color: #ddd;
border: 1px solid #999;
padding: 2px 4px;
cursor: pointer;
width: auto;
}
.start {
align-self: start;
background-color: red;
}
.end {
align-self: end;
background-color: blue;
}
.center {
align-self: center;
background-color: green;
}
.stretch {
align-self: stretch;
background-color: orange;
}
</style>
</head>
<body>
<div class="masonry">
<div class="item start">
<div class="img-placeholder"></div>
</div>
<div class="item center">
<div class="img-placeholder"></div>
</div>
<div class="item end">
<div class="img-placeholder"></div>
</div>
<div class="item stretch">
<div class="img-placeholder" style="height: 100%;"></div>
</div>
</div>
<div class="masonry">
<div class="item start">
<input type="text" value="start" style="width: 43px;">
</div>
<div class="item center">
<button>center</button>
</div>
<div class="item end">
<input type="text" value="end" style="width: 43px;">
</div>
<div class="item stretch">
<button style="height: 100%;">stretch</button>
</div>
</div>
</body>
</html>