2016-11-03 7 views
-1

콘텐츠의 위치에 큰 문제가 있습니다. 머리글과 바닥 글 아래에 숨겨진 많은 양의 콘텐츠가 있습니다. 모든 페이지에 머리말/꼬리말에 여백 - 아래/위쪽이 있어야합니다.머리글과 꼬리말 내용 ... 어떻게 해결할 수 있습니까?

여기 내 HTML 문서입니다 :

@page { 
 
      margin: 180px 50px; 
 
     } 
 

 
     #header { 
 
      position: fixed; 
 
      left: 0px; 
 
      top: -180px; 
 
      right: 0px; 
 
      height: 300px; 
 
      background-color: orange; 
 
      text-align: center; 
 
     } 
 

 
     #footer { 
 
      position: fixed; 
 
      left: 0px; 
 
      bottom: -180px; 
 
      right: 0px; 
 
      height: 300px; 
 
      background-color: lightblue; 
 
     } 
 

 
     #footer .page:after { 
 
      content: counter(page, upper-roman); 
 
     } 
 

 
     section { 
 
      margin-top: 100px; 
 
     }
<div id="header"> 
 
    <h1>Widgets Express</h1> 
 
</div> 
 
<div id="footer"> 
 
    <p class="page">Page </p> 
 
</div> 
 
<section> 
 
    What is Lorem Ipsum? 
 
    <br>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<br>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.<br>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.<br>It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 

 
    <br>Why do we use it? 
 
    <br>It is a long established fact that a reader will be distracted by <br>the readable content of a page when looking at its layout. 
 
    <br>The point of using Lorem Ipsum is that it has a more-or-less normal <br>distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. 
 
    <br>Many desktop publishing packages and web page editors now use Lorem <br>Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 
 
    <br>Various versions have evolved over the years, sometimes by accident,<br> sometimes on purpose (injected humour and the like). 
 

 

 
    <br>Where does it come from? 
 
    <br>Contrary to popular belief, Lorem Ipsum is not simply random text. 
 
    <br>It has roots in a piece of classical Latin literature from 45 BC, <br>making it over 2000 years old.<br>Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.<br>Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC.<br>This book is a treatise on the theory of ethics, very popular during the Renaissance.<br>The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. 
 

 
    <br>The standard chunk of Lorem Ipsum used since the 1500s is reproduced <br>below for those interested.<br>Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H.<br>Rackham. 
 

 
    <br>Where can I get some? 
 
    <br>There are many variations of passages of Lorem Ipsum available, <br>but the majority have suffered alteration in some form, by injected hum<br>our, or randomised wo<br>rds which don't look <br>even slightly believable.<br>If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text.<br>All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet.<br>It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable.<br>The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. 
 

 

 
    <br>5 
 
    <br>paragraphs 
 
    <br>words 
 
    <br>bytes 
 
    <br>lists 
 
    <br>Start with 'Lorem 
 
    <br>ipsum dolor sit amet...' 
 
    <br>Generate Lorem Ipsum 
 

 
</section>

결과 PDF는 다음과 같습니다 http://3.1m.yt/28MKkWG.png

+0

스크린 샷은 코드가 아닙니다. – PeeHaa

+0

jsfiddle 링크가 없으므로 코드를보고 실행할 수 있습니다. 어떻게 수정합니까? –

+2

코드 도움말을 찾는 질문에는 질문 자체에 ** ** [** Stack Snippet **] (https://blog.stackoverflow.com/2014/09/introducing- runnable-javascript-css-and-html-code-snippets /). [** 최소, 완전하고 검증 가능한 예제를 만드는 방법 **] (http://stackoverflow.com/help/mcve) –

답변

2

당신은 모든 페이지에 여백을 추가 할 CSS를 @page를 사용할 수 있습니다.
그러면 헤더에 음수 여백이 필요합니다.

<html> 
<head> 
<style type="text/css"> 
    @page { margin-top: 50px; } 
    .header { margin-top: -50px; } 
</style> 
</head> 
<body> 
<div class="header">Header</div> 
Rest of the page. 
</body> 
</html> 

편집 : 예를 들어 추가

+0

이 코드는 첫 번째 페이지에만 헤더를 만듭니다. 모든 페이지에 머리말이 있고 내 섹션 코드 위에 있지 않아도되는 여백 바닥을 모두 갖고 싶습니다. –

+0

나는 머리글/바닥 글 값을 변경하지 않고도 고정 된 머리글과 바닥 글을 스크립트에 가지고 있습니다. 그래서 나는 CSS 코드'body {background : url ('. $ baseUrl.'/ image // logo-print.png)를 사용한다. 패딩 - 상단 : 100px; }'. 이렇게하면 헤더와 바닥 글이있는 배경 이미지가 있기 때문에 모든 페이지에서 머리말/꼬리말을 반복합니다. – FamousWolluf

+0

섹션 { 위치 : 상대적; 상단 : 200x; 하단 : 400px; } 섹션에이 코드를 추가했는데 마진이 가장 큽니다. 이제는 바닥 글 만 텍스트 섹션을 덮고 있습니다. –

0

#header{ 
 
    position: fixed; 
 
    top: 0%; 
 
    left: 0%; 
 
    width: 100%; 
 
    background-color: orange; 
 
    text-align: center; 
 
} 
 
#footer{ 
 
    position: fixed; 
 
    left: 0%; 
 
    bottom: 0%; 
 
    width: 100%; 
 
    background-color: lightblue; 
 
} 
 
#footer .page:after{ 
 
    content: counter(page, upper-romen); 
 
} 
 
section{ 
 
    margin-top: 100px; 
 
}
<body> 
 
<div id="header"> 
 
<h1> 
 
Widget Express 
 
</h1> 
 
</div> 
 

 

 
<div id="footer"> 
 
<p class="page"> 
 
Page 
 
</p> 
 
</div> 
 
<section> 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
</section> 
 
</body>

+0

섹션 { 여백 : 100px 자동 70px 자동; } – Venkatachalam

+0

두 번째 페이지의 첫 페이지에만 적용됩니다 .. 헤더 섹션의 나머지 텍스트 내용을 다루고 있습니다 .. –

0

많이하지만 코드를보고 도움이되지 않는 이미지를 제공하는 예; "#header"와 "#footer"의 경우 위치를 설정할 수 있습니다 : relative 및 whereit은 top이라고 말하면 다른 값을 주지만 같은 값은 아닙니다.

코드를 복사하여 붙여 넣으면 더 도와 드릴 수 있습니다.

+0

https : // jsfiddle.net/0w75t98f/ jsfiddle에서는 한 페이지 만 만들 수 있습니다. dompdf를 사용하기 때문에 2-3-4 페이지를 만들고 jsfiddle에서 재현 할 수 없습니다. –