why can't I move some of my tables with positioning? - html

I have managed to get certain bits of my responsive website to work but am still having some issues in terms of moving certain tables. For some reason, I can move the table in certain directions but not for others such as top. For the following table, I would like to move it lower if possible but even when placing the word !important after top, it doesn't work. For the first picture, I can't seem to move it further to the right and for the second, I can't seem to move it further down....
Image 1
Image 2
This is the table code for the first problem
.header2_user_information {
background-color: #FAEBD7;
table-layout: fixed;
width: 110%;
position: relative;
right: 20em;
}
<table class="header2_user_information">
<tr>
<th colspan="2">User\'s General Information</th>
</tr>
<tr>
<th>First Name:</th><td>Mervin</td>
</tr>
<tr>
<th>Last Name</th><td>Lee</td>
</tr>
<tr>
<th>Email Address:</th><td>piano0011#gmail.com</td>
</tr>
<tr>
<th>User ID:</th><td>piano0011</td>
</tr>
<tr>
<th>Administrator Status:</th><td>None</td>
</tr>
<tr>
<th>Moderator Status:</th><td>None</td>
</tr>
<tr>
<th>Premium Membership Status:</th><td>Member</td>
</tr>
</table>
The second is very similar to the first...

There is an explanation on when CSS offset properties can be used. According to FreeCodeCamp:
When the position of an element is set to relative, it allows you to specify how CSS should move it relative to its current position in the normal flow of the page. It pairs with the CSS offset properties of left or right, and top or bottom. These say how many pixels, percentages, or ems to move the item away from where it is normally positioned.
You have position: relative in your code snippet but according to your question you probably forgot it in your actual code. Or you have overridden it somewhere else. (Use your browser's "inspect element" to check it.)
.header2_user_information {
background-color: #FAEBD7;
position: relative; /* Note this line. It is necessary to use CSS offsets */
top: 30px;
left: 2em; /* px, em, percentage or any other value is acceptable */
}
<table class="header2_user_information">
<tr>
<th colspan="2">User\'s General Information</th>
</tr>
<tr>
<th>First Name:</th><td>Mervin</td>
</tr>
<tr>
<th>Last Name</th><td>Lee</td>
</tr>
<tr>
<th>Email Address:</th><td>piano0011#gmail.com</td>
</tr>
<tr>
<th>User ID:</th><td>piano0011</td>
</tr>
<tr>
<th>Administrator Status:</th><td>None</td>
</tr>
<tr>
<th>Moderator Status:</th><td>None</td>
</tr>
<tr>
<th>Premium Membership Status:</th><td>Member</td>
</tr>
</table>

Related

TD not displayed correctly

<tr>
<td></td>
<td colspan="3">Susi Handayani Jl. Kebangsaan No.225 300.000</td>
</tr>
How to merge the two td to be inside one Td, but it's not sticking together, merged but I want the word to not stick together beside, make some space from the deleted td to be the same column as above
I tried align but it didn't Work, I've also tried dividing the tr and tried removing td for one paragraph and it still sticks with the second paragraph (td), what I'd expect is the td not to stick together but to align the text above the text that I've made
<h3>Tabel HTML</h3>
<table>
<caption>Tabel Simpanan Peserta</caption>
<thead>
<tr>
<th>No</th>
<th>Nama Peserta</th>
<th>Alamat</th>
<th>Simpanan</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3">Total</td>
<td>350.000</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>1.</td>
<td>Andi Suryono</td>
<td>Jl. Kemerdekaan No.17</td>
<td>50.000</td>
</tr>
<tr>
<td>2.</td>
<td colspan="3">Susi Handayani
Jl. Kebangsaan No.225
300.000</td>
</tr>
<tr>
<td>3.</td>
<td>Roy Pratama</td>
<td>Jl. Merdeka No.32</td>
<td>1.000.000</td>
</tr>
</tr>
<tr>
<td>4.</td>
<td>Tia Suryani</td>
<td>Jl. Jelajah No.111</td>
<td>1.555.000</td>
</tr>
</tbody>
</table>
I'm trying to make the table fused but not sticking together, I'm planning to give the word some space and how do I make the space for each column
You're talking about styling, yet you posted no style tag or CSS whatsoever. Post the general CSS you have, to reproduce the problem, or at least a screenshot of what the problem is.
Generally, spacing in tables comes with padding. Try something like:
<style>
td {
padding: 5px 10px;
}
</style>
This will put 5px top and bottom and 10px from both sides of every cell in the table.

Aligning an image next to a table row

I want to display image next to each row in a table using Html and CSS.
Something like this image:
Images will be placed at the red cross position: on right side of each row and not created within extra column.
What would be the best way to do that.
You could try using the :last-child combined with the :after pseudo.
tr td:last-child::after {
content: '';
display: inline-block;
position: absolute;
height: 1em;
width: 1em;
background: url("http://www.gentleface.com/i/free_toolbar_icons_16x16_black.png") no-repeat center;
}
<table>
<thead>
<th>1</th>
<th>2</th>
</thead>
<tb>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
</tb>
</table>
Another column with a blank table header should do it.
<table style="width:100%">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th> </th> -- This is the blank space
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>Image goes here</td>
</tr>
</table>
You can always style it up to appear like it is not apart of the table.

Why does margin-bottom not work with <tr>?

tr {
margin-bottom: 100px;
}
<table>
<thead>
<tr>
<th>School Name</th>
<th>State</th>
<th>League</th>
<th>Division</th>
</tr>
</thead>
<tbody>
<tr>
<td>School1</td>
<td>State1</td>
<td>League1</td>
<td>Division1</td>
</tr>
</tbody>
</table>
I need a table like this with some basic information where I'll add a button that on click expands that row with some more details.
I couldn't find the right answer for that so I thought about changing css with some transition to the table on click where some specific row gets margin bottom from 0 to 100px maybe and then find the position of that tr and let say:
trPosition= 100px;
trHeight= 30px;
The bottom of the tr is at: 70px
And some new element appends with jquery at that position with a height of tr margin bottom.
But before all that I can't even use margin bottom between rows, why is that?
And is there some other solution for this?
Table elements do not have margin - you can use padding-bottom here. Another thing is you need to apply it to the td or th element.
See demo below:
tr > td {
padding-bottom: 100px;
}
<table>
<thead>
<tr>
<th>School Name</th>
<th>State</th>
<th>League</th>
<th>Division</th>
</tr>
</thead>
<tbody>
<tr>
<td>School1</td>
<td>State1</td>
<td>League1</td>
<td>Division1</td>
</tr>
<tr>
<td>School1</td>
<td>State1</td>
<td>League1</td>
<td>Division1</td>
</tr>
</tbody>
</table>
If you change display for block, you will see margin, but I'm not sure, if that's what you need. You should use different methods.
margin-bottom: 100px; display: block;

using :before (or :after) or table tr's

I am trying to get the effect of buttons sitting outside of the table that are in line with the table rows they effect. To do this, I am trying to use the pseudo elements. I can achieve this easily if I use the :after on the table row, however if i use before, it treats the pseudo element as a new td in the table row and pushes everything over one td, making the table un-aligned.
<table class="saInstrcutionTable">
<thead>
<tr>
<th></th>
<th>Level</th>
<th>Title 1</th>
<th>Title 2</th>
<th>Title 3</th>
</tr>
</thead>
<tbody>
<tr class="saLevel">
<td><input type="checkbox" name="level1"></td>
<td>Level 1 Name</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="moveTableLevel">
<td><input type="checkbox"></td>
<td>1.01</td>
<td>A.Truck, B.Car, C. House</td>
<td>Say look at that, turn head and point</td>
<td>CLorem ipsum</td>
</tr>
<tr class="moveTableLevel">
<td><input type="checkbox"></td>
<td>1.02</td>
<td>A.Truck, B.Car, C. House</td>
<td>Say look at that, turn head and point</td>
<td>CLorem ipsum</td>
</tr>
<tr class="moveTableLevel">
<td><input type="checkbox"></td>
<td>1.03</td>
<td>A.Truck, B.Car, C. House</td>
<td>Say look at that, turn head and point</td>
<td>CLorem ipsum</td>
</tr>
<tr class="moveTableLevel">
<td><input type="checkbox"></td>
<td>1.04</td>
<td>A.Truck, B.Car, C. House</td>
<td>Say look at that, turn head and point</td>
<td>CLorem ipsum</td>
</tr>
</tbody>
</table>
I'm using the moveTableLevel class to add the item to add the buttons attached to the table row
.moveTableLevel:before
position: relative
content: 'up'
If i use :after the desired effect works fine, however I do not want the buttons on the right side of the table. Is there a way to achieve this (possibly using the pseudo elements)? :before seems to want to add a whole new td. Thanks!
edit: fiddle here for live example http://jsfiddle.net/9mLd6v9L/
I had a similar problem (almost exactly the same, actually). What I ended up doing was using the :after psuedo element, but moving it to where I wanted it with position: absolute and setting a left: 0 style.
So I updated your fiddle with this, and added a padding to the left side of the whole table (so you can see the content)
.moveTableLevel:after {
position: absolute;
content: 'up';
left: 5px;
}
It kind of goes against my beliefs of using absolute positioning (which I think should be as little as possible), but it was the only way I could fix it. Hopefully this will work for you too.
I just had the same problem. I found that I can simply re-adjust things by pushing the header as well:
table thead tr::before {
content: "";
}

CSS margin calculated correctly but displayed wrong. Resizing window corrects it

I have two tables floated side by side in a parent div. The leftmost table has a margin-right of 10%. As you can see in the image, the margin is calculated correctly (in this case, the parent is 850px, and the metrics inspector shows an 85px margin) but when drawn, is incorrect (much smaller.)
Resizing the window to make it redraw immediately fixes it. What is going on here!?
HTML:
<table id="subscriptions" class="data">
<tr>
<th colspan="2">Subscriptions
<span id="remaining">Remaining</span></th>
<th></th>
</tr>
<tr>
<td>Spin Classes</td>
<td class="right">3</td>
<td class="right">Redeem</td>
</tr>
<tr>
<td>Spin Classes</td>
<td class="right">3</td>
<td class="right">Redeem</td>
</tr>
</table>
<table id="redeemed" class="data">
<tr>
<th>Redeemed Items</th>
<th class="right">Redeemed</th>
</tr>
<tr>
<td>Spin Class</td>
<td class="right">3/3/13</td>
</tr>
<tr>
<td>Spin Class</td>
<td class="right">3/3/13</td>
</tr>
</table>
CSS:
#subscriptions, #redeemed {
width: 45%;
float: left;
clear: both;
margin: 25px 10% 0 0;
}
#redeemed {
clear: none;
margin-right: 0;
}
I think if you get rid of both the clear lines in the css it might fix it?