dongxia9620 2013-07-30 19:53
浏览 99
已采纳

使用css定位div标签

I created a php page that contains a div tag that contains a PHP code that get links from database, then shows an images, So now when it view the images in the div tag it shows the images vertically but I want it to shows me the images horzintilly, that's my code

<div class="pppi" style="width: 780px; height: 318px;overflow: auto; overflow-y: auto;">
 <?php
 $msqlq = mysql_query("SELECT * FROM `pictures` WHERE `to` = '$id'");
 while($fetchmsq = mysql_fetch_array($msqlq)){
 $pic = $fetchmsq['name'];
 $pics = "<div class='justprofile'><img src='uploaded/$pic'>&nbsp;&nbsp;";
 echo $pics;
 }
 ?>
</div>  

So that shows me like this enter image description here

but I want it to look like this enter image description here

How can I fix this problem, when I tried the css using top , right and position:absolute all the images was located to one position and no spaces between them.

  • 写回答

4条回答 默认 最新

  • doumie7914 2013-07-30 19:55
    关注

    In the HTML output from your PHP, you forgot to close the <div> element. Change the $pics line to this:

    $pics = "<div class='justprofile'><img src='uploaded/$pic'></div>";
    

    In your CSS, do:

    .justprofile {
        float: left;
    }
    

    You may add space between the images by specifying a margin, like this:

    .justprofile {
        float: left;
        margin-right: 1em;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型