I have the following content:
It is a table, with one row and three cells, two blue cells, and the middle cell, and in the middle cell I have a div, for now it looks good.
But if I put the zoom property in the div (zoom: 0.8) I get an extra space in IE11, as if the div was still the same size, like this:
In chrome, the table just adjusts to the div size, but not in IE, is there anyway I can achieve this?
This is the fiddle of the example:
http://jsfiddle.net/Z3wbN/3/
HTML:
<table class="container">
<tr>
<td class="border">
</td>
<td>
<div class="content">
This is a test
</div>
</td>
<td class="border">
</td>
</tr>
CSS:
.container {
background-color: #ddd;
}
.border {
background-color: blue;
width:10px;
}
.content {
margin: auto;
width: 500px;
border: 2px solid yellow;
zoom: 0.8;
}
One possible solution, although I don't know if you'll like it, could be this one: http://jsfiddle.net/Z3wbN/14/
On that solution:
A couple of classes/ids are added to the tags;
The width is assigned to the middle cell instead of to the div inside that cell;
if it's an IE browser, the div width is adjusted to 125% (100% / 0.8 that is the zoom).
The way of detecting the browser is JavaScript but you could try any that you want (I got it from Detect IE version (prior to v9) in JavaScript):
// if it's an IE browser then update the class to "container ie"
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
document.getElementById("container").className = "container ie";
}
Then the CSS is adjusted as specified in the list above:
td.middle {
width:500px;
}
.content {
margin: auto;
border: 2px solid yellow;
zoom: 0.8;
}
.ie .content {
width:125%;
}
This solution displays a "similar" result on IE and Chrome/Firefox.
You need to use display:table-cell; to class .content
Here is the updated fiddle:
.container {
background-color: #ddd;
}
.border {
background-color: blue;
width: 10px;
}
.content {
margin: auto;
width: 500px;
border: 2px solid yellow;
zoom: 0.8;
display: table-cell;
}
zoom: 0.5;
<table class="container">
<tr>
<td class="border">
</td>
<td align="center">
<div class="content">
This is a test
</div>
</td>
<td class="border">
</td>
</tr>
</table>
All you need to do is to apply zoom to .container too :
.container {
zoom: 0.8
}
Here's the JSFiddle: http://jsfiddle.net/Z3wbN/12/
Related
So I'm building a website, which features several pages describing (fantasy) people and places. To that end, several categories of page have a profilebox which include stuff like a heading, an image and a table with some summary data.
The HTML for such a box looks like this:
<profilebox class="red">
<p><i>His Majesty</i><br><span class="big-and-strong">The King</span>
</p>
<figure class="pbox"><img class="pbox" src="../images/armsroyal.svg">
</figure>
<table class="pbox">
<tr>
<td>Surname</td>
<td>N/A</td>
</tr>
<tr>
<td>Forename</td>
<td>N/A</td>
</tr>
<tr>
<td>Rank</td>
<td>King</td>
</tr>
<tr>
<td>Addressed As</td>
<td>‘‘Your Majesty’’</td>
</tr>
</table>
</profilebox>
Whereas the CSS looks like this:
profilebox {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 1em;
margin-right: 0em;
width: 400px;
float: right;
text-align: center;
padding: 1em;
border-color: black;
border-style: solid;
border-width: 0px 0px 0px 5px;
}
table {
border-collapse: collapse;
width: 600px;
}
.mini {
width: 400px;
}
.maxi {
width: 100%;
}
.pbox {
width: 100%;
}
img {
margin: 1em;
}
.pbox {
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
}
figure.pbox {
width: 100%;
}
Now the pbox class of table has width set to 100%, so the table in the profile box should fill up its parent element, right? (I can feel a "Wrong!" coming on.) However, this is what the page actually looks like in Chromium:
Table too narrow
If I replace <table class="pbox"> with <table class="maxi">, I get the desired result:
Table just right
But the maxi and pbox classes of table are identical! Any idea what's going on here?
I had assumed - incorrectly - that if you put something like:
CSS
element1 {
property-a: setting1;
}
.class-name {
property-b: setting2;
}
element2 {
property-c: setting3;
}
.class-name {
property-d: setting4;
}
HTML
<element2 class="class-name"/>
Then element2 will have properties:
property-c: setting3;
property-d: setting4;
In fact, all definitions of .class-name will be applied, so element2 will have properties:
property-b: setting2;
property-c: setting3;
property-d: setting4;
If we amend the CSS as follows:
element1 {
property-a: setting1;
}
element1.class-name {
property-b: setting2;
}
element2 {
property-c: setting3;
}
element2.class-name {
property-d: setting4;
}
Then everything works!
I'm an experienced .net developer, but all of us have areas where we can benefit from improvements. I feel that I'm severely lacking in HTML/CSS skills and I'm trying to teach myself in this area.
I'm trying to create an HTML layout for an application that monitors bandwidth consumption on the local network. I envisage the layout as consisting of 4 elements:
+--------------------------+
+ Controls +
+--------+-----------------+
+ Legend + Graph +
+ + +
+ + +
+ + +
+ + +
+--------+-----------------+
+ Log +
+--------------------------+
Controls - this is a narrow area that will allow clear, pause and otherwise control the graph. It will also allow to show and hide log area. This means that the layout need to accommodate the log area being hidden.
Legend - is a table that will list all series on the graph. It will show series color and also some numeric data associated with the series. If there are more lines in the legend that fit the screen it should be possible to vertical scroll legend area. Horizontal scroll is never required for the area it's assumed that it is always narrow enough. The height of Legend (and Graph) should take up all the remaining space that is not used by Control area and Log area. The width of the legend will be equal to the natural table width.
Graph - there will be a Graph here painted over HTML canvas. This should take up all available space both horizontally and vertically.
Log - here will be two or three lines of log displayed. If there are more than 3 lines to display there should be a vertical scroll bar on this area. This area need to be able to be hid-able. The height of this area can be made fixed. (in the vicinity of 100px - 200px).
The layout should adapt to window re-sizing, and keep looking descent when windows is being made small (to a point of course). Unless the window is too small, it should not have outer horizontal and vertical scrollbars.
Unfortunately, I cannot get it right in several places.
This is my code:
<html>
<head>
<style>
* {margin:0;padding:0;height:100%;}
html, button, input, select, textarea {
font-family: sans-serif;
font-weight: 100;
letter-spacing: 0.01em;
}
.container {
min-height:100%;
position:relative;
}
.control {
background:green;
width:100%;
height:auto;
margin-top: 0;
}
.content {
width:100%;
margin:0;
margin-top:0;
margin-bottom:0;
}
.legend {
position:relative;
background:blue;
float:left
}
.graph {
background:red;
}
.log {
background:yellow;
width:100%;
height:auto;
position:absolute;
margin-top: 0;
margin-bottom: 0;
bottom:0;
left:0;
}
.table {
border-collapse: collapse;
border-spacing: 0;
empty-cells: show;
border: 1px solid #cbcbcb;
}
.table td,
.table th {
border-left: 1px solid #cbcbcb;
border-width: 0 0 0 1px;
font-size: inherit;
margin: 0;
overflow: visible;
padding: 0.5em 1em;
}
.table thead {
background-color: #e0e0e0;
color: #000;
text-align: left;
vertical-align: bottom;
}
.table td {
background-color: transparent;
}
.table-odd td {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<div class="container">
<div class="control">header1<br/>header2</div>
<div class="content">
<div class="legend">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Make</th>
<th>Model</th>
<th>Year</th>
</tr>
</thead>
<tbody>
<tr class="table-odd">
<td style="background-color: #FFB300">1</td>
<td>Honda</td>
<td>Accord</td>
<td>2009</td>
</tr>
<tr>
<td style="background-color: #803E75">2</td>
<td>Toyota</td>
<td>Camry</td>
<td>2012</td>
</tr>
<tr class="table-odd">
<td style="background-color: #FF6800">3</td>
<td>Hyundai</td>
<td>Elantra</td>
<td>2010</td>
</tr>
<tr>
<td style="background-color: #A6BDD7">4</td>
<td>Ford</td>
<td>Focus</td>
<td>2008</td>
</tr>
<tr class="table-odd">
<td style="background-color: #C10020">5</td>
<td>Nissan</td>
<td>Sentra</td>
<td>2011</td>
</tr>
<tr>
<td style="background-color: #CEA262">6</td>
<td>BMW</td>
<td>M3</td>
<td>2009</td>
</tr>
<tr class="table-odd">
<td style="background-color: #817066">7</td>
<td>Honda</td>
<td>Civic</td>
<td>2010</td>
</tr>
<tr>
<td style="background-color: #007D34">8</td>
<td>Kia</td>
<td>Soul</td>
<td>2010</td>
</tr>
</tbody>
</table>
</div>
<div class="graph"><canvas></canvas></div>
</div>
<div class="log">log1<br/>log2</div>
</div>
<script>
function resize() {
var canvas = document.querySelector('canvas');
canvas.style.width = '100%';
canvas.style.height = '100%';
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
ctx = canvas.getContext('2d');
ctx.strokeStyle='yellow';
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(canvas.width,canvas.height);
ctx.stroke();
}
resize();
window.addEventListener('resize', resize, false);
</script>
</body>
</html>
This is the corresponding JSFiddle
Particular problems that I'm facing:
Why canvas is being rendered outside of the enclosing div? This is very surprising to me and I cannot figure out why.
How do I make the table be spaced out naturally? In particular:
Why first line is so tall?
How do I make the table do not take the whole height? It's enclosing dive that has height:100%, not the table, so why is it so tall?
How do I make it scroll-able if it's does not fit in the height?
The Legend/Graph area seems to extend underneath the Log area. Why? How do I prevent that?
Finally, how can I make the Log area of fixed height and scroll-able?
My apologies, I know that this question is a tall order, I'll gratefully accept any help and/or pointers. I do realize that I lack basic understanding, but that's what I'm trying to work against. I spent most of the evening today researching this topic and looking for source that allowed me to put together at least this non-working example. I'm comfortable with JavaScript, it's HTML/CSS that I mainly need help with. I studied the documentation on what properties of different DOM objects do, but it's difficult to figure out what properties to use and how.
You are complicating your CSS a lot for what you want,
you can use CSS Flexbox along with CSS calc() for this
body {
margin: 0
}
section {
background: red;
height: 50px;
}
article {
display: flex;
height: calc(100vh - 100px)
}
aside,
div {
background: lightblue;
}
aside {
overflow-y: auto;
max-width: 45%
}
aside ~ div {
flex: 1
}
canvas {
width: 100%;
height: 100%;
background: green
}
.table {
display: table;
table-layout:fixed;
width:100%
}
.row {
display: table-row;
background-color: #fff;
}
.column {
display: table-cell;
vertical-align: top;
border-left: 1px solid #cbcbcb;
border-width: 0 0 0 1px;
font-size: inherit;
margin: 0;
padding: 0.5em 1em;
background-color: inherit;
}
.cell-header {
font-weight: bold;
}
.row-odd {
background-color: #f2f2f2;
}
<main>
<section>Controls</section>
<article>
<aside>
<div class="table">
<div class="row row-odd">
<div class="column cell-header">#</div>
<div class="column cell-header">Make</div>
<div class="column cell-header">Model</div>
<div class="column cell-header">Year</div>
</div>
<div class="row">
<div class="column" style="background-color: #FFB300">1</div>
<div class="column">Honda</div>
<div class="column">Accord</div>
<div class="column">2009</div>
</div>
<div class="row row-odd">
<div class="column" style="background-color: #803E75">2</div>
<div class="column">Toyota</div>
<div class="column">Camry</div>
<div class="column">2012</div>
</div>
<div class="row">
<div class="column" style="background-color: #FF6800">3</div>
<div class="column">Hyundai</div>
<div class="column">Elantra</div>
<div class="column">2010</div>
</div>
<div class="row row-odd">
<div class="column" style="background-color: #A6BDD7">4</div>
<div class="column">Ford</div>
<div class="column">Focus</div>
<div class="column">2008</div>
</div>
<div class="row">
<div class="column" style="background-color: #C10020">5</div>
<div class="column">Nissan</div>
<div class="column">Sentra</div>
<div class="column">2011</div>
</div>
<div class="row row-odd">
<div class="column" style="background-color: #CEA262">6</div>
<div class="column">BMW</div>
<div class="column">M3</div>
<div class="column">2009</div>
</div>
<div class="row">
<div class="column" style="background-color: #817066">7</div>
<div class="column">Honda</div>
<div class="column">Civic</div>
<div class="column">2010</div>
</div>
<div class="row row-odd">
<div class="column" style="background-color: #007D34">8</div>
<div class="column">Kia</div>
<div class="column">Soul</div>
<div class="column">2010</div>
</div>
</div>
</aside>
<div>
<canvas width="985" height="223"></canvas>
</div>
</article>
<section>Log</section>
</main>
Well your code is a mess. Here is my attempt to clean it a bit and achieve what you described: https://jsfiddle.net/dckex2g7/
I assumed that top and bottom bars have fixed height which makes this a bit simpler. If they don't, you should use display: flex; flex-direction: column on body element and flex-grow: 1 on .content.
Notice how I haven't used any JS for layout. To make it responsive you should use things like min-width and media queries. You almost never need JS for layout unless in a very few very specific cases which are not covered by flexbox somehow.
There's really a lot to describe about this solution so if you have any specific question ask away.
I am using Zurb Foundation for page layout. A row on my page needs have some text and then a line that fills the rest of the width, like so:
| Text of Indeterminate Length -------------------------------------- |
I have the desired layout working with <table> and <hr> tags:
<div class="row">
<div class="large-12 columns">
<table style="width:auto;border-collapse:collapse;border:0;padding:0;margin:0;">
<tr>
<td style="white-space:nowrap;padding:0;">
<h3>Text of Indeterminate Length</h3>
</td>
<td style="width:100%;"><hr/></td>
</tr>
</table>
</div>
</div>
I realize that the use of <table> for layout and <hr> for drawing lines are both generally frowned upon in modern web design. I spent a while trying to get the same layout using <div>, <span>, and <p> and couldn't come up with anything simple and straightforward that didn't require what seemed like an excessive use of Javascript. On top of that, most recommended solutions suggest using things like border_bottom which doesn't give me a nice line in the middle like <hr> does.
So my question is this: is there a straightforward way to do this without <table> or <hr>? Perhaps with some sort of a custom <span> style?
A potential solution could be to give your heading a background style with display:block and width:100% and the text with a white background to hide the line from the containing heading? http://jsfiddle.net/9o74jbLh/
<h3><span>{% block hightide_pagename %}{% endblock hightide_pagename %}
</span></h3>
h3 {
display:block;
position:relative;
width:100%;
}
h3:after {
content:"";
height:1px;
width:100%;
background: #000;
position:absolute;
top:50%;
}
h3 span {
background:#fff;
}
I've seen this design element pop up a few times, and the best way that I've seen it done (which is by no means a perfect way) is to use overflow hidden on a container, float the heading (or make it inline-block), and set the left attribute of your absolutely positioned line element (preferably a pseudo-element so as to keep your markup clean). In effect you get this:
/* stuff to make the demo pretty */
table {
border: 1px solid red;
}
table:before {
content: 'bad way';
color: red;
display: block;
}
.good-ish-way {
border: 1px solid green;
margin-top: 1em;
}
.good-ish-way:before {
content: 'good-ish way';
color: green;
display: block;
}
/* the actually useful stuff. */
.good-ish-way {
overflow: hidden;
}
.good-ish-way h3 {
position: relative;
display:inline-block;
}
.good-ish-way h3:after {
content: '';
width: 100%;
position: absolute;
left: 100%;
height: 1px;
background: #777;
width: 1000%;
top: 0;
bottom: 0;
margin: auto 0 auto 0.3em;
}
<table>
<tr>
<td style="white-space:nowrap;padding:0;">
<h3>Text of Indeterminate Length</h3>
</td>
<td style="width:100%;"><hr/></td>
</tr>
</table>
<div class="good-ish-way">
<h3>Text of Indeterminate Length</h3>
</div>
The only major problem with it is the 1000% part. I've seen other devs use a large pixel value, but the thing is, you'll never know if it's enough. You could use 100vw, but then there are some compatibility issues with older browsers.
Demo for you to play around with it: http://jsfiddle.net/uru17kox/
Edit: Oh! and here's where I first saw this method illustrated in case you want a different spin on it. https://css-tricks.com/line-on-sides-headers/
Html code:
<div class="CorpPerformance">
<div class="row">
<div class="DashboardTitle">
3 Month
</div>
<div class="DashboardScore" style="font-weight:bold">
<a class="redirectLink" data-criteria-corporatesummarycategory="none" data-criteria-corporatesummaryexpand="0" data-criteria-customerpay="" data-criteria-expressservice="" data-criteria-maintenanceplan="" data-criteria-modelname="" data-criteria-rspenddate="" data-criteria-rspstartdate="" data-criteria-warrantypay="" data-criteria-yearmodel="" data-criteria-department="Sales" data-criteria-reportperiod="[Collection Date].[Calendar].[Calendar Month].&[October 2014]" data-criteria-summaryperiod="3MONTH" href="/Corporate/OFSSurveySummary">950</a>
</div>
<div class="DashboardIcon">
<a class="bootstrap-modal" data-criteria-chartcustomerpay="" data-criteria-chartexpressservice="" data-criteria-chartmaintenanceplan="" data-criteria-chartmodelname="" data-criteria-chartmodelyear="" data-criteria-chartwarrantypay="" data-criteria-chartdepartment="SALES" data-criteria-chartmeasurename="Response Default Computation" data-criteria-chartmeasuretype="score" data-criteria-chartorganization="" data-criteria-chartpagetitle="NSSI Trend" data-criteria-chartreportperiod="[Collection Date].[Calendar].[Calendar Month].&[October 2014]" data-criteria-chartsummaryperiod="3MONTH" data-criteria-charttitle="NSSI" data-criteria-chartwheretuple="[Questionnaire].[Questionnaire].[Question].&[OFSP]&[OFSP13011]" href="/Trend" modal-no-resize="True" upper="NSSI Trend"><span>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAAZCAYAAACM9limAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHxSURBVFhH7Zg9SEJRFMcdW4QmcRI3xclNcYiGBocGB4dqMQTXdHdoFRqsoCAtJEiMKCpCHkHkECFJUNQgNqgEIQ19DIFBw8n/8SkUPft66n31fnBArnLh/O69556roQHp8WEYSOctuhgFhBdTLN5RLndN2WxZHukNQoopFGrk9W6S1Zogu32FhofXyeFI0cBAnHy+HUqlLunh4Vn+dWfq9RcWG4+f0sjIBnk8aZ5vcHC+kfgMz/URQolBspHIIdlsyxSLnVCl8ih/0wRJbm9f0eSkREbjHJlMC5wkYmIiS4GAxEJbY2bzIsvEZ8w7O3vKkhCfiRVGDFYOuwMr+1Vqtad2oonEOU1NHZAkldtj78V+h76LyedvWIjfv8uJikLfxGA1x8b2yO1O8+qKRs/FYFeMjm5xHclkivKoePRMTKuw4qaZnj7mQioyPRETDjeFoLCKLqRF18XgGh0f3/ty3yEKXRODnYGeQqmBEp2uiMHuQIeKnkKrqC6mVLqnoaGMpqUAVcXg+rVYlrht1zqqiMHRwfsFDZvWiqwSvxaTTF5wS6/VIqvEj8Wcnd3yq9XlWqNq9eePNVHpKAZvGCSPY4JuFREK7fMOcTpXhXzjqEVHMQDJ45hASjR6RMGgxP+q/XU+FfNf0cUo0Bajx/sw0CuzQYKdi8e4ggAAAABJRU5ErkJggg==">
</span></a> </div>
<div class="CvalNational">
<span style="color:#fff;font-weight:bold;">
National
</span>
</div>
<br>
</div>
</div>
JSfiddle link :
http://jsfiddle.net/8nbyc9m7/
Output without zoom :
if i zoom to 110% or 150% or 60% zooming it gives different output. that means last section is not aligned properly.
with zoom:
how to maintain the same output for all levels of zooming in all browsers.
Setting the container to have a width equals to the parent container does the trick for me
http://jsfiddle.net/kursion/8nbyc9m7/2/
Btw... you should probably concider doing a simple table ?
.CorpPerformance {
padding-left: 5px; <----------- changed
display: table;
border: 2px solid gray;
border-radius: 5px;
vertical-align: middle;
line-height: 30px;
width: 340px; <----------- changed
}
.CorpPerformance .DashboardTitle {
width: 80px; <----------- changed
}
.CorpPerformance .DashboardScore {
width: 40px; <----------- changed
}
.CorpPerformance .DashboardIcon {
width: 100px; <----------- changed
}
.CorpPerformance .CvalNational {
width: 119px; <----------- changed
text-align: center;
border-left: 1px dotted black;
background-color: gray;
}
80px + 40px + 100px + 119px + 1px(border) = 340px
And I removed the padding
.CorpPerformance .row > div {}
Edit: with a table... it's much more easier and zoom works ! Check the link in my comment
http://jsfiddle.net/victor_007/8nbyc9m7/3/
* {
box-sizing:border-box;
}
use box-sizing:border-box; which gives border and padding from inside and set the width exactly which you want
Here is your solution.
What I did is to correct your table and remove the width of the last cell so that it can be flexible. I have used table and tr and td instead of div as it will make your css lighter.
If you can't or don't want to change your div for table, tr and td, you can always add the following css on your div: display: table; to replace table, display: table-row; to replace tr, and display: table-cell; to replace td. The result will be the same.
.CorpPerformance {
border: 2px solid gray;
border-radius: 5px;
vertical-align: middle; /* it's defined for the whole table so you don't need to write it again */
line-height: 30px;
max-width: 343px;
border-spacing: 0; /* important for Chrome browser that add spacing */
}
img {
max-width: 100%;
vertical-align: middle;
border: 0;
}
.CorpPerformance > td {
padding: 0 5px 3px; /* I've just simplified the writing */
}
.CorpPerformance .DashboardTitle {
width: 110px;
}
.CorpPerformance .DashboardScore {
width: 25px;
}
.CorpPerformance .DashboardIcon {
width: 75px;
}
.CorpPerformance .CvalNational { /* no width anymore */
text-align: center;
border-left: 2px dotted black;
background-color: gray;
color: #fff; /* I've remove your span to put the css here, if you can do this it's best to keep html free of css */
font-weight: bold;
}
<table class="CorpPerformance">
<tr>
<td class="DashboardTitle">3 Month</td>
<td class="DashboardScore" style="font-weight:bold"> <a class="redirectLink" data-criteria-corporatesummarycategory="none" data-criteria-corporatesummaryexpand="0" data-criteria-customerpay="" data-criteria-expressservice="" data-criteria-maintenanceplan="" data-criteria-modelname="" data-criteria-rspenddate=""
data-criteria-rspstartdate="" data-criteria-warrantypay="" data-criteria-yearmodel="" data-criteria-department="Sales" data-criteria-reportperiod="[Collection Date].[Calendar].[Calendar Month].&[October 2014]" data-criteria-summaryperiod="3MONTH"
href="/Corporate/OFSSurveySummary">950</a>
</td>
<td class="DashboardIcon">
<a class="bootstrap-modal" data-criteria-chartcustomerpay="" data-criteria-chartexpressservice="" data-criteria-chartmaintenanceplan="" data-criteria-chartmodelname="" data-criteria-chartmodelyear="" data-criteria-chartwarrantypay="" data-criteria-chartdepartment="SALES"
data-criteria-chartmeasurename="Response Default Computation" data-criteria-chartmeasuretype="score" data-criteria-chartorganization="" data-criteria-chartpagetitle="NSSI Trend" data-criteria-chartreportperiod="[Collection Date].[Calendar].[Calendar Month].&[October 2014]"
data-criteria-chartsummaryperiod="3MONTH" data-criteria-charttitle="NSSI" data-criteria-chartwheretuple="[Questionnaire].[Questionnaire].[Question].&[OFSP]&[OFSP13011]" href="/Trend" modal-no-resize="True" upper="NSSI Trend"><span>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAAZCAYAAACM9limAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHxSURBVFhH7Zg9SEJRFMcdW4QmcRI3xclNcYiGBocGB4dqMQTXdHdoFRqsoCAtJEiMKCpCHkHkECFJUNQgNqgEIQ19DIFBw8n/8SkUPft66n31fnBArnLh/O69556roQHp8WEYSOctuhgFhBdTLN5RLndN2WxZHukNQoopFGrk9W6S1Zogu32FhofXyeFI0cBAnHy+HUqlLunh4Vn+dWfq9RcWG4+f0sjIBnk8aZ5vcHC+kfgMz/URQolBspHIIdlsyxSLnVCl8ih/0wRJbm9f0eSkREbjHJlMC5wkYmIiS4GAxEJbY2bzIsvEZ8w7O3vKkhCfiRVGDFYOuwMr+1Vqtad2oonEOU1NHZAkldtj78V+h76LyedvWIjfv8uJikLfxGA1x8b2yO1O8+qKRs/FYFeMjm5xHclkivKoePRMTKuw4qaZnj7mQioyPRETDjeFoLCKLqRF18XgGh0f3/ty3yEKXRODnYGeQqmBEp2uiMHuQIeKnkKrqC6mVLqnoaGMpqUAVcXg+rVYlrht1zqqiMHRwfsFDZvWiqwSvxaTTF5wS6/VIqvEj8Wcnd3yq9XlWqNq9eePNVHpKAZvGCSPY4JuFREK7fMOcTpXhXzjqEVHMQDJ45hASjR6RMGgxP+q/XU+FfNf0cUo0Bajx/sw0CuzQYKdi8e4ggAAAABJRU5ErkJggg==" /></span></a>
</td>
<td class="CvalNational">Test National</td>
</tr>
</table>
I have a table I have simplified for this question while preserving the problem.
It is a single row with three cells. The middle one contains an image and the first and last ones fill the remaining space and are textually supposed to be empty.
The height of the first and last cell adapts to that of the central (image) one as it is the highest, which does work -
but they become a tad bigger than they should visually creating a hole beneath the central cell.
HTML:
<article class="content" id="pc">
<table id="contentTable">
<tr>
<td class="pad" id="padL"></td>
<td id="cc">
<a href="#"><img src="http://38.media.tumblr.com/b9dc51057ece7352d07d40f4c59f0c65/tumblr_nb0xmfghdm1tin2h1o1_500.jpg" width="250"/>
</a>
</td>
<td class="pad" id="padR"></td>
</tr>
</table>
</article>
CSS:
#contentTable {
table-layout: fixed;
width: 700px;
}
#cc {
width: 500px;
}
.pad {
background-color: gray;
vertical-align: middle;
}
#padR {
border-top-right-radius: 2em;
border-bottom-right-radius: 2em;
}
#padL {
border-top-left-radius: 2em;
border-bottom-left-radius: 2em;
}
Here is a screen shot of the problem with the space highlighted in blue
And a CodePen if it helps.
Why does it occur and how can I remove it?
Since your image is inline, it obeys rules of baseline and has space at the bottom.
I had success by setting:
img {
display:block;
}
To get rid of other table spacing (not showing in your screen-shot), I suggest adding:
#contentTable {
border-collapse:collapse;
...
}
#contentTable tr td{
padding:0;
}
WORKING EXAMPLE
EDIT
Per your comment, here's an example using an embedded YouTube video (iframe). Iframes default to display:inline (replaced element), too.
iframe { display:block; }
WORKING EXAMPLE
Add a class to the cell containing the picture.
<td class="pad" id="cc">