Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Masonry Test: Self-Alignment along column axis of absolute positioned items</title>
<link rel="author" title="Yanling Wang" href="mailto:yanlingwang@microsoft.com">
<link rel="match" href="column-masonry-alignment-positioned-items-001-ref.html">
<style>
html,body {
color:black; background-color:white; font:10px/1 monospace; padding:0; margin:0;
}
.masonry {
position: relative;
display: masonry;
grid-template-columns: 100px 150px;
width: 300px;
height: 200px;
background: grey;
gap: 10px;
padding: 10px;
justify-items: start;
}
.masonry > div {
position: absolute;
}
.masonry > :nth-child(1) {
grid-column: 1 / 2;
align-self: start;
background: green;
}
.masonry > :nth-child(2) {
grid-column: 2 / 3;
align-self: start;
background: blue;
}
.masonry > :nth-child(3) {
grid-column: 1 / 2;
align-self: end;
background: yellow;
}
.masonry > :nth-child(4) {
grid-column: 2 / 3;
align-self: end;
background: red;
}
</style>
</head>
<body>
<div class="masonry">
<div>X XX X</div>
<div>XX X<br>X XXX X<br>XX XXX</div>
<div>X XX X</div>
<div>XX X<br>X XXX<br>X<br>XX XXX</div>
</div>
<div class="masonry" style="direction: rtl;">
<div>X XX X</div>
<div>XX X<br>X XXX X<br>XX XXX</div>
<div>X XX X</div>
<div>XX X<br>X XXX<br>X<br>XX XXX</div>
</div>
</body>
</html>