使用CSS属性,您可以轻松地在HTML中并排放置三个<div>。使用CSS属性float可以实现此目的。
这样,添加height:100px并设置边距。
您可以尝试运行以下代码来将三个<div>并排放置。
<!DOCTYPE html> <html> <head> <title>HTML div</title> </head> <body> <div style="width: 100px; float:left; height:100px; background:gray; margin:10px"> First DIV </div> <div style="width: 100px; float:left; height:100px; background:yellow; margin:10px"> Second DIV </div> <div style="width: 100px; float:left; height:100px; background:red; margin:10px"> Third DIV </div> </body> </html>