2017-02-13 8 views
0

Ich habe diesen HTML-CodeWarum werden divs php überlappend eingefügt?

<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> 

Und diese 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; 
} 

Warum sind die eingefügten Elemente farbig, aber nicht ausgerichtet sind, wie ich sie sein? Sie sind alle an der gleichen Position, auch wenn ich margin ändere.

+0

Entfernen Sie 'position: absolute;' von '.errorlog'. – jeroen

+1

Danke, das war es :) – Barsch

Antwort

1

Sie haben alle .errorlog-divs position: absolute; angegeben, die sie alle übereinander positionieren.

+0

Danke. Das war's :) – Barsch

Verwandte Themen