What's causing these image sizes to be wrong? - html

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%;
}

Related

How do I resize a table and its cells as screen size shrinks?

https://clementmihailescu.github.io/Pathfinding-Visualizer/#
I'm using a similar table layout like the one linked for a project I'm currently doing but I can't seem to figure out how to not have the cells wrap onto a new row when the screen size shrinks. How is it done in this Pathfinding Visualizer project? What CSS property should I be applying to my table/tr/td? When I shrink my screen size, my table's cells wrap onto the next row making it so that every other row has a different number of columns. I'd like for the table width and, consequently, the table cells to just shrink in width and have the same columns in every row even for smaller screen sizes.
table {
border-collapse: collapse;
margin-left: 8px;
margin-right: 5px;
position: fixed;
bottom: 20px;
}
.grid-row {
white-space: nowrap;
}
.square {
background: #fff;
border: 1px solid #999;
padding: 0;
height: 25px;
width: 25px;
margin-right: -1px;
margin-top: -1px;
border: 1px solid rgb(175, 216, 248)
}
You haven't actually provided a link to your table or it's code.
But, if you're actually using a table structure, your white-space: nowrap; call should be applied to your td elements and not your tr elements.
Again, without a link to your table it's difficult to answer. But perhaps this will point you in the right direction?

Fixed table header scroll both horizontal and vertical CSS ONLY

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.

What's the best way to have a table with sticky header?

What I'm currently doing is 2 tables, one for headers and one for data, in combination with table-layout:fixed and fixed widths for each column.
I don't like that solution since I have to keep adjusting widths and they don't look as good a the auto adjusted ones you get when the table layout isn't fixed.
I also considered a JS solution where the data table is laid out, then JS picks up each column width and applies it to the header table. The advantage of this is fluid td widths dictated by content. The problem is table contents can change dynamically, and the JS script needs to know that so it can recompute the widths... ew.
Is there a better way of doing that?
better to use some plugins like jQuery Plugin for Fix Header Table
or if you want the pure CSS and want to know how it works. you can try the below fiddle https://jsfiddle.net/dPixie/byB9d/3/light/
its all about showing the content if div which is inside the TH
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;
}

How to position a div at the bottom of a table cell?

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;
}

Responsive table design by cell

I have this table with three cells in the first row. I'm trying to create a design that will bring down the last cell if there is no space. So something like 2 on top, 1 below. And as the window gets even small 1 on each row. I'm having trouble finding anything like this.
I was able to get a responsive design to stack all cells on top of each other depending on size but if I could find a better solution that would be nicer.
HTML:
<table id="dashboard" cellpadding="0" cellspacing="0">
<tr>
<td id="TopLeft"><div class='chartLoadingOverlay'>Loading chart please be patient...</div></td>
<td id="TopRight"><div class='chartLoadingOverlay'>Loading chart please be patient...</div></td>
<td id="BottomLeft"><div class='chartLoadingOverlay'>Loading chart please be patient...</div></td>
</tr>
</table>
CSS:
#dashboard{
border-collapse: separate;
border-spacing: 5px 5px;
border: 5px solid red;
background-color: blue;
}
div.chartLoadingOverlay{
font-style:italic;
color:gray;
border:1px silver solid;
background-color:#F5F5F5;
line-height:250px;
height:250px;
width:500px;
text-align:center;
margin:2px;
}
#media only screen and (max-width: 1000px){
/* Force table to not be like tables anymore */
#dashboard table{
width: 100%;
border-collapse: collapse;
border-spacing: 0;
display: block;
position: relative;
width: 100%;
}
#dashboard tbody {
/*display: block;*/
width: auto; position: relative;
overflow-x: auto;
white-space: nowrap;
}
#dashboard tbody tr {
display: inline-block;
vertical-align: top;
}
#dashboard td {
display: block;
}
}
That's not possible. But even if it were doable, a more elegant solution would be to stack 3 divs side-by-side and responsively put them one below the other. Check this Bootstrap example for something quite similar to what you want.
Tables should not be used for responsive design...
Store this to make it a thumb rule : http://shouldiusetablesforlayout.com/
You can try something like this to make DIV structure and make that responsive:
<div id="container">
<div id="col_left"> something here</div>
<div id="col_mid"> something here </div>
<div id="col_mid"> something here</div>
<div style="clear: both"></div>
</div>
CSS:
#container
{
width: 100 %;
clear: both;
border: 1px solid #CCC;
}
#col_left
{
float: left;
width: 20%;
margin: 0 5px 0 0;
border: 1px solid #CCC;
}
#col_mid
{
float: left;
width: 20%
margin: 0 5px 0 0;
border: 1px solid #CCC;
}
#col_right
{
float: right;
width; 35%;
margin: 5px;
border: 1px solid #CCC;
}
you can refer this http://jsfiddle.net/aasthatuteja/awvck/
You can change display like this http://jsfiddle.net/Yr22s/1/
BUT, it effectively changes your table to be div
sorry i dont think this is possible ..actually its not posiible...you cant break a tabular design...
what does a row mean???its a collection of cells...so one row will always contain a particular number of cells...you cant change number of cells in a row depending on screen width..its fixed...
for example consider this table in image
now if your screen width gets too small to accommodate its total width then it will overflow horizontally and horizontal scroll bar will be introduced...and if one cell gets too tall then row size will take the height of tallest cell and rest of the cell will be aligned vertically middle by default...you cant change this property dynamically depending on screen size
what you can do is ..define there width using %..so it wil grow or shrink according to screen width...
this is one reason(actually there are many) why you should avoid tabular design..use container(<div>) to design your website