<!DOCTYPE html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>无标题 1</title> <style> div{ vertical-align:top; /*定义元素在行内的上下位置,比如sub*/ display:inline-block; margin:0; /*值为0,依然有外边距5px*/ background:black; width:200px; height:200px; } </style> </head> <body style="width:616px;color:white"> <div>1</div> <div style="height:400px;">2</div> <div>3</div> <!---无论是float还是inline-block,第4块将对其最长的第二块排列。因此不规则的瀑布式布局应该分好了三列,然后依次往三列中追加div。---> <div>4</div> <div>5</div> </body> </html>
关于float和inline-block实现不规则瀑布布局的探索
最新推荐文章于 2022-08-13 14:46:32 发布