douchi2022 2017-02-13 14:34
浏览 37
已采纳

为什么php插入的div重叠?

I got this html Code

<html>
<head>
    <meta charset="utf-8">
    <title>Dashboard</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
<?php
include 'functions.php';
$logs = getUnsuccessfulBuilds();
for ($i = 0; $i < sizeof($logs); $i++){
    echo("<div class='errorlog'>");
    echo($logs[$i]['name']);
    echo($logs[$i]['id']);
    echo("</div>");
}
?>
</body>
</html>

And this css code

body {
    background-color: #27373d;
}
.container {
    position: relative;
    width: 100%;
    height: 100%;
}
.errorlog {
    display: block;
    border-radius: 3px;
    width: 10%;
    overflow: hidden;
    float: left;
    background-color: #c6656a;
    padding: 20px;
    position: absolute;
    margin: auto;
    vertical-align: middle;
}

Why are the inserted elements colored, but not aligned as I want them to be? They are all at the same position, even if I change margin.

  • 写回答

1条回答 默认 最新

  • doujingxi3356 2017-02-13 14:37
    关注

    You have given all of the .errorlog divs position: absolute;, which will absolutely position them all ontop of each other.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试