网页前端代码用css如何实现不规则的图片排列。求如下图的前端网页代码或示例。
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TEST</title>
<style>
.grid {
display: table;
transform:rotate(-45deg);
margin: 0 auto;
}
.grid > .grid-tr {
display: table-row;
}
.grid > .grid-tr > .grid-td {
display: table-cell;
width: 120px;
height: 120px;
border: 2px solid rgba(255,255,255,1);
background-color: aqua;
}
</style>
</head>
<body>
<div class="grid">
<div class="grid-tr">
<div class="grid-td"></div>
</div>
<div class="grid-tr">
<div class="grid-td"></div>
<div class="grid-td"></div>
</div>
<div class="grid-tr">
<div class="grid-td"></div>
<div class="grid-td"></div>
<div class="grid-td"></div>
</div>
<div class="grid-tr">
<div class="grid-td"></div>
<div class="grid-td"></div>
<div class="grid-td"></div>
<div class="grid-td"></div>
</div>
</div>
</body>
</html>
想放图片的话直接将 img标签放到 grid-td的div里面去。
思路很简单,看似不规则的排列实际是规则的,与其一个一个将div旋转,不如放入一个容器里面排列好,然后旋转了-45° 。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询