Anuj TBE
Anuj TBE

Reputation: 9790

weasyprint give margin to parent page

Using weasyprint in Python and here is the @page CSS

@page {
    size: A4;
    margin: 1cm;
    margin-top: 2cm;

    @top-left {
        background: var(--bs-primary);
        content: counter(page);
        height: 1cm;
        margin-top: 1cm;
        text-align: center;
        width: 1cm;
        color: var(--bs-white);
    }
    @top-center {
        background: var(--bs-primary);
        content: '';
        display: block;
        height: .05cm;
        opacity: .5;
        width: 100%;
    }
    @top-right {
        content: element(header);
        font-size: 9pt;
        height: 1cm;
        vertical-align: middle;
        width: 100%;
    }
}
@page :blank {
    @top-left { background: none; content: '' }
    @top-center { content: none }
    @top-right { content: none }
}
@page :first {
    background: url('../img/v915-wit-011-f_.jpg') no-repeat center;
    background-size: cover;
    margin: 0;
}
@page responses {
    margin-top: 1cm;
}

header {
  position: running(header);
    text-align: right;
}
.page-break-inside {
    page-break-inside: avoid;
}
.page-break-before {
    break-before: always;
}
#responses {
    page: responses;
}

The margin of 2cm is applied on the first page but other pages with ID responses do not have any margin.

When added, the margin is applied between the top and the content. Whereas I want to add overall margin to the responses pages also.

Upvotes: 0

Views: 140

Answers (0)

Related Questions