How to fix the div aligning inside <table> - html

How can I have align Name with title/phone/email and when I expand my page the aligning is messing up as shown in screen shot 1 and 2
I have tried: style="display:initial;position: relative; "
but does not do any good.
<table class="detailList" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="data2Col first " colspan="2">
<div>
<span class="labelCol vfLabelColTextWrap" scope="row" style="display:inline-block; ">Name </span>
<span class="data2Col"> Erich Schulz </span>
</div>
</td>
</tr>
<tr>
<th class="labelCol vfLabelColTextWrap " scope="row">Title</th>
<td class="data2Col "><span id="j_id0:j_id1:j_id3:j_id4:j_id6"></span></td>
</tr>
<tr>
<th class="labelCol vfLabelColTextWrap " scope="row">Phone</th>
<td class="data2Col "><span id="j_id0:j_id1:j_id3:j_id4:j_id7">(555) 555-5555</span></td>
</tr>
<tr>
<th class="labelCol vfLabelColTextWrap last " scope="row">Email</th>
<td class="data2Col last "><span id="j_id0:j_id1:j_id3:j_id4:j_id8">test#example.com</span></td>
</tr>
</tbody>
</table>

Try replacing both span elements with th and td
<span class="labelCol vfLabelColTextWrap" scope="row" style="display:inline-block; ">Name </span>
<span class="data2Col"> Erich Schulz </span>
Shown below:
<th class="labelCol vfLabelColTextWrap " scope="row">Name </th>
<td class="data2Col"> Erich Schulz </td>

As written in my comment, I would replace the span elements in the first table row by td elements (and remove the colspan=2 from that row):
<table class="detailList" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="data2Col first ">
<div>
<td class="labelCol vfLabelColTextWrap" scope="row" style="display:inline-block; ">Name </td>
<td class="data2Col"> Erich Schulz </td>
</div>
</td>
</tr>
<tr>
<th class="labelCol vfLabelColTextWrap " scope="row">Title</th>
<td class="data2Col "><span id="j_id0:j_id1:j_id3:j_id4:j_id6"></span></td>
</tr>
<tr>
<th class="labelCol vfLabelColTextWrap " scope="row">Phone</th>
<td class="data2Col "><span id="j_id0:j_id1:j_id3:j_id4:j_id7">(555) 555-5555</span></td>
</tr>
<tr>
<th class="labelCol vfLabelColTextWrap last " scope="row">Email</th>
<td class="data2Col last "><span id="j_id0:j_id1:j_id3:j_id4:j_id8">test#example.com</span></td>
</tr>
</tbody>
</table>
Or, if for some reason you have to keep those span elements, wrap them with <td>...</td>
Additional edit: As spencerlarry wrote correctly, the first one is actually a <th> tag. But that probably won't make a difference regarding the alignment.

Why do you use the first column in one piece? Please change the first <tr> block as follows:
<tr>
<td class="labelCol first">
<span class="vfLabelColTextWrap" scope="row">Name </span>
</td>
<td class="data2Col">
Erich Schulz
</td>
</tr>

Related

Align text in table html

I have table:
<table border="1" width="100%">
<thead>
<tr>
<th width="50%">Name</th>
<th width="50%"><span style="width: 50%;text-align: left;">Price</span> / <span style="width: 50%;text-align: right;">Einheit</span></th>
</tr>
</thead>
<tbody>
<tr>
<td>Name1</td>
<td><span style="width: 50%;text-align: left;">1000</span> / <span style="width: 50%;text-align: right;">Hour</span></td>
</tr>
<tr>
<td>Name2</td>
<td><span style="width: 50%;text-align: left;">250.50</span> / <span style="width: 50%;text-align: right;">Day</span></td>
</tr>
</tbody>
</table>
Need that 1000 and 250.50 were under the word Price, Hour and Day were under the word Einheit. I tried do it using width property and text-align but it doesnt work.
Need this result, for example:
https://clip2net.com/s/3ZXsphT
Thanks
By Default span tag is inline element, it doesn't take width. You need to change span tag to block label element using display or float. check updated snippet below...
td span {
display: inline-block;
width: 47%;
}
<table border="1" width="100%">
<thead>
<tr>
<th width="50%">Name</th>
<th width="50%"><span style="width: 50%;text-align: left;">Price</span> / <span style="width: 50%;text-align: right;">Einheit</span></th>
</tr>
</thead>
<tbody>
<tr>
<td>Name1</td>
<td><span style="text-align: right;">1000</span> / <span style="text-align: left;">Hour</span></td>
</tr>
<tr>
<td>Name2</td>
<td><span style="text-align: right;">250.50</span> / <span style="text-align: left;">Day</span></td>
</tr>
</tbody>
Add this CSS
table tr td:nth-child(even){
text-align:center;
}
<table border="1" width="100%">
<thead>
<tr>
<th width="50%">Name</th>
<th width="50%"><span>Price</span> / <span>Einheit</span></th>
</tr>
</thead>
<tbody>
<tr>
<td>Name1</td>
<td><span>1000</span> / <span>Hour</span></td>
</tr>
<tr>
<td>Name2</td>
<td><span>250.50</span> / <span>Day</span></td>
</tr>
</tbody>
</table>
Actually, you don't need any single span as none was executed.
price / Einheit was centered only as this is the default of th tag
So, in order to align the cell beneath it, you can just code td style=" text-align:center"
and if you want to align all cells to the center
table style="text-align:center"

