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?
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.
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.
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.
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;
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With