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: "";
}
Related
<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.
I want make two buttons sit next to each other within the same cell. How can I go about that without having alot space in the cell. Only Enough space to have the buttons sit in comfortable space between each other.
I have used display: inline-block; as well as display:block and style='white-space: nowrap'. Have looked at similar questions and their answers don't work with my project.
<table>
<tr>
<th>Employee Name</th>
<th>Email Address</th>
<th>Action</th>
</tr>
<tr>
<td>Johnny Depp</td>
<td>hotdog69#gmail.com</td>
<td>
<button type="button">Add</button>
<button type="button">Edit</button>
</td>
</tr>
</table>
When one or two buttons are present within a cell, they create this super long horizontal cell. The buttons are also far apart from each other.
You can use "table-layout:fixed" property to make your table use fixed width and assign width to "th" as per your choice. It will help you to adjust space of your table layout easily.
For email id, use "word-break: break-all" property to break text instead of using "white-space: nowrap" property.
<table style="table-layout:fixed;text-align:left">
<tr>
<th width="115px">Employee Name</th>
<th width="105px">Email Address</th>
<th width="90px">Action</th>
</tr>
<tr>
<td>Johnny Depp</td>
<td style="word-break:break-all;">hotdog69#gmail.com</td>
<td>
<button type="button">Add</button>
<button type="button">Edit</button>
</td>
</tr>
</table>
Maybe you need to use the command "colspan". For example...
<tr>
<th>Name</th>
<th colspan="2">Address</th>
</tr>
Turns out a button's style was controlling all the buttons in my project. I should have given that button an id so it wouldn't control all the buttons in a general sense.
Try to add below styling on the button or the td tag,
display:contents
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>
I have some tables like this:
<tr>
<th scope="rowgroup" rowspan="2">Rowgroup</th>
<th scope="row">Row 1</th>
<td>A</td>
</tr>
<tr>
<th scope="row">Row 2</th>
<td>B</td>
</tr>
I want a general CSS rule to catch all the scope="row" elements when part of a rowgroup but not when they aren't part of a rowgroup like this:
<tr>
<th scope="row">Row 1</th>
<td>A</td>
</tr>
<tr>
<th scope="row">Row 2</th>
<td>B</td>
</tr>
My goal is to have all my TH's one color, except when part of a rowgroup. I tried this but it only catches the first one:
th[scope="rowgroup"] th { color: blue; }
I don't care about browser compatibility and using many rules is fine, I just want to avoid using id or class selectors or javascript if possible.
I'm afraid you cannot do that with simply CSS.
The problem is that CSS does not support going "up", only going "down". In your first example, it would be impossible to reach the th located in the second tr, they are "cousins" with the th scope="rowgroup" element, so you would have to go up first and then go down.
It is easy to solve with Javascript/jQuery, or if you can add a class on the tr that contains the th scope="rowgroup" in your HTML.
Juste use as css code:
th {color:blue;}
th[scope="rowgroup"] { color: red; }
demo: http://jsfiddle.net/H4Hy9/1/
I use Richfaces and have a rich:datatable with nested rich:tooltip-s.
You can imagine the generated HTML looks like this:
<table style="width: 400px; border: 3px solid #000; caption-side: bottom; border-collapse:collapse;">
<caption align="bottom">Table 1.1: A record of the fur shed annually by Jennifer's dog Shasta</caption>
<thead>
<tr>
<th>Month</th>
<th>Fur Shed (mm)</th>
</tr>
<thead>
<tbody style="background-color: #ff3;">
<tr>
<td>April</td>
<td>20</td>
</tr>
<tr>
<td>May</td>
<td>19</td>
</tr>
<tr>
<td>June</td>
<td>10</td>
</tr>
<tr>
<td>July</td>
<td>6</td>
</tr>
<tr>
<td>August</td>
<td>8</td>
</tr>
<tr>
<td>September</td>
<td>14</td>
</tr>
</tbody>
<tbody>
<tr>
<td style="display:none;">
<script type="text/javascript">
new RichFaces.ui.DataTable("form1:table1:0:j_idt227",{"ajaxEventOptions":{}} )
</script>
</td>
</tr>
The problem with this html is in the 2nd (generated from RF) tbody: td has style="display:none;" and in Google Chrome this causes the bottom border being not shown.
My question is: do you know if it is possible to find a workaround to fix this? Moving the display:none; at tr or tbody level would already be a solution.
Thanks!
You can add a footer to the table (<f:facet name="footer">) which will render under the hidden row but if you don't want to you can use this CSS:
table > tbody > tr:last-child {
border-bottom: 3px solid #000;
}
this will find the last row and add a border at the bottom, of course this will affect every table on your page so you should use some identifiers. Also note that the :last-child selector may not be supported by all browsers (it does work in Chrome).
Other alternative is to wrap the table in a div but you'd need to play a little with the CSS to make it look the way you want.