Reputation: 79
The position of the 2nd column in a row in HTML table is not at the right side.
I have a table, in which the first row has a single column with colspan="2"
and width of the row is set at 100%, and other two rows have two column and width of the row is set at 90% (White space between two column should be 10%).
Demonstration:
EXPECTED
:
REALITY
:
I tried to match my expectations:
<td style="positon: relative; right: 0; left: 5%;">
LIVE DEMO (Just because snippet
is not giving an actual result)
Full Code:
.hidden_timer {
visibility: hidden;
}
.visible {
visibility: visible !important
}
.question1 {
display: flex;
align-items: center;
width: 90%;
height: auto;
min-height: 40px;
position: relative;
background: blue;
color: white;
}
.question1::after {
content: "";
position: absolute;
left: -20px;
bottom: 0;
width: 0;
height: 0;
border-right: 20px solid blue;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.question1::before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid blue;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.table_cstm {
border-collapse: separate;
border-spacing: 15;
/* Apply cell spacing */
}
<link rel="stylesheet" href="http://docstore.co.in/kbc/style/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
<table id="test" class="table table-responsive table_cstm">
<tbody>
<tr>
<td colspan="2">
<div class="question1" style="justify-content: center; width: 100%;">Who was First President of India?(15204)</div>
</td>
</tr>
<tr>
<td>
<div id="A1" class="question1" onclick="onSelect(event)">A) M K Gandhi
</div>
</td>
<td style="positon: relative; right: 0; left: 5%;">
<div id="B1" class="question1" onclick="onSelect(event)">B) Jawaharlal Nehru
</div>
</td>
</tr>
<tr>
<td>
<div id="C1" class="question1" onclick="onSelect(event)">C) Rajendra Prasad
</div>
</td>
<td style="positon: relative; right: 0; left: 5%;">
<div id="D1" class="question1" onclick="onSelect(event)">D) Chandra Shekhar Azad
</div>
</td>
</tr>
</tbody>
</table>
Upvotes: 1
Views: 933
Reputation: 1921
Div's in the right cells are aligned to left side.
This will make them to float to the right side:
td:last-child div {
float:right;
}
Upvotes: 2