2017-05-22 6 views
-1

Mein Div mit Text, Schaltflächen, Gif und Bild wird in die Mitte gesetzt, aber wie ein anderes div von ihm links, ohne neue Zeile als links gesetzt?
Bild Erklärung: https://prnt.sc/faolm5CSS-Ausrichtung und Positionierung

+0

Verwendung 'float: left' CSS-Eigenschaft –

+1

Können Sie den Code-Schnipsel hinzufügen –

+0

Sie bitte Ihre HTML und CSS – Chris

Antwort

0

Sie sollten dies überprüfen. LearnLayout Es wird dir helfen. Sie können das folgende CSS auch verwenden.

Beispiel ein

div { 
    display: inline-block; 
} 

Beispiel zwei

div { 
    float: left; 
} 
0

hinzufügen float: left

#div1 { 
    width: 50px; 
    height: 50 px; 
    border: 1px solid red; 
    float: left; 
} 

#div2 { 
    width: 50px; 
    height: 50 px; 
    border: 1px solid red; 
    float: left; 
    margin-left: 5px; 
} 

<!DOCTYPE html> 
<html> 

<head> 
    <link rel="stylesheet" href="style.css"> 
    <script src="script.js"></script> 
</head> 

<body> 
    <div id="div1"> 
    I am first! 
    </div> 

    <div id="div2"> 
    I am second! 
    </div> 
</body> 

</html> 

DEMO