2014-12-20 4 views
-5

PHP를 사용하여 코드를 개발 중입니다. 두 개의 파일 (header.php와 footer.php)을 다른 PHP 파일 인 index.php로 가져옵니다. 이제 수평으로 스크롤하는 동안 header.php 및 footer.php를 수정해야합니다. 나에게 코드를 제안 해 주시겠습니까? 나는 다음과 같은 코드이 파일의 index.php에서PHP 파일에서 머리글과 바닥 글을 수정하는 방법

Header.php 
code here 
footer.php 
code here 

index.php를

<?php include("header.php"); ?> 
welcome to index file 
welcome to index file 
welcome to index file 

<?php include("footer.php"); ?> 

를 사용하고, 나는 수평으로 스크롤하는 동안 그 머리글과 바닥 글이 고정되어야하고, 다른 사람의 CSS는 방해하지 않아야합니다 .

+2

처음에는 PHP와 관련이 없다는 것을 이해해야합니다. 그 CSS 부분은 –

+0

입니다. 괜찮 으면 –

답변

0

를 수집

<div id="header"> 
    <?PHP include_once('header.php');?> 
    </div> 
    <div id="wrap"> 
    welcome to index file 
    </div> 
    <div id="footer"> 
    <?PHP include_once('foo.php');?> 
    </div> 

CSS :

#header{position:fixed;top:0px;} 
#footer{position:fixed;bottom:0px;} 
position:fixed;하고 정상적으로 :

또는

header.php 
<div id ="header"></div><div id="content"> 
footer.php 
</div><div id="footer"></div> 

index.php 
<?PHP include_once('header.php');?> 
content here., 
<?PHP include_once('footer.php');?> 
+0

머리글과 바닥 글은 고정되어 있지만 스크롤은 위쪽과 아래쪽에서 작동합니다. –

0

귀하의 solucion은 괜찮습니다. 만 나는이 같은 것을 사용 권 해드립니다 :.이 시도

<div id="header"> 
<?PHP include_once('header.php');?> 
</div> 
<div id="wrap"> 
here is my html content 
</div> 
<div id="footer"> 
<?PHP include_once('foo.php');?> 
</div> 

include_once의 사용이 일부 파일 의 include을 반복하지 않습니다에 대한 좋은 CSS와 excelent 레이아웃을

+0

라고 말하면됩니다. 머리말, 꼬리말 및 랩 div에 대한 CSS도 제안 할 수 있습니다. –

+0

@adeshsingh 있습니다. css..i로 답변을 추가했습니다. 추가 질문이있는 경우 u가 도움이 될 수 있습니다. :) –

+0

스크롤은 상단과 하단까지 작동하지만 스크롤은 헤더와 하단 하단에서 작동해야합니다. –

0

사용 HTML5하고 여기에 include_once

<header> 
<?PHP include_once('header.php');?> 
</header> 
<div id="wrap"> 
here is my html content 
</div> 
<footer> 
<?PHP include_once('foo.php');?> 
</footer> 

를 사용은 다음과 같은 속성을 넣어, 당신의 CSS에서 그냥 샘플 FIDDLE DEMO

html,body{ 
    margin:0;padding:0; 
} 
header{ 
    background:Green; 
    height:50px; 
} 
footer{ 
    position:absolute; 
    width:100%; 
    bottom:0; 
    background:Red; 
    height:50px; 
} 
0

입니다 속임수를 써라.

관련 문제