html - How to use absolute position relative to parent element -
html report contains rows elements should printed in same line. absolute left positions specified @ design time.
each row should appear in next line after previous row without explicit top attribute like
row1 field1 row1 field2 row2 field1 row2 field2
according http://www.tutorialspoint.com/css/css_paged_media.htm , absolute positioning , parent element absolute position parent relative element position.
so must work:
<!doctype html> <html> <head> <style> .row { position: relative; } .field { position: absolute; } </style> </head> <body> <div class='row'> <div class='field' style='left:5cm'>row1 field1</div> <div class='field' style='left:16cm'>row1 field2</div> </div> <div class='row'> <div class='field' style='left:8cm'>row2 field1</div> <div class='field' style='left:12cm'>row2 field2</div> </div> </body> </html>
unfortunately, not work unknown reason. elements appear in same row:
row1 field1 row2 field1 row2 field2 row1 field2
adding top attributes top of screen produces desired layout:
<div class='row'> <div class='field' style='top:1cm;left:5cm'>row1 field1</div> <div class='field' style='top:1cm;left:16cm'>row1 field2</div> </div> <div class='row'> <div class='field' style='top:2cm;left:8cm'>row2 field1</div> <div class='field' style='top:2cm;left:12cm'>row2 field2</div> </div>
elements heights , browser rendered line heights may vary. big empty space between rows should eliminated. difficult calculate poper top values html requires.
how desired layout without using top attribute? every row div element should start in next row after previous row element browser renders block elements.
i can use table or other implemented elements if helps instead of divs. report razor view generated @ runtime asp.net mvc4 application , run using razorengine go html rendered in desktop modern browser.
try giving each .row
height
attribute
.row { position: relative; height:1em; }
divs typically have 0 or null height effect when not explicitly set.
Comments
Post a Comment