您现在的位置: 万盛学电脑网 >> 程序编程 >> 网页制作 >> DivCSS教程 >> 正文

div怎么分左右两半?

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 在内容排版上以前是在左上角放置广告后,内容跟随到广告下面,这次希望左右分开,不要跟随到广告下面,因为数据比较短,跟随到下面不留意发现,于是用到了div来控制左右两边分离,给需要的朋友参考下:

代码非常简单:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>exhibitor114</title> 
<style type="text/css"> 
<!-- 

#exhibitor114{ margin:0 auto;width:auto;height:100%} 
#exhibitorleft{ float:left; width:44%; height:100%; background:#eeeeee} 
#exhibitorright{ float:left; width:56%;height:100%;} 
--> 
</style> 
</head> 

<body> 
<div id="exhibitor114" style="float:inherit"> 
<div id="exhibitorleft">左侧</div> 
<div id="exhibitorright">右侧</div> 
</div> 
</body> 
</html>