Home > Web Front-end > HTML Tutorial > div的宽度和高度的固定_html/css_WEB-ITnose

div的宽度和高度的固定_html/css_WEB-ITnose

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

固定一列的宽度或者高度:
建议:尽可能的手写代码,可以有效的提高学习效率和深度。
在实际使用中往往需要给一个块设定固定的宽度或者高度,这一使用比较简单基础。
首先我们在文档中建立一个class名称为mytest的div,然后通过内联样式表设置div的宽度和高度。为了便于查看效果,div的background-color值设置为green。下面给出完整代码:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">.mytest {  background-color:green;  width:200px;  height:200px;}</style></head><body><div class="mytest"> </div></body></html>
Copy after login

以上代码将div的高度和宽度分别固定为200px。

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

更多内容可以参阅: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