Intersecting horizontal and vertical lines in HTML and CSS - html

I have begun creating an OrgChart using HTML and CSS. One issue I have run into is creating an intersecting chart flow-line between <tr> and <td> elements.
I created container, vertical-line and horizontal-line definitions that I wrapped into <td> andtags. The vertical-line works correctly by cantering the line in the. I created a second` for the horizontal-line to intersect in the middle with the vertical-line. However, the line remains at the bottom.
I have added the CSS and HTML to my post and hope that one of you can help me on what I am doing wrong.
table {
border-collapse: collapse;
margin-left: auto;
margin-right: auto;
width: auto;
}
tr {
border: none;
}
th,
td {
border-collapse: collapse;
border: 1px solid black;
padding-top: 0;
padding-bottom: 0;
text-align: center;
width: 100;
}
div.container {
width: 40px;
}
div.vertical-line {
border-left: 1px solid red;
height: 55px;
margin-left: auto;
margin-right: auto;
width: 1px;
}
div.horizontal-line {
border-bottom: 1px solid red;
height: 1px;
margin-top: auto;
margin-bottom: auto;
width: 40px;
}
<table>
<tr>
<td style="background-color: goldenrod" colspan="3">
<div>Dept
</br>
<b>EmpName</b>
</div>
</td>
</tr>
<tr>
<td style="width: 42.5%; background-color: wheat">
<div>Dept
</br>
<b>EmpName</b>
</div>
</td>
<td style="width: 15%">
<div class="container">
<div class="vertical-line"> </div>
<div class="horizontal-line"> </div>
</div>
</td>
<td style="width: 42.5%">
<div style="background-color:#CCFFCC">Dept
</br>
<b>EmpName</b>
<div style="border-bottom: 1px solid">
</div>
<div style="background-color:#CCFFFF">Dept
</br>
<b>EmpName</b>
</div>
</td>
</tr>
</table>

Here's a workaround:
add another horizontal line before the vertical line:
<td style="width: 15%">
<div class="container">
<div class="horizontal-line"> </div>
<div class="vertical-line"> </div>
<div class="horizontal-line"> </div>
</div>
</td>
Then change the display of it's container to flex:
div.container {
display: flex;
width: 40px;
}

Related

How to make table with different spacing and rounded corners

My attempt is to create a table with unique spacing, in this case it would be 3 columns but in my first attempt I tried using rectangle and straight lines, the white spaces need to interact so I found it better and more obvious to try to use a table with custom css, below the example that I wish to mirror myself, I need to get to the reproduction of it.
my attempt with retancle is so bad like this
<div class="_idGenObjectLayout-1">
<div id="_idContainer000" class="_idGenObjectStyleOverride-1">
</div>
</div>
<div class="_idGenObjectLayout-1">
<div id="_idContainer001" class="Quadro-de-gr-fico-b-sico _idGenObjectStyleOverride-2">
</div>
</div>
<div class="_idGenObjectLayout-1">
<div id="_idContainer002" class="Quadro-de-gr-fico-b-sico _idGenObjectStyleOverride-3">
</div>
</div>
<div class="_idGenObjectLayout-1">
<div id="_idContainer003" class="Quadro-de-gr-fico-b-sico _idGenObjectStyleOverride-4">
</div>
</div>
<div class="_idGenObjectLayout-1">
<div id="_idContainer004" class="Quadro-de-gr-fico-b-sico _idGenObjectStyleOverride-4">
</div>
</div>
My question is how to reproduce this table properly with tables with divs/html/css
.custom-table{
border: 2px solid #6cb7e1;
border-collapse: collapse;
background-color: #287cb6;
width: 410px;
height: 68px;
}
.custom-table td {
border: 2px solid #6cb7e1;
}
.custom-table td span.line {
border-bottom: 1px solid #3a86bd;
display: block;
}
.custom-table .arrow {
width: 27px;
position: relative;
cursor: pointer;
}
.custom-table .arrow > span {
border: 6px solid #d3a823;
border-color: #d3a823 transparent transparent transparent;
width: 0;
height: 0;
display: inline-block;
position: absolute;
top: 50%;
left: 50%;
transform:translate(-50%, -50%)
}
<table class="custom-table">
<tr>
<td>
<span class="line">line</span>
</td>
<td rowspan="2">
<span class="line">line</span>
<span class="line">line</span>
</td>
<td rowspan="2" class="arrow">
<span></span>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
I suggest you to use a combination of table, spans and css.

Display inline - overflow visible opacity

I have a table which should not have multi-lines. So I was thinking of forcing the overflow being hidden and make overflow visible it on hover. However, the other text is still shining through the visible overflow. Is there a way to prevent this?
https://jsfiddle.net/60mj7gqb/1/
<table>
<tr>
<td style="height: 30px; width: 100px; border: 1px solid grey;">
<div style="width: 100px; overflow: hidden">
<span style="white-space: nowrap; padding: 5px;">myPreciousText is located here</span>
</div>
</td>
<td style="height: 30px; width: 100px; border: 1px solid grey;">
<div style="width: 100px; overflow: visible">
<span style="white-space: nowrap; padding: 5px; background: #afffcf">myPreciousText is located here</span>
</div>
</td>
<td style="height: 30px; width: 100px; border: 1px solid grey;">
<div style="width: 100px; overflow: hidden">
<span style="white-space: nowrap; padding: 5px;">myPreciousText is located here</span>
</div>
</td>
</tr>
</table>
You could add a z-index on hover (as well as your background-colour on the span):
div {
overflow: hidden;
}
div:hover {
position: relative;
z-index: 1;
overflow: visible;
}
div:hover span {
background: #afffcf;
}
<table>
<tr>
<td style="height: 30px; width: 100px; border: 1px solid grey;">
<div style="width: 100px; ">
<span style="white-space: nowrap; padding: 5px;">myPreciousText is located here</span>
</div>
</td>
<td style="height: 30px; width: 100px; border: 1px solid grey;">
<div style="width: 100px; ">
<span style="white-space: nowrap; padding: 5px; ">myPreciousText is located here</span>
</div>
</td>
<td style="height: 30px; width: 100px; border: 1px solid grey;">
<div style="width: 100px;">
<span style="white-space: nowrap; padding: 5px;">myPreciousText is located here</span>
</div>
</td>
</tr>
</table>

Firefox renders table incorrect with multiple rowspan and colspan

The following code works well in Chrome and IE, but does not working in Firefox.
The table is generated dynamically and tr/td can't be removed from the following example
.widget-table-container,
tr td {
border: 1px solid red;
}
.widget {
border: 1px solid green;
margin: 0px;
padding: 0px;
background-color: #ffffff;
border-radius: 5px;
overflow: hidden;
height: 100%;
width: 100%;
left: 1px;
top: 1px;
bottom: 0px;
right: 0px;
}
<table class="widget-table-container">
<tbody>
<tr>
<td colspan="2" rowspan="2" style="width: 378px; height: 378px;">
<div class="widget" style="width: 371px; height: 371px; background-color:lightblue;">
<div class="widget-title">
<p>Title</p>
</div>
<div class="widget-body"></div>
</div>
</td>
<td colspan="8" rowspan="4" style="width: 1512px; height: 756px;">
<div class="widget" style="width: 1493px; height: 745px;">
<div class="widget-title">Title CPU</p>
</div>
<div class="widget-body">BODY</div>
</div>
</td>
</tr>
<tr>
</tr>
<tr>
<td colspan="2" rowspan="2" style="width: 378px; height: 378px;">
<div class="widget" style="width: 371px; height: 371px;">
<div class="widget-title">
<p>Some Title</p>
</div>
<div class="widget-body"></div>
</div>
</td>
</tr>
<tr></tr>
</tbody>
</table>
I have removed last empty and it looks like fixed problem.
I'm not sure why only removing last tr fixed problem not all tr.
But i my case it is working, Thanks All for help.

How do I bottom-align bars in a CSS vertical bar chart?

I am experimenting with two different bar charts I created using HTML and CSS: horizontal and vertical. How do I move the bars in my vertical bar chart from the center to the bottom?
body {
font-family: Arial, Helvetica, sans-serif;
}
/* Global */
.stat-table-horz, .stat-table-vert {
border-collapse: collapse;
}
.bar {
background: #0c0;
}
/* Horizontal bar chart */
.stat-table-horz td:first-of-type {
padding: 5px;
}
.stat-table-horz td:nth-of-type(2) {
border-top: 1px solid #090;
border-bottom: 1px solid #090;
padding: 0;
width: 240px;
}
.stat-table-horz td .horz-bar {
height: 30px;
}
/* Vertical bar chart */
.stat-table-vert tr:nth-of-type(2) td {
padding: 5px;
}
.stat-table-vert tr:first-of-type td {
border-left: 1px solid #090;
border-right: 1px solid #090;
padding: 0;
height: 160px;
width: 80px;
}
.stat-table-vert td .vert-bar {
}
<body>
<table class="stat-table-horz">
<tr>
<td>Health</td>
<td>
<!-- First bar -->
<div class="bar horz-bar" style="width: 10%;"></div>
</td>
</tr>
<tr>
<td>Attack</td>
<td>
<!-- Second bar -->
<div class="bar horz-bar" style="width: 90%;"></div>
</td>
</tr>
<tr>
<td>Speed</td>
<td>
<!-- Third bar -->
<div class="bar horz-bar" style="width: 60%;"></div>
</td>
</tr>
</table>
<br>
<table class="stat-table-vert">
<tr>
<td>
<!-- First bar -->
<div class="bar vert-bar" style="height: 10%;"></div>
</td>
<td>
<!-- Second bar -->
<div class="bar vert-bar" style="height: 90%;"></div>
</td>
<td>
<!-- Third bar -->
<div class="bar vert-bar" style="height: 60%;"></div>
</td>
</tr>
<tr>
<td>Health</td>
<td>Attack</td>
<td>Speed</td>
</tr>
</table>
</body>
My original JSFiddle: https://jsfiddle.net/jkantner/b7aa2yu1/
Just add
.stat-table-vert td {
vertical-align:bottom;
}
Adding vertical-align: bottom to the containing TD seems to do it if I'm understanding you correctly.
.stat-table-vert tr:first-of-type td {
border-left: 1px solid #090;
border-right: 1px solid #090;
padding: 0;
height: 160px;
width: 80px;
vertical-align: bottom;
}
Using vertical-align: bottom; or vertical-align: baseline on the td element should fix the issue.
body {
font-family: Arial, Helvetica, sans-serif;
}
/* Global */
.stat-table-horz, .stat-table-vert {
border-collapse: collapse;
}
.bar {
background: #0c0;
}
/* Horizontal bar chart */
.stat-table-horz td:first-of-type {
padding: 5px;
}
.stat-table-horz td:nth-of-type(2) {
border-top: 1px solid #090;
border-bottom: 1px solid #090;
padding: 0;
width: 240px;
}
.stat-table-horz td .horz-bar {
height: 30px;
}
/* Vertical bar chart */
.stat-table-vert tr:nth-of-type(2) td {
padding: 5px;
}
.stat-table-vert tr:first-of-type td {
border-left: 1px solid #090;
border-right: 1px solid #090;
padding: 0;
height: 160px;
width: 80px;
vertical-align: baseline;
}
.stat-table-vert td .vert-bar {
}
<body>
<table class="stat-table-horz">
<tr>
<td>Health</td>
<td>
<!-- First bar -->
<div class="bar horz-bar" style="width: 10%;"></div>
</td>
</tr>
<tr>
<td>Attack</td>
<td>
<!-- Second bar -->
<div class="bar horz-bar" style="width: 90%;"></div>
</td>
</tr>
<tr>
<td>Speed</td>
<td>
<!-- Third bar -->
<div class="bar horz-bar" style="width: 60%;"></div>
</td>
</tr>
</table>
<br>
<table class="stat-table-vert">
<tr>
<td>
<!-- First bar -->
<div class="bar vert-bar" style="height: 10%;"></div>
</td>
<td>
<!-- Second bar -->
<div class="bar vert-bar" style="height: 90%;"></div>
</td>
<td>
<!-- Third bar -->
<div class="bar vert-bar" style="height: 60%;"></div>
</td>
</tr>
<tr>
<td>Health</td>
<td>Attack</td>
<td>Speed</td>
</tr>
</table>
</body>
Vertical align
Add flowing css
.stat-table-vert td {
position: relative;
}
.stat-table-vert .bar.vert-bar{
position: absolute;
bottom: 0;
width: 100%;
}
or
add
.stat-table-vert td {
vertical-align:bottom;
}
https://jsfiddle.net/b7aa2yu1/4/

Unexplained Extra Space, Possibly Padding Surrounding a Table within a Table

This is an experiment I'm working on for a layout. I had a lot of issues positioning divs to achieve this effect, so I turned to the old standby, table cascades. My problem here is that that last upper box has extra padding in all 3 browsers and I cannot seem to CSS or HTML it away no matter what I try. The red boxes should be flush over the green bits you see surrounding them and there shouldn't be a 1px visible green line to the right of the blue row between the red boxes. Any insight would be extremely appreciated.
<!doctype html>
<html>
<head>
<style>
table { border-collapse: collapse; border-spacing: 0; padding: 0; margin: 0;}
td table { border-collapse: collapse; border-spacing: 0; padding: 0; margin: 0;}
img { display: block; }
</style>
</head>
<body style="background-color: black;">
<table style="background-color: white; height: 525px; width: 3200; padding-top: 25px; padding-bottom: 25px;">
<tr>
<td colspan="1" style="width: 350px;">
<table class="container" style="height: 475px; width: 350px; margin-left: 25px; margin-right: 25px;">
<tr>
<td style="background-color: green; height: 225px; width: 350px;" colspan="3">
</td>
</tr>
<tr>
<td style="background-color: blue; height: 25px; width: 350px;" colspan="3">
</td>
</tr>
<tr>
<td style="background-color: green; height: 200px; width: 175px;">
</td>
<td style="background-color: blue; height: 200px; width: 25px;">
</td>
<td style="background-color: green; height: 200px; width: 125px;">
</td>
</tr>
</table>
</td>
<td colspan="1" style="width: 125px;">
<table class="container" style="height: 475px; width: 125px; margin-right: 25px;">
<tr>
<td style="background-color: red; height: 475px; width: 125px;">
</td>
</tr>
</table>
</td>
<td colspan="1">
<table class="container" style="height: 475px; width: 450px; margin-right: 25px;">
<tr>
<td style="background-color: green; height: 25px; width: 225px;">
</td>
<td style="background-color: blue; height: 225px; width: 25px;" >
</td>
<td style="background-color: green; height: 225px; width: 225px;" >
</td>
</tr>
<tr>
<td style="background-color: blue; height: 25px; width: 450px;" colspan="3">
</td>
</tr>
<tr>
<td style="background-color: green; height: 200px; width: 450px;" colspan="3">
</td>
</tr>
</table>
</td>
<td colspan="1">
<table class="container" style="height: 475px; width: 400px; margin-right: 25px;">
<tr style="height: 225px;">
<td style="background-color: green; height: 225px; width: 275px;">
<table style="width: 100%; height: 225px;">
<tr>
<td style="height: 100px; width: 225px; background-color: red;">
</td>
</tr>
<tr>
<td style="background-color: blue; height: 25px; width: 225px;">
</td>
</tr>
<tr>
<td style="height: 100px; width: 225px; background-color: red;">
</td>
</tr>
</table>
</td>
<td style="background-color: blue; height: 225px; width: 25px;" >
</td>
<td style="background-color: green; height: 225px; width: 100px;" >
</td>
</tr>
<tr>
<td style="background-color: blue; height: 25px; width: 400px;" colspan="3">
</td>
</tr>
<tr>
<td style="background-color: green; height: 200px; width: 400px;" colspan="3">
</td>
</tr>
</table>
</td>
</table>
</td>
</table>
</body>
</html>
Do you mean this?
http://jsfiddle.net/Nq8Us/1/
I've edited your code and removed the extra 'padding' of green under red in question, by removing inline-styling, then added some styles in css pointing to the #problem_cell_table.
I suggest you remove all your inline styling and shift them to the stylesheet. Inline-styling overrides all stylesheet code. That's bad and also explains why you don't get any effect from stylesheet changes.
As to why there's a padding, it's because your main table's height that is wrapping all the rows, cells, and inner-tables, is higher than the declared row height added together. The cells in your all the rows automatically adjusts it's size to compensate for pixels that doesn't add up to your total declared of 525px.
In the example I've done, I "cheated" by setting css of the inner-table to height: 100% so it will expand to fit the height, should miscalculations occur.
Give me a moment, I'll add more to the <div> styling methods in my answer.
Edit:
Ok here my attempt at the layout using <div> and CSS. http://jsfiddle.net/XbFcJ/
Remember to use a CSS Reset Stylesheet first!
The CSS:
<style>
body{
background: black;
}
.wrapper{
}
.container{
width: 1500px;
}
.content-table {
border: 25px solid #fff;
overflow: hidden;
background: #fff;
}
.content-column {
margin-right: 25px;
float: left;
height: 475px;
}
.content-column.last {
margin-right: 0;
}
.first, .third, .last {
width: 425px;
background-color: green;
margin-right: 25px;
}
.top{
height: 225px;
border-bottom: 25px solid blue;
}
.left {
height: 225px;
width: 200px;
border-right: 25px solid blue;
}
.content-column.second {
width: 100px;
background-color: red;
}
.last .left {
background-color: red;
}
.last .left .top {
height: 100px;
border-bottom: 25px solid blue;
}​
</style>
The HTML:
<body>
<div class="wrapper">
<div class="container">
<div class="content-table">
<div class="content-column first">
<div class="top">
</div>
<div class="bottom">
<div class="left">
</div>
</div>
</div>
<div class="content-column second">
</div>
<div class="content-column third">
<div class="top">
<div class="left">
</div>
</div>
<div class="bottom">
</div>
</div>
<div class="content-column last">
<div class="top">
<div class="left">
<div class="top">
</div>
</div>
</div>
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
</body>​