水平对齐列表项

时间:2014-04-12 07:24:21

标签: php html css html-lists

我正在尝试在宽度为92%的<li>上分发三个<ul>元素。到目前为止,我只是将<ul>与这个类集中在一起:

.centeralign {
display: table;
margin: 0 auto;

}

但是在尝试了多种方法在<li>之间均匀分布这些<ul>元素之后,我仍然无法让它们分发。我得到三张<li>,如下图所示。

这是HTML / PHP代码:

<ul class="featuredevs centeralign">
<?php
    $developers = array();

    $sql = "SELECT `userid` FROM UserData WHERE `name`!='' AND `profileImg`!='' ORDER BY `userid` desc limit 3;";
    include 'SQLaccount.php';
    $result = mysqli_query($accountCon,$sql) or die ("Error: ". mysql_error(). " with query ". $sql);
    $numOfDevs = $result->num_rows;
    mysqli_close($accountCon);
    while($row = mysqli_fetch_array($result)){
        array_push($developers, $row['userid']);
    }


    <?php
$cnt = 3;
foreach ($developers as $userid) {
    $name = "";
    $profileImg = "";

    $sql = "SELECT `name`, `profileImg` FROM UserData WHERE `userid`=$userid;";
    include 'SQLaccount.php';
    $result = mysqli_query($accountCon,$sql) or die ("Error: ". mysql_error(). "    with query ". $sql);
    mysqli_close($accountCon);
    while($row = mysqli_fetch_array($result)){
        $name = $row['name'];
        $profileImg = $row['profileImg'];
        break;
    }

    echo('<li class="developerdiv">');

    echo ("<a class='' href='profile.php?user=$userid'>");

    echo("<img class='featureimage img-rounded' src='userPictures/$profileImg' alt='$name Profile Picture>");

    echo("div class='devinfo'>");
    echo("<p class='devname'>" . $name . "</p>");
    echo("<p class='devdesc'>" . $userid . "</p>");
    echo("</div>");

    echo ('</a>');

    echo('</li>');


    $cnt += 1;

}


    ?>
    </ul>

任何建议都备受赞赏!

0 个答案:

没有答案