[英]Display CSS boxes side by side
css code CSS代码
#folder {
width: 105px;
background: #BABABA;
position: relative;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 0px 10px 10px 10px;
}
This is CSS code to create boxes 这是创建框的CSS代码
php code PHP代码
<link rel="stylesheet" type="text/css" href="fold.css" /></style>
<?php
function listFolderFiles($dir,$exclude){
$ffs = scandir($dir);
echo '<ul class="ulli">';
foreach($ffs as $ff){
if(is_array($exclude) and !in_array($ff,$exclude)){
if($ff != '.' && $ff != '..'){
if(!is_dir($dir.'/'.$ff)){
} else {
echo '<div class=wrap><div id=folder><li>'.$ff.'</div></div>';
}
if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff,$exclude);
echo '</li>';
}
}
}
echo '</ul>';
}
listFolderFiles('.',array('index.php','edit_page.php'));
?>
It Displays the boxes one below the other How to display the boxes side by side 它在另一个下方显示框。如何并排显示框
float: left;
这将并排显示框,但是您需要在框之后的项目中添加以下属性才能正确显示。
clear: both;
#folder {display: inline-block;}
或#folder {float: left}
I'd say instead of doing: 我会说而不是做:
echo '<div class=wrap><div id=folder><li>'.$ff.'</div></div>';
try: 尝试:
echo '<li><div class=wrap><div id=folder>'.$ff.'</div></div></li>';
Making sure your < li >
tag is closing correctly and wrapping your divs
(or contrary, not sure what you're trying) 确保您的
< li >
标记正确关闭并包装了divs
(或者相反,不确定您要尝试的内容)
But your code doesn't seem really clean anyways, for example use class .folder
instead of id #folder
since ids should be unique by definition. 但是您的代码看起来还是不太干净,例如使用class
.folder
而不是id #folder
因为id在定义上应该是唯一的。
But i guess you gotta start somewhere, good luck :) 但是我想你得从某个地方开始,祝你好运:)
divs are block elements by default. divs默认是块元素。
these elements consume all available width. 这些元素消耗所有可用宽度。
Even if you set a width to them, the margin will get the rest. 即使您为它们设置了宽度,边距也会得到其余部分。
You can change this behavior by any of these methods: 您可以通过以下任何一种方法来更改此行为:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.