结痂:山河静默,我与岁月慢酌。大图男头
<style>.attach-col5 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
max-width: 800px;
margin:12px auto;
}
.attach-col5-column {
display: flex;
flex-direction: column;
gap: 12px;
}
.attach-col5 a {
display:block;
border-radius:12px;
overflow:hidden;
}
.attach-col5 img {
width:100%;
height:auto;
display:block;
border-radius:8px;
}
@media(max-width:640px){
.attach-col5{
gap:4px;
max-width:100%;
}
.attach-col5-column{gap:8px;}
}
</style>
<div class="attach-col5">
<div class="attach-col5-column" id="colLeft"></div>
<div class="attach-col5-column" id="colRight"></div>
</div>
<script>
// 将所有图片a标签自动奇偶分配到左右两列,顶部同时开始,列内瀑布流堆叠
(function(){
// 把这里替换你的图片HTML字符串,例如 let imgs_html = `<a><img src="1.jpg"></a><a><img src="2.jpg"></a>`
let imgs_html = `
<!-- 《图片位置》把全部a+img粘贴在这里 -->
`;
let tempDiv = document.createElement('div');
tempDiv.innerHTML = imgs_html;
let items = Array.from(tempDiv.children);
let left = document.getElementById('colLeft');
let right = document.getElementById('colRight');
items.forEach((el,idx)=>{
if(idx % 2 ===0){
left.appendChild(el);
}else{
right.appendChild(el);
}
})
})();
</script>
<div class="dz_attach_masonry_wrap">
<style>
/* 全部样式带命名空间,仅本块生效 */
.dz_attach_masonry_wrap .attach-col5 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
max-width: 800px;
margin: 12px auto;
}
.dz_attach_masonry_wrap .attach-col5__col {
display: flex;
flex-direction: column;
gap: 12px;
}
.dz_attach_masonry_wrap .attach-col5 a {
display: block;
border-radius: 12px;
overflow: hidden;
}
.dz_attach_masonry_wrap .attach-col5 img {
width: 100%;
height: auto;
display: block;
border-radius: 8px;
}
/* 移动端 */
@media (max-width: 640px) {
.dz_attach_masonry_wrap .attach-col5 {
gap: 4px;
max-width: 100%;
}
.dz_attach_masonry_wrap .attach-col5__col {
gap: 8px;
}
}
</style>
<div class="attach-col5">
<div class="attach-col5__col" data-side="left"></div>
<div class="attach-col5__col" data-side="right"></div>
</div>
<script>
(function(){
const root = document.querySelector('.dz_attach_masonry_wrap');
if(!root) return;
const colL = root.querySelector('');
const colR = root.querySelector('');
// ==========【在这里粘贴全部 <a><img src="xxx"></a> 图片代码】==========
let imageItemsHtml = `
<!-- 《图片位置》 -->
`;
const temp = document.createElement('div');
temp.innerHTML = imageItemsHtml;
const items = Array.from(temp.children);
// 奇偶分配:第1左、2右、3左、4右……两列同时从顶部开始
items.forEach((item, index)=>{
index % 2 === 0 ? colL.appendChild(item) : colR.appendChild(item);
});
})();
</script>
</div>
本帖最后由 结痂 于 2026-8-27 15:55 编辑 <br /><br /><br>
<br>
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1494577443&auto=1&height=66"></iframe> 选图眼光真不错。 山河静默,我与岁月慢酌。 宝藏帖子,必须支持。
山河静默,我与岁月慢酌。 山河静默,我与岁月慢酌。 山河静默,我与岁月慢酌。 山河静默,我与岁月慢酌。