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

WBOY
Release: 2016-06-24 11:29:41
Original
1719 people have browsed it

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>
Copy after login

二.将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>
Copy after login

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

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template