Heim  >  Artikel  >  Web-Frontend  >  css如何实现让两个div在同一行排列_html/css_WEB-ITnose

css如何实现让两个div在同一行排列_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:29:411681Durchsuche

css如何实现让两个div在同一行排列:
让两个div元素在同一行排列是基本的操作,实现也非常的简单,可能会对初学者有所帮助。
一.使用功能浮动方式:
代码如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css"> div{  width:150px;  height:50px;  background:blue;}.left{float:left}.right{float:right}</style></head><body><div class="left"></div><div class="right"></div></body></html>

二.将div设置为行内块级元素:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css"> div{  width:150px;  height:50px;  background:blue;  display:inline-block;}.left{background:red}.right{background:blue}</style></head><body><div class="left"></div><div class="right"></div></body></html>

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=13927

更多内容可以参阅:http://www.softwhy.com/divcss/

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn