Basically, I want to space my tds apart from each other horizontally. In Firefox, it works fine by setting a margin, but the margin doesn't work in chrome. So I tried the following and applied it to the table
border-spacing: 40px;
border-collapse: separate;
Moreover, that solution worked in chrome, but NOT Firefox; even though guides suggested that I need the border-collapse: separate to have it work in firefox.
Without any further detail, here's the code for the table styling (the one that works in Firefox):
#tstyle3 {
margin: 10px 0 0 0px;
width: 750px;
border-collapse: separate;
}
#tstyle3 tr {
height: 270px;
border-bottom: none;
border-collapse: separate;
width: 950px;
display: inline-block;
}
#tstyle3 td {
border-top: none;
display: inline-block;
position: relative;
border-collapse: separate;
margin: 0 30px 0 0;
height: 220px;
width: 220px;
background-color: white;
float: left;
box-shadow: 0px 3px 5px #b5b6b6;
}
And the situation recreated in jsfiddle (which shows how it appears in Firefox)
http://jsfiddle.net/JjZNb/
What about you try something more sexy like
float:left; display:block;
http://jsfiddle.net/JjZNb/1/
Margin does not work for td elements.
That's not quite right. Margin doesn't work for table cells (so elements with display:table-cell. But the CSS above styles the <td> elements with display: inline-block, so they aren't table cells anymore and margin should be applying to them.
You can add spacing by specifying a border size, or padding for your td elements.
td{border:8px solid #fff;}
or for padding
td{padding:0 10px;}
or when border styles are already defined,
td{border-width:2px;}
or for each side
td{border-width:0 2px 0 2px;}
/* top right bottom left*/
here is a jsFiddle that demonstrates the above http://jsfiddle.net/VjkP9/
Related
I have created div table but got an issue with border spacing not perfect for me. I have tired border spacing border collapse separate border collapse but no luck.
Need: All border should be clean 1px. I just upload an example snapshot.
jsfiddle.net/abilashu/w70a4ups/17/
use the border-collapse: collapse instead of separate.
div.blueTable {
border: 1px solid yellow;
background-color: #848EA4 ;
width: 100%;
text-align: left;
border-collapse:collapse;
border-spacing: 0;
}
I cannot work out why some of the images on this page are wrongly sized (2 of them appear smaller than the others).
https://www.violinschool.org/video-testing/
I have re-cropped them all to the same size (355x200, ratio 16:9) so there must be something else causing it.
Am trying to check the html and CSS (it's a wordpress site using Toolset Types) to see what might be wrong, but to no avail.
Try adding this line to your CSS file and see if it helps:
table.wpv-loop.js-wpv-loop td {
width: 25%;
}
As <td> in table are not fixed width they get the width according to the content inside it untill the width is not defined in css.
You can do it with 2 solutions.
First is Add table-layout:fixed in table.
table{
border-bottom: 1px solid #ededed;
border-collapse: collapse;
border-spacing: 0;
font-size: 14px;
line-height: 2;
margin: 0 0 20px;
width: 100%;
table-layout: fixed;
}
Adding table-layout:fixed will restrict the table to show each cell with same width.
and second Use width in <td>
As you are using exact 4 <td> in one row so you can give width manually width:25%.
td {
border-top: 1px solid #ededed;
padding: 6px 10px 6px 0;
width: 25%;
}
Problem is not in images but in table. Now each table-cell is taking dynamic width according to its content. If one table-cell has more content it will be wider than others.
Add table-layout: fixed property on table then all table-cell will take equal width and your problem will be fixed.
table {
border-bottom: 1px solid #ededed;
border-collapse: collapse;
table-layout: fixed;
border-spacing: 0;
font-size: 14px;
line-height: 2;
margin: 0 0 20px;
width: 100%;
}
Firstly, is it possible to achieve this using only CSS?
I have built a table that can scroll both horizontally and vertically however, I want to have the header encapsulated within it's container and not appear outside of the wrapper. So that when you scroll horizontally the corresponding header is in line with the content of it's designated column.
Using different variations of position: absolute and position: static give me some intended results but not the complete solution.
You'll note the width applied to the section element to give the effect of scrolling horizontally within the enclosed region.
Here is a JSFIDDLE example of what I have so far and CSS below to reference
https://jsfiddle.net/ko6qco1r/
html, body{
margin:0;
padding:0;
height:100%;
}
section {
position: relative;
border: 1px solid #000;
padding-top: 37px;
background: grey;
width: 300px;
}
.container {
overflow-y: auto;
overflow-x: scroll;
height: 200px;
}
table {
border-spacing: 0;
width:100%;
}
td + td {
border-left:1px solid #eee;
}
td, th {
border-bottom:1px solid #eee;
background: white;
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 black;
}
th:first-child div{
border: none;
}
This is another one of those interesting challenges (like vertical centering) brought to us by the inaction of the W3C. Also like vertical centering, you can't put a fixed header on a table with a horizontal scrollbar using position: fixed; on the thead element. But you do have a couple of options.
Option 1 - Horizontal Scrolling (http://codepen.io/staypuftman/pen/JXbpvZ)
The key here is to reestablish your table layout as table-layout: fixed; CSS-tricks has a good piece on this approach and then put a min-width value on your container when you want the scrollbars to appear. This makes the table scrollable left to right and maintains the integrity of the column headers on smaller devices. But the header is not fixed.
Option 2 - Fixed Header (https://jsfiddle.net/dPixie/byB9d/3/light/)
Your code looked like a rip-off of this guy's work, so I thought I'd repost here to give him some credit. This approach creates a series of <div> elements that mirror the contents of the <th> elements and uses some VERY creative positioning techniques to get it all to work.
There is a much better run-down on Salzar design that shows some examples and explains in detail all the complicated maneuvers to get this right.
I'm tired of searching and not being able to accomplish this: 1 label at top left of a cell and the content at the bottom center. Trying to achieve this, I'm using 2 divs inside a TD, but I don't mind changing that as long as I can achieve the goal.
I don't know the size of the labels (they can be translated into different languages and therefore taking different sizes).
The original table will be taking half of an A4 Portrait in height. It's 7 (row) * 5 (columns) (with the exception of 1 single cell in the middle of it that I use rowspan="2")
I've tried the "set the parent to position: relative and make the container position: absolute; bottom: 0" solution and I can't make it work.
Basically, I want to have 1 label set to the top left and the content in the bottom middle of the cell.
The 950px width is for printing purposes.
Here is a jsfiddle link to exemplify my problem.
http://jsfiddle.net/o1L31qwu/
Thanks in advance.
change your CSS like this:
.tableClass {
width: 950px;
table-layout: auto;
margin-top: 8px;
border-color: black;
border-width: 0 0 1px 1px;
border-style: solid;
border-spacing: 0;
border-collapse: collapse;
}
.tableClass td{
border-color: black;
border-width: 1px 1px 0 0;
border-style: solid;
margin: 0;
padding: 4px 0;
position:relative;
vertical-align:top;
}
.label{position:relative; margin:4px; margin-bottom:30px /* adjust to bottom size */; }
.content{width:100%; position:absolute; bottom:1px; left:0; background:#fc0; margin:0; text-align:center;}
I have added a background color for visualization purposes, but of course you'll need to edit at will . See fiddle here
Here's a flexbox solution that will handle arbitrarily-sized .label and .content: http://jsfiddle.net/5kzzgkgr/.
The content of the cell should be placed in a wrapper div:
<td>
<div>
<div class="label">This Label is large / and divided [eph] really large label.And some more text, text, text, and more text.....<br /><br /></div>
<div class="content">BOTTOM</div>
</div>
</td>
CSS:
.tableClass td{
height: 0px;
}
.tableClass div:only-of-type {
height: 100%;
background-color: #ccc;
display: flex;
flex-flow: column wrap;
justify-content: space-between;
}
I have a divider containing x tables in the form:
<div class="container">
<table>....</table>
<table>....</table>
<table>....</table>
<table>....</table>
</div>
The CSS code that corresponds to this is:
.container{
width: 100%;
clear: both;
border-bottom: solid 2px #036;
white-space: nowrap;
}
table{
display: inline-table;
border-bottom: solid 1px #000;
}
However, when this is applied, there is a gap of ~12px from the bottom border of the table and the bottom border of the divider. If I set "margin-bottom: -12px;" on the table it corrects the positioning error, but not in all browsers.
Does anyone know why there is a margin being made?
There seems to be a problem with display: inline-table, when you replace this with float: left the problem is gone. I have also set overflow: hidden on the .container div, so it takes the full height of the floating tables inside.
EDIT: In order to prevent the tables from wrapping, you could place the tables inside another left floating div that has white-space: nowrap; set.
CSS
* {
margin: 0;
padding: 0;
}
.container {
overflow: hidden;
border-bottom: solid 2px #036;
}
.nowrap {
float: left;
overflow: hidden;
white-space: nowrap;
}
table {
float: left;
border-bottom: solid 1px #000;
border-spacing: 0px;
padding: 0px;
}
HTML
<div class="container">
<div class="nowrap">
<table><tbody><tr><td>test test test test test</td></tr></tbody></table>
<table><tbody><tr><td>test test test test test</td></tr></tbody></table>
<table><tbody><tr><td>test test test test test</td></tr></tbody></table>
<table><tbody><tr><td>test test test test test</td></tr></tbody></table>
</div>
</div>
Test<br />
See this updated JSFiddle
Do you have to use <table>? I strongly recomended you to use <div> instead.
However in table (possibly you should add td in your css) set border to 0. This should help.