首页 > 资讯 > 网站设计
CSS基本布局16例
发布时间:2005-02-01   浏览次数:1151109
单行单列1:采用float浮在左上角,固定宽度。 #content {float: left;padding: 10px;margin: px;background: #FFF;border: 5px solid #666;width: 400px; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 370px;}html>body #content {width: 370px; /* ie5win fudge ends */} 单行单列2:固定在左上角,固定宽度,采用的是(absolute)定位。 #content {position: absolute;top: 0px;left: 0px;padding: 10px;margin: px;background: #FFF;border: 5px solid #666;width: 400px; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 370px;}html>body #content {width: 370px; /* ie5win fudge ends */}单行单列3:固定在左上角,不固定宽度,采用百分比(%)定义宽度来自适应页面。 #content {position: absolute;top: 0px;left: 0px;margin: px;background: #FFF;border: 5px solid #666;width: 74%; /* ie5win fudge begins */padding: 10px 10% 10px 15%;voice-family: "\"}\"";voice-family:inherit;width: 55%;padding: 10px 9% 10px 11%;}html>body #content {width: 55%;padding: 10px 9% 10px 11%;} /* ie5win fudge ends */单行单列4(推荐):固定宽度,采用在body样式中定义居中属性(text-align: center;)实现适应页面自动居中。 body {margin: 0px 0px 0px 0px;padding: 0px 0px 0px 0px;font-family: verdana, arial, helvetica, sans-serif;color: #c060;background-color: #CCC;text-align: center;/* part 1 of 2 centering hack */}#content {width: 400px; padding: 10px;margin-top: px;margin-bottom: px;margin-right: auto;margin-left: auto; /* opera does not like margin:px auto */background: #FFF;border: 5px solid #666;text-align:left; /* part 2 of 2 centering hack */width: 400px; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 370px;}html>body #content {width: 370px; /* ie5win fudge ends */}单行两列 单行两列1:两列都固定宽度。列浮在左上角,第二列浮在列右边。 #content {float: left;padding: 10px;margin: px;background: #FFF;border: 5px solid #666;width: 300px; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 270px;}html>body #content {width: 270px; /* ie5win fudge ends */} #content2 {float: left;padding: 10px;margin: px;background: #FFF;border: 5px solid #666;width: 300px; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 270px;}html>body #content2 {width: 270px; /* ie5win fudge ends */} 单行两列2:两列都百分比宽度,但不满屏。列固定在左上角,第二列浮在列右边。 #content {float: left;padding: 10px 2% 10px 2%;margin: px 1% px 2%;background: #FFF;border: 5px solid #666;width: 44%; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 41%;}html>body #content {width: 41%; /* ie5win fudge ends */} #content2 {float: right;padding: 10px 2% 10px 2%;margin: px 2% px 1%;background: #FFF;border: 5px solid #666;width: 44%; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 41%;}html>body #content2 {width: 41%; /* ie5win fudge ends */} 单行两列3:两列都百分比宽度,满屏。两列都采用定位。 #content {position: absolute;top: 0px;left: 0px;padding: 10px 2% 10px 2%;margin: 0px;border: 0px;background: #FFF;width: 50%; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 46%;}html>body #content {width: 46%; /* ie5win fudge ends */} #content2 {position: absolute;top: 0px;right: 0px; /* Opera5.02 will show a space at right when there is no scroll bar */padding: 10px 2% 10px 2%;margin: 0px;border: 0px;background: #FFF;width: 50%; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 46%;}html>body #content2 {width: 46%; /* ie5win fudge ends */} /* Opera5.02 shows a 2px gap between. N6.01Win sometimes does. Depends on amount of fill and window size and wind direction. */ 单行两列4:两列都百分比宽度,满屏。列浮在左上角,第二列浮在右上角。 #content {float: left;padding: 10px 2% 10px 2%;margin: 0px;border: 0px;background: #FFF;width: 50%; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 46%;}html>body #content {width: 46%; /* ie5win fudge ends */}#content2 {float: right; /* Opera5.02 will show a space at right when there is no scroll bar */padding: 10px 2% 10px 2%;margin: 0px;border: 0px;background: #FFF;width: 50%; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 46%;}html>body #content2 {width: 46%; /* ie5win fudge ends */} /* Opera5.02 shows a 2px gap between. N6.01Win sometimes does. Depends on amount of fill and window size and wind direction. */单行两列5:两列都百分比宽度,满屏。列浮在左上角,第二列浮在列右边。 #content {float: left;padding: 10px 2% 10px 2%;margin: 0px;border: 0px;background: #FFF;width: 50%; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 46%;}html>body #content {width: 46%; /* ie5win fudge ends */}#content2 {float: left; /* Opera5.02 will show a space at right when there is no scroll bar */padding: 10px 2% 10px 2%;margin: 0px;border: 0px;background: #FFF;width: 50%; /* ie5win fudge begins */voice-family: "\"}\"";voice-family:inherit;width: 46%;}html>body #content2 {width: 46%; /* ie5win fudge ends */
业务咨询

Copyright 2003 - 2023 huinet.cn All Rights Reserved.
慧网公司 版权所有