>  기사  >  웹 프론트엔드  >  CSS 페이지에서 왼쪽, 중간, 오른쪽 열 레이아웃 구현

CSS 페이지에서 왼쪽, 중간, 오른쪽 열 레이아웃 구현

不言
不言원래의
2018-06-21 16:36:233108검색

페이지의 왼쪽, 중간 및 오른쪽 열 레이아웃은 현재 웹 레이아웃에서 비교적 일반적입니다. 아래에서는 왼쪽, 중간 및 오른쪽 열 레이아웃을 달성하는 두 가지 좋은 방법을 알려 드리겠습니다. 놓치지 마세요

다음 코드를 복사하여 붙여넣을 수 있습니다.
예제 1:

<!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 charset="gb2312" /> 
<style type="text/css"> 
.page_center { 
width:100%; 
} 
#nav { 
background-color:red; 
height:20px; 
} 
#left { 
width:120px; 
background-color:green; 
position:absolute; 
} 
#middle { 
background-color:yellow; 
} 
#right { 
width:120px; 
background-color:green; 
position:absolute; 
top:0; 
right:0; 
} 
#foot { 
background-color:pink; 
} 
#main { 
position:relative; 
} 
</style> 
</head> 
<body> 
<p id="nav" class="page_center">上边</p> 
<p id="main" class="page_center"> 
<p id="left">左边</p> 
<p id="middle"> 中间部分</p> 
<p id="right">右边</p> 
</p> 
<p id="foot" class="page_center">底边</p> 
</body> 
</html>

예제 2:

<!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>Untitled Document</title> 
</head> 
<style type="text/css"> 
#left{ 
float:left; width:240px; height:500px; background:#0C9; 
} 
#right{ 
float:right;width:240px;height:500px; background:#933; 
} 
#center{ 
height:500px;background:#06C; 
} 
</style> 
<body> 
<p id="left" >左边</p> 
<p id="right" >右边</p> 
<p id="center" style="">中间</p> 
</body> 
</html>
<span style="font-size: 14px; font-family: Arial, Helvetica, sans-serif;"><strong></strong></span>

위 내용은 이 글의 전체 내용입니다. 더 많은 관련 내용을 보려면 PHP 중국어 웹사이트를 주목하세요!

관련 권장 사항:

CSS를 사용하여 다중 행 및 다중 열 레이아웃을 구현하는 방법 정보

위 내용은 CSS 페이지에서 왼쪽, 중간, 오른쪽 열 레이아웃 구현의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.