Hello Ive ran into this problem where I cant seem to get the table data border to line up with the border of the border here is the code:
<table id="proxy-list">
<tr>
<th>Proxies</th>
</tr>
<tr>
<td>Proxy1</td>
<td>12.34.54.78.90</td>
</tr>
</table>
and heres the css:
#proxy-list {
position: absolute;
top: 15%;
left: 60%;
border: 5px solid #e83737;
border-collapse: collapse;
}
th {
width: 300px;
height: 50px;
border: 5px solid #e83737;
text-align: center;
}
th, td {
color: #4F8AFF;
}
td {
width: 20px;
height: 180px;
padding-bottom: 100px;
}
Ive been trying to fix this forever Please help!!!!!
Add colspan attribute to th tag. The colspan attribute defines the number of columns a cell should span.
<th colspan="2">Proxies</th>
#proxy-list {
position: absolute;
top: 15%;
left: 60%;
border: 5px solid #e83737;
border-collapse: collapse;
}
th {
width: 300px;
height: 50px;
border: 5px solid #e83737;
text-align: center;
}
th,
td {
color: #4f8aff;
}
td {
width: 20px;
height: 180px;
padding-bottom: 100px;
}
<table id="proxy-list">
<tr>
<th colspan="2">Proxies</th>
</tr>
<tr>
<td>Proxy1</td>
<td>12.34.54.78.90</td>
</tr>
</table>
Set colspan=2 in th header
<table id="proxy-list">
<tr>
<th **colspan=2**>Proxies</th>
</tr>
<tr>
<td>Proxy1</td>
<td>12.34.54.78.90</td>
</tr>
</table>
Related
Here, I'm having issues with the table in display inline-block property. In my scenario, I need to add 2 spans and text inside the td element. When I use it the text wrapped into the next line. Here I need the text overlap into the span, i.e., the spans should not be disturbing the td's text content. I don't want to use position property. Here is my simple demo.
table {
border-collapse: collapse;
width: 200px;
}
table tr td {
border: 1px solid;
}
span.leftspan {
display: inline-block;
width: 50%;
height: 20px;
background-color: skyblue;
}
span.rightspan {
display: inline-block;
width: 40%;
height: 20px;
background-color: red;
}
<table>
<tr>
<td><span class="leftspan"></span><span class="rightspan"></span>12</td>
<td><span class="leftspan"></span><span class="rightspan"></span>25</td>
</tr>
</table>
In the demo 2 numbers (12, 25) shouldn't wrap into the next line. I need to achieve this without position property.
Using display:flex on the td element and flex-grow: 1 in the element containing the number will make this element to fill the rest of the space on the parent td element. then you can make them overlap using a translateX transform. Check this answer for extra info about how flex and flex-grow.
table {
border-collapse: collapse;
width: 200px;
}
table tr td {
border: 1px solid;
display: flex;
}
span.leftspan {
display: inline-block;
width: 50%;
height: 20px;
background-color: skyblue;
}
span.rightspan {
display: inline-block;
width: 40%;
height: 20px;
background-color: red;
}
span.rest {
flex-grow: 1;
transform: translateX(-100%)
}
<table>
<tr>
<td><span class="leftspan"></span><span class="rightspan"></span><span class="rest">12</span></td>
<td><span class="leftspan"></span><span class="rightspan"></span><span class="rest">25</span></td>
</tr>
</table>
Added Div, and added style for Div
table {
border-collapse: collapse;
width: 200px;
}
table tr td {
border: 1px solid;
}
table tr td div {
display: flex;
}
span.leftspan {
display: inline-block;
width: 50%;
height: 20px;
background-color: skyblue;
}
span.rightspan {
display: inline-block;
width: 40%;
height: 20px;
background-color: red;
}
<table>
<tr>
<td>
<div>
<span class="leftspan"></span><span class="rightspan"></span>12
</div>
</td>
<td>
<div>
<span class="leftspan"></span><span class="rightspan"></span>25
</div>
</td>
</tr>
</table>
I currently have this Bootstrap table and the problem I'm facing is that the sticky headers aren't working without removing the Bootstrap .table-responsive class. Is this possible without using JS?
.table-responsive {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.table-fixed {
width: 100%;
}
/* This will work on every browser but Chrome Browser */
.table-fixed thead {
position: sticky;
position: -webkit-sticky;
top: 0;
z-index: 999;
background-color: #FFF;
}
/*This will work on every browser*/
.table-fixed thead th {
position: sticky;
position: -webkit-sticky;
top: 0;
background-color: #FFF;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="table-responsive">
<table class="table table-striped table-fixed">
<thead>
<tr>
<th>Test</th>
<th>Test</th>
</tr>
</thead>
</table>
</div>
position sticky doesn't work with some table elements (thead/tr) in Chrome. You have added sticky position in thead and th both. try below steps.
remove stick position from thead and keep only in th
Add overflow-x: visible for table-responsive class.
Thanks
See the below code to make table header sticky
<section class="">
<div class="container">
<table>
<thead>
<tr class="header">
<th>
Table attribute name
<div>Table attribute name</div>
</th>
<th>
Value
<div>Value</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>align</td>
<td>left, center, right</td>
</tr>
<tr>
<td>cellpadding</td>
<td>pixels</td>
</tr>
<tr>
<td>cellspacing</td>
<td>pixels</td>
</tr>
<tr>
<td>frame</td>
<td>void, above, below, hsides, lhs, rhs, vsides, box, border
</td>
</tr>
<tr>
<td>rules</td>
<td>none, groups, rows, cols, all</td>
</tr>
<tr>
<td>summary</td>
<td>text</td>
</tr>
<tr>
<td>width</td>
<td>pixels, %</td>
</tr>
</tbody>
</table>
</div>
</section>
<style>
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
section {
position: relative;
border: 1px solid #000;
padding-top: 37px;
background: #500;
}
section.positioned {
position: absolute;
top: 100px;
left: 100px;
width: 800px;
box-shadow: 0 0 15px #333;
}
.container {
overflow-y: auto;
height: 160px;
}
table {
border-spacing: 0;
width: 100%;
}
td+td {
border-left: 1px solid #eee;
}
td,
th {
border-bottom: 1px solid #eee;
background: #ddd;
color: #000;
padding: 10px 25px;
}
th {
height: 0;
line-height: 0;
padding-top: 0;
padding-bottom: 0;
color: transparent;
border: none;
white-space: nowrap;
}
th div {
position: absolute;
background: transparent;
color: #fff;
padding: 9px 25px;
top: 0;
margin-left: -25px;
line-height: normal;
border-left: 1px solid #800;
}
th:first-child div {
border: none;
}
</style>
I'm using CSS resize:both; property to let users resize my content. See the code below.
.foo {
resize: both;
min-width: 250px;
width: auto;
text-align: center;
min-height: 30px;
border: 1px solid #515151;
border-radius: 6px;
position: absolute;
padding: 0;
overflow: hidden;
text-shadow: 1px 1px 1px rgba(0,0,0,0.33);
box-shadow: 5px 5px rgba(0,0,0, 0.1);
}
.thClass {
margin-left: -3px;
text-align: center;
box-shadow: 0 2px 2px rgba(0,0,0,0.26);
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.26);
-moz-box-shadow: 0 2px 2px rgba(0,0,0,0.26);
margin-top: -2px;
min-height: 30px;
line-height: 30px;
font-size: 19px;
cursor: move;
}
.header{
margin-left: 17px;
}
.tableBody {
display: block;
min-height: 25px;
text-align: center;
width: 102%;
margin-left: -2px;
cursor: default;
}
.foo tbody tr td {
display: block;
line-height: 25px;
text-align: center;
border-bottom: 1px solid rgba(0,0,0,0.2);
}
#displaySizes {
list-style: none;
padding: 0;
margin-top: 0;
}
.disp tbody tr th {
border: 1px solid black;
}
.disp tbody tr td {
display: table-cell;
}
<table class="foo disp elementTable">
<tr class="tableHeader">
<th class="thClass" colspan="5">
<span class="header">Device</span>
</th>
</tr>
<tr>
<td rowspan="4" id="sizeContainer">
<ul id="displaySizes">
<li>4:3</li>
<li>16:9</li>
<li>Clock</li>
</ul>
</td>
<td>$100</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
</table>
Is there a way to resize this table step by step using CSS, for example, by [10,10] pixels? JavaScript is also OK. I've searched the web, but could not find anything. Here is the working fiddle for you to play with code.
Here's a solution I put together that will snap to given grid on resize (in this example 20px.)
It uses "cross browser resize event listener", that a another developer has put together (source):
Basically it just listens to the resize event, then sets the styles for width and height using javascript.
Fiddle here:
https://jsfiddle.net/treetop1500/co8zbatz/
// utility function for rounding (20px in this case)
function round20(x)
{
return Math.ceil(x/20)*20;
}
// Attach listener
var myElement = document.getElementById('resize'),
myResizeFn = function(){
h = round20(parseInt(this.style.height,10));
w = round20(parseInt(this.style.width,10));
this.style.height = h + "px";
this.style.width = w + "px";
};
addResizeListener(myElement, myResizeFn);
That's a good point , So It's possible using the css-element-queries Library ,
All you have is creating a ResizeSensor() for your table and then make calculation to set both height and width range change :
See below Snippet :
var width = $('.elementTable').width();
var height = $('.elementTable').height();
var changePX = 50;
new ResizeSensor(jQuery('.elementTable'), function(){
//width calcuation
if(Math.abs($('.elementTable').width()-width) > changePX) {
$('.elementTable').width() > width ? width +=changePX : width -=changePX;
}
$('.elementTable').width(width);
//height calcuation
if(Math.abs($('.elementTable').height()-height) > changePX) {
$('.elementTable').height() > height ? height +=changePX : height -=changePX;
}
$('.elementTable').height(height);
})
.foo {
resize: both;
min-width: 250px;
width: auto;
text-align: center;
min-height: 30px;
border: 1px solid #515151;
border-radius: 6px;
position: absolute;
padding: 0;
overflow: hidden;
text-shadow: 1px 1px 1px rgba(0,0,0,0.33);
box-shadow: 5px 5px rgba(0,0,0, 0.1);
}
.thClass {
margin-left: -3px;
text-align: center;
box-shadow: 0 2px 2px rgba(0,0,0,0.26);
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.26);
-moz-box-shadow: 0 2px 2px rgba(0,0,0,0.26);
margin-top: -2px;
min-height: 30px;
line-height: 30px;
font-size: 19px;
cursor: move;
}
.header{
margin-left: 17px;
}
.tableBody {
display: block;
min-height: 25px;
text-align: center;
width: 102%;
margin-left: -2px;
cursor: default;
}
.foo tbody tr td {
display: block;
line-height: 25px;
text-align: center;
border-bottom: 1px solid rgba(0,0,0,0.2);
}
#displaySizes {
list-style: none;
padding: 0;
margin-top: 0;
}
.disp tbody tr th {
border: 1px solid black;
}
.disp tbody tr td {
display: table-cell;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/css-element-queries/0.4.0/ResizeSensor.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/css-element-queries/0.4.0/ElementQueries.min.js"></script>
<table class="foo disp elementTable">
<tr class="tableHeader">
<th class="thClass" colspan="5">
<span class="header">Device</span>
</th>
</tr>
<tr>
<td rowspan="4" id="sizeContainer">
<ul id="displaySizes">
<li>4:3</li>
<li>16:9</li>
<li>Clock</li>
</ul>
</td>
<td>$100</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
</table>
How can I keep cell phone words in the same line?
.label {
width: 300px;
padding: 5px 15px;
}
.input {
border: 1px solid red;
width: 100%;
}
.input > input {
width: calc(100% - 4px);
}
<form class="frm-find-people">
<table>
<tbody>
<tr>
<td class="label">Cell Phone</td>
<td class="input"><input type="text" name="name"></td>
</tr>
</tbody>
</table>
</form>
As you see, I've set width: 300px for that column. But seems it doesn't apply. Why?
Add white-space: nowrap; to .label:
.label {
padding: 5px 15px;
white-space: nowrap;
}
.input {
border: 1px solid red;
width: 100%;
}
.input > input {
width: calc(100% - 4px);
}
<form class="frm-find-people">
<table>
<tbody>
<tr>
<td class="label">Cell Phone</td>
<td class="input"><input type="text" name="name"></td>
</tr>
</tbody>
</table>
</form>
the 300px width is not being applied because you have a width:100% on the next column, which tells it to occupy as much space as it can.
To fix that, you have to remove the width:100% on the next td. Transfer that to the text field instead. Finally, set the entire table to have width:100% so it covers the entire parent. Below is the corrected CSS.
table {
width: 100%; /* This should be 100% */
}
.label {
width: 300px;
padding: 5px 15px;
}
.input {
border: 1px solid red;
/* remove width 100% from here */
}
.input > input {
width: 100%; /* this should be 100% */
}
Use following css:
table { width:100%; } .label { width: 30%; padding: 5px 15px; } .input { border: 1px solid red; width:70%; } .input > input { width: calc(100% - 4px); }
The problem with your code, is that you should have:
table.mytable {
width: 100%;
}
Because the <td> is a child element of the <table class="mytable">. So the parent element has to have a set size to be able to modify child elements such as <td>. The added mytable class is so that it only affects that table incase you have others.
You've set .input to width: 100%, which is shrinking .label down to the smallest size possible (the length of the words inside)
You could use css calc to make .input 100vw - 300px wide
.input {
width: calc(100vw - 300px);
}
And
.input > input {
width: calc(100vw - 300px);
}
.label {
padding: 5px 15px;
border: 1px solid red;
width: 300px;
}
.input {
border: 1px solid red;
width: calc(100vw - 300px);
}
.input > input {
width: calc(100vw - 300px);
}
tr {
border: 1px solid blue;
}
<form class="frm-find-people">
<table>
<tbody>
<tr>
<td class="label">Cell Phone</td>
<td class="input"><input type="text" name="name"></td>
</tr>
</tbody>
</table>
</form>
I have this JS fiddle https://jsfiddle.net/658epj15/
.navChild:hover{
background-color:#626262;
}
When I hover over a link, the word has a background around it that illuminates, that is the length of the word.
How can I extend this so that it illuminates over the whole <td> and not just the div, so it illuminates from the left border of the <td> to the right border of the <td>?
Use tr td instead of .navChild
tr td:hover {
background-color: #626262;
}
https://jsfiddle.net/658epj15/2/
Update, regarding to your comment:
Pay attention to the following lines
tr td:hover, .current {
background-color: #626262;
}
and
<td class="current"><a class="navChild" href=b illboard.html>Nav 1</a></td>
.navParent table {
color: #ffffff;
table-layout: fixed;
text-align: center;
position: absolute;
font-size: 20px;
border: none;
border-collapse: collapse;
width: 100%;
}
.navParent table td {
border-left: 1px solid #000000;
}
.navParent table td:first-child {
border-left: none;
}
.navParent a {
text-decoration: none;
color: black;
}
.navChild {
width: 100%;
height: auto;
}
tr td:hover,
.current {
background-color: #626262;
}
<div class="navParent">
<nav>
<table>
<tr>
<td class="current"><a class="navChild" href=b illboard.html>Nav 1</a></td>
<td><a class="navChild" href=a bout.html>Nav 2</a></td>
<td><a class="navChild" href=l ocations.html>Nav 3</a></td>
<td><a class="navChild" href=p ricing.html>Nav 4</a></td>
</tr>
</table>
</nav>
</div>
Instead of adding hover on a add hover on td
.navParent table{
color:#ffffff;
table-layout: fixed;
text-align:center;
position:absolute;
font-size: 20px;
border: none;
border-collapse:collapse;
width:100%;
}
.navParent table td{
border-left: 1px solid #000000;
}
.navParent table td:first-child{
border-left:none;
}
.navParent a{
text-decoration: none;
color:black;
}
.navChild
{
width: 100%;
height: auto;
}
.navParent td:hover{
background-color:#626262;
}
<div class = "navParent">
<nav>
<table>
<tr>
<td><a class = "navChild" href = billboard.html>Nav 1</a></td>
<td><a class = "navChild" href = about.html>Nav 2</a></td>
<td><a class = "navChild" href = locations.html>Nav 3</a></td>
<td><a class = "navChild" href = pricing.html>Nav 4</a></td>
</tr>
</table>
</nav>
</div>
You want to display the a as a block element so it takes up the space of the cell that it is in. Also, you want to set the cellpadding on the table to 0 to eliminate the spacing around the text (you said you wanted it go border to border). This updated fiddle also fixes some incorrect HTML in the original (the closing table tag was wrong). https://jsfiddle.net/658epj15/3/
.navParent table {
color: #ffffff;
table-layout: fixed;
text-align: center;
position: absolute;
font-size: 20px;
border: none;
border-collapse: collapse;
width: 100%;
}
.navParent table td {
border-left: 1px solid #000000;
}
.navParent table td:first-child {
border-left: none;
}
.navParent a {
text-decoration: none;
color: black;
}
.navChild {
width: 100%;
height: auto;
display: block;
}
.navChild:hover {
background-color: #626262;
}
<div class="navParent">
<nav>
<table cellpadding="0">
<tr>
<td><a class="navChild" href=billboard.html>Nav 1</a></td>
<td><a class="navChild" href=about.html>Nav 2</a></td>
<td><a class="navChild" href=locations.html>Nav 3</a></td>
<td><a class="navChild" href=pricing.html>Nav 4</a></td>
</tr>
</table>
</nav>
</div>
By default, your <a> tags are set to display: inline, and won't fill out the <td>. Set them to display: block, and the hover should work as expected.
Updated fiddle.