XPath to table cell (td) contents based upon label?

Can anyone help me to find the right XPath to retrieve the Average Win and Loss value (36.68 pips and -38.56 pips) from this web page:
https://www.myfxbook.com/members/babatrader/ic-markets-live/2595252
Here the portion of the HTML
<table class="maxWidth" cellspacing="0" id="trades">
<tbody><tr>
<td valign="top">
<table cellspacing="0" class="advanced border0L">
<tbody><tr class="bg1">
<td>Trades:</td>
<td class="alignR">2885</td>
</tr>
<tr>
<td>Profitability:</td>
<td align="right" class="pointer">
<span id="wonTip" class="Won 1619 out of 2885 trades, which represents 56%.<br/>Lost 1266 out of 2885 trades, which represents 44%."><div class="blockHolder">
<div class="greenBlock floatLeft" style="width:56px"></div>
<div class="redBlock floatLeft" style="width:44px"></div>
</div></span>
</td>
</tr>
<tr class="bg1">
<td>Pips:</td>
<td class="alignR">10571.7</td>
</tr>
<tr>
<td>Average Win:</td>
<td class="alignR">36.68 pips / €3.31</td>
</tr>
<tr class="bg1">
<td>Average Loss:</td>
<td class="alignR">-38.56 pips / -€3.56</td>
</tr>
<tr>
<td> Lots:</td>
<td class="alignR">38.94</td>
</tr>
<tr class="bg1">
<td>Commissions:</td>
<td class="alignR">-€226.56</td>
</tr>
</tbody></table>
</td>
<td valign="top">
<table cellspacing="0" class="advanced border0R border0L">
<tbody><tr>
<td>Longs Won:</td>
<td align="right">
<span class="gray">(687/1247) </span> 55%
</td>
</tr>
<tr class="bg1">
<td>Shorts Won:</td>
<td align="right">
<span class="gray">(932/1638) </span> 56%
</td>
</tr>
<tr>
<td>Best Trade(€):</td>
<td class="alignR"> <span class="gray">(Jul 20)</span> 17.93
</td>
</tr>
<tr class="bg1">
<td> Worst Trade(€):</td>
<td class="alignR"> <span class="gray">(Jul 19)</span> -32.08
</td>
</tr>
<tr>
<td>Best Trade (Pips):</td>
<td class="alignR"> <span class="gray">(Sep 07)</span> 177.5
</td>
</tr>
<tr class="bg1">
<td>Worst Trade (Pips):</td>
<td class="alignR"> <span class="gray">(Sep 06)</span> -190.0
</td>
</tr>
<tr>
<td>Avg. Trade Length:</td>
<td class="alignR">
22h 45m
</td>
</tr>
</tbody></table>
</td>
<td>
<table cellspacing="0" class="advanced border0R">
<tbody><tr class="bg1">
<td><span class="dotted" id="pfTip">Profit Factor:</span></td>
<td class="alignR">
1.19
</td>
</tr>
<tr>
<td><span class="dotted" id="sdTip">Standard Deviation:</span></td>
<td class="alignR">€4.30</td>
</tr>
<tr class="bg1">
<td><span class="dotted" id="sharpTip">Sharpe Ratio:</span></td>
<td class="alignR">
0.00
</td>
</tr>
<tr>
<td><span class="dotted" id="zTip">Z-Score (Probability):</span></td>
<td class="alignR">
-31.21 (99.99%)
</td>
</tr>
<tr class="bg1">
<td><span class="dotted" id="expTip">Expectancy:</span></td>
<td class="alignR">3.7 Pips / €0.30</td>
</tr>
<tr>
<td><span class="dotted" id="ahprTip">AHPR:</span></td>
<td class="alignR">0.01%</td>
</tr>
<tr class="bg1">
<td><span class="dotted" id="ghprTip">GHPR:</span></td>
<td class="alignR">0.01%</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
I've tried without succeed: The below is the one I have tried it.
//*[#id="trades"]/tbody/tr/td[1]/table/tbody/tr[5]/td[2]
//*[#id="trades"]/tr/td[1]/table/tbody/tr[5]/td[2]
and many others.. ;-)
This XPath,
substring-before(//table[#id="trades"]
//td[.="Average Win:"]/following-sibling::td[1], " /")
will select
36.68 pips
as requested, and you should find it to be more robust than many alternatives. For example, the table structure can change substantially, and as long as the label and the relative positions of the two table cells remain the same, this XPath will continue to function.
i had to remove both "tbody"
//*[#id='trades']/tr/td/table/tr[4]/td[2]

Force an element to take exactly half of available height in print media

I am dynamically creating elements (student bills) on a web page which I want to print.
I want this element to take only half of the total printable height in print media, so that I can print two elements on one page.
But in the picture, It's clear that some part of the third element is appearing on first page, which should actually go on the second page.
How can I force this element (one student's bill) to take exactly half of the height of the page?
<div class="col-md-6">
<div id="page-wrap">
<div style="clear:both"></div>
<div id="customer">
<div id="customer-title">
<table>
<tbody>
<tr>
<td style="text-align:center">
12017 </td>
<td style="text-align:center">
dfsdgf sdgsdg sdgsdg </td>
<td style="text-align:center">
1st </td>
</tr>
<tr>
<td style="text-align:center">
32817 </td>
<td style="text-align:center">
Sarika Godara </td>
<td style="text-align:center">
3rd </td>
</tr>
</tbody>
</table>
</div>
<table id="meta">
<tbody>
<tr>
<td class="meta-head">Bill #</td>
<td>149</td>
</tr>
<tr>
<td class="meta-head">Date</td>
<td id="date">11-08-2017</td>
</tr>
<!--tr>
<td class="meta-head">Amount Due</td>
<td><div class="due">Rs.</div></td>
</tr-->
</tbody>
</table>
</div>
<table id="items">
<tbody>
<tr>
<th colspan="1">Sr.No.</th>
<th colspan="4">Description</th>
<th colspan="1">Detail</th>
<th colspan="1">Sub-total</th>
</tr>
<tr>
<td colspan="1">1
</td>
<td colspan="4"> Tuition Fees(upto September)
</td>
<td colspan="1">2600 + 2750
</td>
<td colspan="1">5350
</td>
</tr>
<tr>
<td colspan="1">2
</td>
<td colspan="4"> AC
</td>
<td colspan="1">2450 + 2450
</td>
<td colspan="1">4900
</td>
</tr>
<tr>
<td colspan="1">3
</td>
<td colspan="4"> Transport Fees(upto September)
</td>
<td colspan="1">1650
</td>
<td colspan="1">1650
</td>
</tr>
<tr>
<td colspan="2" class="blank"> </td>
<td colspan="4" class="total-line">Grand Total</td>
<td class="total-value">
<div id="total">Rs. 11900</div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"> </td>
<td colspan="4" class="total-line">Amount Paid</td>
<td class="total-value">Rs. 0</td>
</tr>
<tr>
<td colspan="2" class="blank"> </td>
<td colspan="4" class="total-line balance">Balance Due</td>
<td class="total-value balance">
<div class="due">Rs. 11900</div>
</td>
</tr>
</tbody>
</table>
<div id="terms">
<h5>Please Note</h5> आपने अपने बच्चे की फीस पेमेंट में बहुत देर कर दी है. कृपया जल्दी से जल्दी भुगतान करें.
</div>
</div>
</div>
Try this
add a div after every 2nd elements with page-break-after property
<div style="page-break-after:always"></div>
page-break-after property sets whether a page break should occur AFTER a specified element
DEMO

Columns not lining up HTML table

I have the following table in HTML, but the columns don't line up at all well, you can see it here:
http://purepremier.com/#/teams
Is there any reason why this might be?
<table class="league">
<thead>
<tr>
<th>Pos</th>
<th>Team</th>
<th>P</th>
<th>F</th>
<th>A</th>
<th>GD</th>
<th>Pts</th>
</tr>
</thead>
<tbody>
<td class="ng-binding">1</td>
<td class="teams">
<a href="#/teams/65" ng-click="hidePrefs()" class="ng-binding">
Manchester City
</a>
</td>
<td class="ng-binding">4</td>
<td class="ng-binding">10</td>
<td class="ng-binding">0</td>
<td class="ng-binding">10</td>
<td class="ng-binding">12</td>
</tr>
<tr ng-repeat="team in teamsList.standing" class="ng-scope">
<td class="ng-binding">2</td>
<td class="teams">
<a href="#/teams/354" ng-click="hidePrefs()" class="ng-binding">
Crystal Palace
</a>
</td>
<td class="ng-binding">4</td>
<td class="ng-binding">8</td>
<td class="ng-binding">5</td>
<td class="ng-binding">3</td>
<td class="ng-binding">9</td>
</tr>
............
</tbody>
</table>
The below should fix the issue
In app.css line 921 change the display:inline-block; to display:table-cell;
display:table-cell; is the default behaviour of the <td> element

Xpath targeting starting from CSS

I'd like to target in XPath (to be used in xmlImport for Google Spreadsheets) the element that in CSS would be .forum-table tr:nth-of-type(1) .forum-number-topics:
<table class="forum-table forum-table-forums">
<thead class="forum-header">
<tr>
<th class="forum-icon"> </th>
<th class="forum-name">Forum</th>
<th class="forum-topics">Topics</th>
<th class="forum-posts">Posts</th>
<th class="forum-last-post">Last post</th>
</tr>
</thead>
<tbody id="forum-table-12892-content">
<tr class="forum-row even container-12897-child" id="forum-12897">
<td class="forum-list-icon forum-list-icon-default"> <span class="forum-list-icon-wrapper"><span>No new</span></span>
</td>
<td colspan="1" class="forum-details">
<div class="forum-name"> Settimana 1
</div>
</td>
<td class="forum-number-topics">
<div class="forum-number-topics">20</div>
</td>
<td class="forum-number-posts">171</td>
<td class="forum-last-reply">n/a</td>
</tr>
<tr class="forum-row odd container-13043-child" id="forum-13043">
<td class="forum-list-icon forum-list-icon-default"> <span class="forum-list-icon-wrapper"><span>No new</span></span>
</td>
<td colspan="1" class="forum-details">
<div class="forum-name"> Settimana 2
</div>
</td>
<td class="forum-number-topics">
<div class="forum-number-topics">21</div>
</td>
<td class="forum-number-posts">143</td>
<td class="forum-last-reply">n/a</td>
</tr>
<tr class="forum-row even container-13107-child" id="forum-13107">
<td class="forum-list-icon forum-list-icon-default"> <span class="forum-list-icon-wrapper"><span>No new</span></span>
</td>
<td colspan="1" class="forum-details">
<div class="forum-name"> Settimana 3
</div>
</td>
<td class="forum-number-topics">
<div class="forum-number-topics">20</div>
</td>
<td class="forum-number-posts">91</td>
<td class="forum-last-reply">n/a</td>
</tr>
</tbody>
</table>
I specified tr:nth-of-type(1) because I need the same syntax in Xpath (with numeric entity).
As a literal translation, I would try
//*[contains(#class, 'forum-table')]//tr[1]//*[contains(#class, 'forum-number-topics')]
Note that this will select both <td> and <div> elements, e.g. where you have
<td class="forum-number-topics">
<div class="forum-number-topics">
in the input. Also note that this assumes you don't have "ornery" classes that contain forum-table but not as a whole class name, e.g. if your first table element had class="forum-table-forums" without forum-table in there. If you need to be more rigorous about matching class names, you can do
//*[contains(concat(' ', #class, ' '), ' forum-table ')]//tr[1]//
*[contains(concat(' ', #class, ' '), ' forum-number-topics ')]
(line broken for clarity).