Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to align element to bottom of page in print preview

Tags:

html

css

i am trying to align the element of my html page, using css.

I have aligned the element to bottom of page, but when i see the page in print preview. the element is not appearing at bottom

i am using this css to align element to bottom

code:

.bel {
    position:relative;
    margin-left: 38%;
    margin-right: 38%;
    bottom:-25pc;
}

html code:

<span class="bel">Text 1</span>

but this is not working...How can i solve this?

like image 376
MintY Avatar asked Oct 12 '13 10:10

MintY


People also ask

How do I move an element to the bottom of the page?

If position: absolute; or position: fixed; - the bottom property sets the bottom edge of an element to a unit above/below the bottom edge of its nearest positioned ancestor. If position: relative; - the bottom property makes the element's bottom edge to move above/below its normal position.

How do I align text at the bottom of the page?

Use the text-align property to align the inner content of the block element. Use the bottom and left properties. The bottom property specifies the bottom position of an element along with the position property. The left property specifies the left position of an element along with the position property.

How do you align a div to the bottom of a page?

Set the position of div at the bottom of its container can be done using bottom, and position property. Set position value to absolute and bottom value to zero to placed a div at the bottom of container.


2 Answers

To print an element at the bottom of the page, you should define some style rules for print. Here is the code:

@media print{
 .bel{
     position:fixed;
     bottom:0;
     }
}
like image 131
Mustafa Bazghandi Avatar answered Oct 13 '22 11:10

Mustafa Bazghandi


I found a useful answer in: How to use HTML to print header and footer on every printed page?:

div.divFooter {
    position: fixed;
    bottom: 0;
}

So, do not use absolute, as @idmean suggested, but fixed. As a bonus, the footer will appear on each printed page.

like image 20
R. Schreurs Avatar answered Oct 13 '22 10:10

R. Schreurs