Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Padding/ Margin values with relative units not working #145

Open
subhadhal opened this issue Oct 24, 2017 · 1 comment
Open

Padding/ Margin values with relative units not working #145

subhadhal opened this issue Oct 24, 2017 · 1 comment
Assignees

Comments

@subhadhal
Copy link

subhadhal commented Oct 24, 2017

Hi Dan,

If padding/ margin values are provided in percentage(%) value, then no padding/ margin is getting applied. The actual HTML gives the appropriate padding/ margin. Is there any alternative/ fix for this?

<html>
	<head>
		<style type="text/css">
		@page
		{
			size:8.5in 11in portrait; 
			margin-left: 10px; 
			margin-right:15px;
			margin-top:10px;
			margin-bottom: 0;
		}
		body
		{
			height: 11in;
			width: 8.5in;
			display: block;
			page-break-after: always;
			margin-top: 0px;
			position: relative;
		}
		.parent
		{
			display: table;
			padding : 10%;
			width: 99.95%;
		}
		.tableHead
		{
			display: table-row;
			border: 1px solid black;
		}
		.tableHead span
		{
			display: table-cell;
			width: 1px;
			white-space: nowrap;
			word-break: break-word;
			text-align: center;
			border-bottom: 1px solid black;
			border-right: 1px solid black;
		}
		</style>
	</head>
	<body>
		<div class="parent">
			<div class="tableHead">
				<span>CODE</span>
				<span>DESCRIPTION</span>
				<span>QTY</span>
				<span>PRICE CS</span>
				<span>PRICE IP</span>
				<span>PRICE PC</span>
				<span>AMOUNT DUE</span>
			</div>
		</div>
	</body>
</html>

Here I have provided 10% padding to the .parent div, it is not getting applied. Please help!!
Below is the output when I provide padding in percentage.
capture

Below is the output when I provide padding in pixels(NOTE: When I use absolute CSS units, it works fine. But I don't want to use absolute units, instead I want to use relative units)
capture1

@subhadhal subhadhal changed the title Padding/ Margin values with percentage units not working Padding/ Margin values with absolute units not working Oct 24, 2017
@subhadhal subhadhal changed the title Padding/ Margin values with absolute units not working Padding/ Margin values with relative units not working Oct 24, 2017
@danfickle
Copy link
Owner

Hi @subhadhal

I tested your example and indeed padding with percentage values is not working. I did however, get margins with percentage values to work and this may be a workaround for your situation.

<html>
	<head>
		<style type="text/css">
		@page
		{
			size:8.5in 11in;
			-fs-page-orientation: portrait; 
			margin-left: 10px; 
			margin-right:15px;
			margin-top:10px;
			margin-bottom: 0;
		}
		body
		{
			height: 11in;
			width: 8.5in;
			display: block;
			page-break-after: always;
			margin-top: 0px;
			position: relative;
		}
		.parent
		{
			margin: 10%;
			display: table;
			width: 79.95%; /* width of content-box */
		}
		.tableHead
		{
			display: table-row;
			border: 1px solid black;
		}
		.tableHead span
		{
			display: table-cell;
			width: 1px;
			white-space: nowrap;
			word-break: break-word;
			text-align: center;
			border-bottom: 1px solid black;
			border-right: 1px solid black;
		}
		</style>
	</head>
	<body>
		<div class="parent">
			<div class="tableHead">
				<span>CODE</span>
				<span>DESCRIPTION</span>
				<span>QTY</span>
				<span>PRICE CS</span>
				<span>PRICE IP</span>
				<span>PRICE PC</span>
				<span>AMOUNT DUE</span>
			</div>
		</div>
	</body>
</html>

Thanks for providing a complete example and please leave this issue open as this is a major failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants