Home  >  Article  >  Web Front-end  >  DIV CSS automatically adapts to width and height_html/css_WEB-ITnose

DIV CSS automatically adapts to width and height_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:31:041072browse

DIV CSS adaptive width:

<!DOCTYPE html/><html><head><title>自适应宽度实例--www.ops.cc</title><style type="text/css">/* 自适应宽度 */#left{width:150px;margin-right:-150px;float:left;}#center{width:auto;margin:0 0 0 150px;}#right{width:140px;margin-left:-140px;float:right;}/* 自适应高度度 *//* warp 用于隐藏溢出的部分 */#wrap{overflow:hidden;}#left,#center,#right{padding-bottom:20000px;margin-bottom:-20000px;}</style></head><body><div id="wrap"><div id="left" style="background:#333;height:600px;">左边栏,固定宽度150px;高度600px</div><div id="right" style="background:#555">右边栏,固定宽度150px;高度:自适应</div><div id="center" style="background:#888">中间栏,宽度:自适应,高度:自适应</div></div></body></html>

1. Note that when adapting to the width, arrange the left and right columns first and then let the middle column Arrange freely, so the order of 4bdcf5115dbbbca398fda50218f2427151168d198e83b298830021771a8f8f187487d9f1ae9c3b7df97224ef4c7bf8bb

2. The automatic height will Override the margin-bottom attribute of the div when both automatic width and automatic height are used. Preferably auto-height styles should come after auto-width.


#sidebar { width:auto; float:left;margin:0 762px 0 0;}
#main{width:742px;float:right;margin-left:-762px}

Please indicate the source for the original reprint of the article: http://newmin.cnblogs.com/archive/2010/11/04/div-css-auto-width-and-height.html

Statement:
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