Forum Bugs

column-span margin bug

John
hello,

we have stumbled upon a weird bug/behaviour when dealing with columns and column-span.

Our input files have several cascaded <section> elements which consist of a <div> element, that holds the actual content of this section and is probably followed by other <section> child elements (omitted in this simplified example).
The first element of the <div> always is a <h1> element. In a two-column layout we want the <h1> to span over both columns. We also want to specify a margin-bottom for the <div> element so there is space between the content of this <section> and it's possible child <section> elements.
But when we do this the margin-bottom is not only applied to the <div> element, but also the <h1> element, creating a margin where none should be.

Why is there a margin below the <h1> elements? There is none defined. It look as if the margin-bottom of the <div> element is applied to the <h1> elements.

The input file:
<!DOCTYPE HTML>
<html>
  <head>
    <style type="text/css" media="all">
      body {
        background: #00a1a1;
        margin: 0;
        padding: 0;
      }


      h1 {
        margin: 0;
        column-span: all;
      }

      article > section {
        column-count: 2;
      }

      section.level-1 {
        margin-bottom: 20mm;
      }

      section.level-1 > div {
        margin-bottom: 10mm;
      }

    </style>
  </head>
  <body>

    <article>
      <section class="level-1">
        <div>
          <h1>First headline</h1>
          <p>It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station with enough power to destroy an entire planet. Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy...</p>
        </div>  
      </section>

      <section class="level-1">
        <div>
          <h1>Second headline</h1>
          <p>It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station with enough power to destroy an entire planet. Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy...</p>
        </div>
      </section>
    </article>

  </body>
</html>

I have also attached the test file to reproduce the problem as well as the output PDF on my local machine.

Greetings,
John
  1. output.pdf25.7 kB
    Output file
  2. result.html1.8 kB
    input file

Edited by John

markbrown
Thanks for the detailed bug report. We will look into this.
John
Hello Mark,

let met know if you need anything, be it more information or support with testing. We have been using PrinceXML for some projects in the past as a desktop solution, but are now evaluating integrating it in our environment to increase automation. Down this road we need to avoid manual intervention as much as possible.

Greetings John

Edited by John

markbrown
Great, we'll do what we can to help!

Looking at this in Chrome, I see that there is a margin at the end of the div (i.e., in the last column), but this doesn't provide any space between the first column and any child sections. Is this what you had in mind? If not, it might be helpful to have a screenshot from somewhere showing what the output ought to look like.
John
Hello Mark,

yes the margin of the <div> was intentional:

      section.level-1 > div {
        margin-bottom: 10mm;
      }


The question I'm asking is: why is the margin also applied to the <h1>? If you remove the margin property for the div, there will also be no margin between the <h1> and the <p>. So it appears to me as if the margin property set for the div, is also applied to the <h1>.

I have attached the chrome print preview. Regarding the margins this is what I would expect.


  1. chrome_print_preview.png62.4 kB
    Chrome Print Preview

Edited by John

markbrown
I can confirm that the margin beneath the <h1> is a bug. Fixing it has been added to my TODO list.
John
hello mark,

I have received another bug report similar to this one. In the following example section.level-2 has a "margin-top" of "10mm" set. As you can see this is correctly applied. However, it appears as if the "margin-top" is also applied to the div.column-span-all.

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Column Span all Div - Margin Test</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>

    @page {
      size: 210mm 297mm;
    }

    * {
      margin: 0;
      padding: 0;
    }

    body {
      font-family: Arial, Helvetica, sans-serif;
      font-weight: normal;
      font-size: 8.5pt;
      line-height: 12pt;
    }

    section.level-1 {
      column-count: 2;
      column-fill: auto;
      column-gap: 6mm;
    }

    section.level-2 {
      /* this causes also a wrong top-margin of div.column-span-all: */
      margin-top: 10mm;
    }

    .column-span-all {
      column-span: all;
      height: 1cm;
      border: 1px solid black;
    }

    /* Coloring */
    body {
      background: yellow;
    }
    .level-1 {
      background: #ffb9b9;
    }
    .level-2 {
      background: #b9b9ff;
    }
    </style>
  </head>
  <body>
    <section class="level-1">
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab perferendis, doloribus porro rem dicta reprehenderit aliquam quis, qui assumenda provident ullam nobis. Vel pariatur expedita nihil doloremque labore illo, alias vero facilis, rem natus fuga temporibus aliquam aliquid placeat quos minima architecto atque quibusdam consequatur nesciunt accusantium eligendi praesentium nulla. Incidunt architecto sint neque culpa iusto exercitationem corporis optio nesciunt accusamus saepe mollitia laborum dolor numquam officiis recusandae doloremque, rerum dicta deserunt unde, excepturi animi eligendi sit. Voluptates voluptatem cum officia obcaecati soluta nostrum quaerat expedita, suscipit earum doloribus illo velit aspernatur molestiae, iste blanditiis perspiciatis. Optio expedita, eum adipisci.</p>
      <section class="level-2">
        <p>Starting section with margin-top. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab perferendis, doloribus porro rem dicta reprehenderit aliquam quis, qui assumenda provident ullam nobis. Vel pariatur expedita nihil doloremque labore illo, alias vero facilis, rem natus fuga temporibus aliquam aliquid placeat quos minima architecto atque quibusdam consequatur nesciunt accusantium eligendi praesentium nulla. Incidunt architecto sint neque culpa iusto exercitationem corporis optio nesciunt accusamus saepe mollitia laborum dolor numquam officiis recusandae doloremque, rerum dicta deserunt unde, excepturi animi eligendi sit. Voluptates voluptatem cum officia obcaecati soluta nostrum quaerat expedita, suscipit earum doloribus illo velit aspernatur molestiae, iste blanditiis perspiciatis. Optio expedita, eum adipisci.</p>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab perferendis, doloribus porro rem dicta reprehenderit aliquam quis, qui assumenda provident ullam nobis. Vel pariatur expedita nihil doloremque labore illo, alias vero facilis, rem natus fuga temporibus aliquam aliquid placeat quos minima architecto atque quibusdam consequatur nesciunt accusantium eligendi praesentium nulla. Incidunt architecto sint.</p>
        <div class="column-span-all">div with column-span all</div>
        <p>Neque culpa iusto exercitationem corporis optio nesciunt accusamus saepe mollitia laborum dolor numquam officiis recusandae doloremque, rerum dicta deserunt unde, excepturi animi eligendi sit. Voluptates voluptatem cum officia obcaecati soluta nostrum quaerat expedita, suscipit earum doloribus illo velit aspernatur molestiae, iste blanditiis perspiciatis. Optio expedita, eum adipisci.</p>
      </section>      
    </section>
  </body>
</html>


  1. case-1.html3.6 kB
    input
  2. case-1.pdf14.1 kB
    output
markbrown
The planned fix for the first problem should also cover this one. I'll be sure to test both, however!
hallvord
Hi John, thanks for attaching those files - I've modified them somewhat and added them to this repository for Prince testing:
https://github.com/yeslogic/miscellaneous-testcases/commit/7cdc5bc7c995fa9c1518017ed08056855aa55fbc
Hope you don't mind :)

Announcement: repos for tests/utils

John
hi hallvord,

thanks for adding them to the repo, as always :)

greetings,
john