二列div固定宽度_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:31:24
Original
1061 people have browsed it

二列div固定宽度:
建议:尽可能的手写代码,可以有效的提高学习效率和深度。
在div+css布局中经常会用到两列固定宽度的div,一般用来对页面的功能区域的划分。之前已经介绍了一列div固定宽度,下面简单介绍一下如何让两列div并列显示,并且宽度是固定的。其实原理很简单,就是给两个div以固定的宽度,然后让他们并列显示。代码:

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

以上代码中使用float属性,让两个div在一行显示。点击可查看flaot属性介绍。

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

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

Related labels:
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