how to put row onto another one? / CSS - html

on the image as you can see 'Sezon' and 'Poza sezonem' blocks are on another blocks(ND-CZW, PT-SB)
I'm trying to write html code of this image. how can I put Sezon,poza sezonem blocks on the blocks below?
<div class="parent">
<tr>
<td style="text-align: center;background-color: #E96165;color: #fff">Ilosc
gosci</td>
<td class="baslik1">Sezon</td>
<td class="baslik1">Poza sezonem</td>
<td class="baslik1">Poza sezonem 2</td>
</tr>
<tr>
<td class="baslik2"> </td>
<td class="baslik2">ND-CZW</td>
<td class="baslik2">PT-SB</td>
<td class="baslik2">ND-CZW</td>
</tr>
</div>

I would use Flexbox with absolute positioning like this:
.parent {
display: flex;
}
.table {
display: flex;
flex-direction: column;
box-shadow: 0 20px 30px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
background: lightgrey;
}
.table:nth-child(2) {
z-index: 2;
}
.table:nth-child(3) {
z-index: 3;
}
.table > div {
display: flex;
flex-direction: row;
}
.cell {
box-sizing: border-box;
display: flex;
height: 60px;
width: 200px;
border-bottom: 1px solid grey;
}
.cell--head {
height: 60px;
position: relative;
}
.cell--logo {
background-color: #E96165;
color: #fff;
padding: 0;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
}
.cell--head > div {
padding-top: 30px;
}
.cell > div {
flex: 1;
text-align: center;
border-left: 1px solid grey;
padding: 20px;
}
.cell > div:first-of-type {
border-left: 0;
}
.label {
position: absolute;
top: -2px;
background: black;
color: white;
transform: translate(-50%, 0%);
left: 50%;
padding: 5px;
font-size: 10px;
}
<div class="parent">
<div class="table">
<div class="cell cell--logo">
Ilosc gosci
</div>
<div class="cell">
Ilosc gosci
</div>
</div>
<div class="table">
<div class="cell cell--head">
<span class="label">Sezon</span>
<div>ND-CZW</div>
<div>ND-CZW</div>
</div>
<div class="cell">
<div>245 pln</div>
<div>245 pln</div>
</div>
</div>
<div class="table">
<div class="cell cell--head">
<span class="label">Poza sezonem</span>
<div>ND-CZW</div>
<div>ND-CZW</div>
</div>
<div class="cell">
<div>245 pln</div>
<div>245 pln</div>
</div>
</div>
<div>
<td class="baslik2"></td>
<td class="baslik2"></td>
<td class="baslik2"></td>
<td class="baslik2"></td>
</div>
</div>
</div>

Your code seems to have some wrong syntax, I tried achieve the same in the fiddle below
http://jsfiddle.net/Parthoghsh820/akhwgg2f/3/
<table>
<thead>
<tr class="header">
<th colspan="2">
<span>Major 1</span>
</th>
<th colspan="2">
<span>Major 2</span>
</th>
</tr>
<tr class="subheader">
<th>col1</th>
<th>col2</th>
<th>col3</th>
<th>col4</th>
</tr>
</thead>
<tbody>
<tr>
<td>data1</td>
<td>data2</td>
<td>data3</td>
<td>data4</td>
</tr>
</tbody>

Related

Content inside a table cell doesn't take the whole space

I created this table:
table {
}
thead {
background-color: black;
color: white;
}
tbody, tr, td {
border: 1px solid black;
}
.cell-first-column {
width: 200px;
height: 70px;
}
.cell, th {
width: 100px;
height: 70px;
}
.td-cell {
height: 70px;
border: 1px solid black;
}
.chart {
position: relative;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
margin: 0
}
.chart-inner {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: gold;
}
.cell-text {
z-index: 10;
}
<table>
<thead>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
<th>Number</th>
</tr>
</thead>
<tr>
<td><div class="cell-first-column">Alfreds Futterkiste</div></td>
<td><div class="cell">Maria Anders</div></td>
<td><div class="cell">Germany</div></td>
<td><div class="cell">1234567</div></td>
</tr>
<tr>
<td><div class="cell-first-column">Centro comercial</div></td>
<td><div class="cell">Francisco Chang</div></td>
<td><div class="cell">Mexico</div></td>
<td><div class="cell">1234567</div></td>
</tr>
<tr>
<td><div class="cell-first-column">Opla</div></td>
<td class="td-cell">
<div class="chart">
<div class="chart-inner" style="height: 90%"></div>
<div class="cell-text">Charles Boule</div>
</div>
</td>
<td class="td-cell">
<div class="chart">
<div class="chart-inner" style="height: 30%"></div>
<div class="cell-text">France</div>
</div>
</td>
<td class="td-cell">
<div class="chart">
<div class="chart-inner" style="height: 50%"></div>
<div class="cell-text">1234567</div>
</div>
</td>
</tr>
</table>
inside the third row, the cells are colored and to do that I use absolute position.
It works but I don't understand why the yellow doesn't take the entire cell space, there is a white margin between the yellow and the cell border.
Margins are 0.
How it is now vs How I would like it to be:
Why? How can I solve?
Thanks a lot
Set padding of td to 0 should fix the issue.
The correct way:
<table cellpadding="0">

CSS Border doubling with flex

I have a piece of CSS I am working with. Whenever I add the "display: flex" property to .student, the border suddenly doubles. I need the flex property because I want the text to be centered vertically next to the image inside of the .student table data cell. How can I get rid of this pesky double border? The double border goes away whenever I remove the display:flex property, but then the text is no longer vertically next to the image. I've tried whitespace, border collapse, and several others without any luck.
Codepin: https://codepen.io/dansbyt/pen/dyvoejG?editors=1100
CSS:
/* ------------{GRADEBOOK}------------ */
.gradebook {
position: absolute;
top: 60px; left: 0;
width: 100vw; height: calc(100vh - 126px);
overflow-y: scroll;
box-sizing: border-box;}
/* Table styling*/
table {table-layout: fixed; border-collapse: collapse;}
/* Table heading styling */
thead th {
height: 60px; width: 100px;
top: 0; z-index: 2;
position: -webkit-sticky; position: sticky;
border-right: 1px solid gray;
background-color: white;}
thead th:first-child {left: 0; z-index: 10;}
th {
padding: 10px 16px;
text-align: left;
font-weight: normal;
color: gray}
table .duedate {font-size: 14px; margin-bottom: 8px}
table .title {font-size: 18px; color: #5B7042}
/* Table data styling */
td {
text-align: center;
border: 1px solid gray;
background-color: white}
td.late{background-color: #EA5D6B}
td input {
text-align: center;
padding: 4px; margin: 0;
width: 114px;
border: none;}
/* Student Name styling */
.student {
padding: 6px;
box-sizing: border-box;
display: flex;
align-items: center}
.pic{
display: inline-block;
width: 25px;
clip-path: circle();
margin-right: 10px;}
.pic img{display: none}
/* ------------{CONTROLS}------------ */
.controls {
display: flex;
position: absolute;
bottom: 10px; left: 0;
width: 100vw; height: 56px;
border-top: 1px solid #DDDDDD}
HTML:
<link rel="stylesheet" href="../style.css">
<div class='gradebook'>
<table>
<thead>
<tr>
<th style='width: 200px'></th>
<th>
<div class='duedate'>Due Oct 08</div>
<div class='title'>Mayflower Vocabulary</div>
</th>
<th>
<div class='duedate'>Due Oct 15</div>
<div class='title'>Wax Museum</div>
</th>
<th>
<div class='duedate'>Due Oct 15</div>
<div class='title'>American Revolution</div>
</th>
<th>
<div class='duedate'>Due Oct 27</div>
<div class='title'>Jamestown</div>
</th>
<th>
<div class='duedate'>Due Nov 1</div>
<div class='title'>Comparing Colonies</div>
</th>
</tr>
</thead>
<tr>
<td class='student'>
<img class='pic' src='../pics/default.png'>
<span>Jane Doe</span>
</td>
<td><input type='text' value='-'></td>
<td class='late'><input type='text' value='10'></td>
<td><input type='text' value='9.5'></td>
<td><input type='text' value='10'></td>
<td><input type='text' value='5'></td>
</tr>
<tr>
<td class='student'>
<img class='pic' src='../pics/default.png'>
<span>John Doe</span>
</td>
<td><input type='text' value='-'></td>
<td><input type='text' value='8'></td>
<td><input type='text' value='9'></td>
<td><input type='text' value='10'></td>
<td class='late'><input type='text' value='9'></td>
</tr>
</table>
</div>
<div class='controls'>
</div>
Image of issue:
Instead of using border: 1px solid gray you can try this.
td {
text-align: center;
border: 1px solid gray;
border-bottom: 0;
border-right: 0;
background-color: white
}
tr:last-of-type td {
border-bottom: 1px solid gray;
}
td:last-of-type {
border-right: 1px solid gray;
}
/* ------------{GRADEBOOK}------------ */
.gradebook {
position: absolute;
top: 60px;
left: 0;
width: 100vw;
height: calc(100vh - 126px);
overflow-y: scroll;
box-sizing: border-box;
}
/* Table styling*/
table {
table-layout: fixed;
border-collapse: collapse;
}
/* Table heading styling */
thead th {
height: 60px;
width: 100px;
top: 0;
z-index: 2;
position: -webkit-sticky;
position: sticky;
border-right: 1px solid gray;
background-color: white;
}
thead th:first-child {
left: 0;
z-index: 10;
}
th {
padding: 10px 16px;
text-align: left;
font-weight: normal;
color: gray
}
table .duedate {
font-size: 14px;
margin-bottom: 8px
}
table .title {
font-size: 18px;
color: #5B7042
}
/* Table data styling */
td {
text-align: center;
border: 1px solid gray;
border-bottom: 0;
border-right: 0;
background-color: white
}
tr:last-of-type td {
border-bottom: 1px solid gray;
}
td:last-of-type {
border-right: 1px solid gray;
}
td.late {
background-color: #EA5D6B
}
td input {
text-align: center;
padding: 4px;
margin: 0;
width: 114px;
border: none;
}
/* Student Name styling */
.student {
padding: 6px;
box-sizing: border-box;
display: flex;
align-items: center;
margin-bottom: -1px;
}
.pic {
display: inline-block;
width: 25px;
clip-path: circle();
margin-right: 10px;
}
.pic img {
display: none
}
/* ------------{CONTROLS}------------ */
.controls {
display: flex;
position: absolute;
bottom: 10px;
left: 0;
width: 100vw;
height: 56px;
border-top: 1px solid #DDDDDD
}
<link rel="stylesheet" href="../style.css">
<div class='gradebook'>
<table>
<thead>
<tr>
<th style='width: 200px'></th>
<th>
<div class='duedate'>Due Oct 08</div>
<div class='title'>Mayflower Vocabulary</div>
</th>
<th>
<div class='duedate'>Due Oct 15</div>
<div class='title'>Wax Museum</div>
</th>
<th>
<div class='duedate'>Due Oct 15</div>
<div class='title'>American Revolution</div>
</th>
<th>
<div class='duedate'>Due Oct 27</div>
<div class='title'>Jamestown</div>
</th>
<th>
<div class='duedate'>Due Nov 1</div>
<div class='title'>Comparing Colonies</div>
</th>
</tr>
</thead>
<tr>
<td class='student'>
<img class='pic' src='../pics/default.png'>
<span>Jane Doe</span>
</td>
<td><input type='text' value='-'></td>
<td class='late'><input type='text' value='10'></td>
<td><input type='text' value='9.5'></td>
<td><input type='text' value='10'></td>
<td><input type='text' value='5'></td>
</tr>
<tr>
<td class='student'>
<img class='pic' src='../pics/default.png'>
<span>John Doe</span>
</td>
<td><input type='text' value='-'></td>
<td><input type='text' value='8'></td>
<td><input type='text' value='9'></td>
<td><input type='text' value='10'></td>
<td class='late'><input type='text' value='9'></td>
</tr>
</table>
</div>
<div class='controls'>
</div>
My assumption is that problem arises from clashing between two layout alghorithms, table and flex one. Td belongs to table one and putting flex there just make problems.
So only solution is to wrap td content with div, and put flex onto that div.
table{
border-collapse: collapse;
}
td{
border: 1px solid;
}
.flex{
display: flex;
}
<!DOCTYPE html>
<html lang="en">
<body>
<table>
<th>flex</th>
<th>flex</th>
<tr>
<td class='flex'>...</td>
<td>...</td>
</tr>
<tr>
<td>...</td>
<td class='flex'>...</td>
</tr>
</table>
<table>
<th>div flex</th>
<th>div flex</th>
<tr>
<td> <div class='flex'>...</div></td>
<td> <div class='flex'>...</div></td>
</tr>
<tr>
<td> <div class='flex'>...</div></td>
<td> <div class='flex'>...</div></td>
</tr>
</table>
</body>
</html>

circular on border of table with text in that

i have big challenge in html css in create custom table
I have no idea in this case for create
I want create circular on vertical line of border
I create this table . but these to are very Different :-D
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
.container {
width: 100px;
height: 1px;
background-color: black;
position: relative;
}
.circle {
display: inline-block;
vertical-align: middle;
width: 40px;
height: 40px;
background-color: white;
border: solid 1px black;
border-radius: 50%;
position: absolute;
top: -6px;
left: calc(50% - 5px);
}
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td>
<div class="container">
<div class="circle">test</div>
</div>
</td>
<td>94</td>
</tr>
</table>
You are on right track just a little bit of changes in left and some padding on td
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 16px;
}
td{
padding-right: 22px;
}
.container {
position: relative;
}
.circle {
display: inline-block;
vertical-align: middle;
width: 40px;
height: 40px;
background-color: white;
border: solid 1px black;
border-radius: 50%;
position: absolute;
left: -38px;
top: 50%;
text-align: center;
line-height: 37px;
transform: translate(0%, -50%);
}
<html>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td><div class="container">
<div class="circle">
test
</div>
</div></td>
<td>94</td>
</tr>
<tr>
<td>Eve</td>
<td><div class="container">
<div class="circle">
test
</div>
</div></td>
<td>94</td>
</tr>
<tr>
<td>Eve</td>
<td><div class="container">
<div class="circle">
test
</div>
</div></td>
<td>94</td>
</tr>
</table>
</html>
this code
try that :
<html>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td style="width: 100px;height: 100px;"> <div class="row">
<div class="large-8 large-centered">
<div class="wrapper">
<div class="vertical-line"></div>
<div class="circle">
<h5>Some Text</h5>
</div>
<div class="vertical-line"></div>
</div>
</div>
</div>
</td>
<td>94</td>
</tr>
</table>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
.wrapper {
width: auto;
height: auto;
}
.circle {
width: 50px;
height: 50px;
border-style: solid;
border-color: #000000;
border-radius: 100px;
position: relative;
margin: 0 auto 0 auto;
}
h5 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
color: #000000;
}
.vertical-line {
width: 2px;
height: 100px;
background: #2ecc71;
margin: 0 auto 0 ;
}
hr {
border: 0;
height: 1px;
background: #333;
background: linear-gradient(to right, #ccc, #333, #ccc);
}
</style>
</html>
Make sure the container is of 100% and that left is correct:
<html>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td><div class="container">
<div class="circle">
test
</div>
</div></td>
<td>94</td>
</tr>
</table>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
.container {
width: 100%;
height: 1px;
background-color: black;
position: relative;
}
.circle {
display: inline-block;
vertical-align: middle;
width: 40px;
height: 40px;
background-color: white;
border: solid 1px black;
border-radius: 50%;
position: absolute;
top: -6px;
left: -20px;
}
</style>
</html>
How about something like this? Note that in order for this to work reliably, I gave your table row (the tr element) a fixed height.
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
tr {
height: 10px;
}
.firstRow {
position: relative;
background-color: red;
}
.circle {
position:absolute;
width: 40px;
height: 40px;
background-color: white;
border: solid 1px black;
border-radius: 50%;
top: -30px;
transform: translateX(-50%);
left: calc(100%);
}
.circleText {
text-align: center;
display: block;
left: 50%;
top: 20px;
transform: translateY(50%);
}
<html>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve
<div class="firstRow">
<div class="circle">
<div class="circleText">test</span>
</div>
</div>
</td>
<td>Eve's last name</td>
<td>94</td>
</tr>
</table>
</html>
I created a working demo. It is fully working.
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
.main-container{
display:flex;
width:100%;
}
.container {
display:flex;
justify-content: center;
flex-direction:column;
align-items:center;
flex:2;
}
.container:before, .container:after {
content: "";
background: #000;
width: 1px;
height: 20px;
}
.circle {
width: 40px;
height: 40px;
background-color: white;
border: solid 1px black;
border-radius: 50%;
display:flex;
justify-content: center;
align-items:center;
}
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td>
<div class="main-container">
<div style="flex:1">
<div>Monday</div>
<div>March 6, 2020</div>
<div>from Tokyo</div>
</div>
<div class="container">
<div class="circle">test</div>
</div>
<div>
<div>Monday</div>
<div>March 6, 2020</div>
<div>from Tokyo</div>
</div>
</div>
</td>
<td>94</td>
</tr>
</table>
The key lessons here are:
an extra relatively positioned element is not necessary for absolutely positioning the circle. we can just put the position: relative on the <td> itself.
use transform: translate() to position the circle elements without need for arbitrary pixel values
This solution uses the least CSS possible and standard (semantic) <table> markup
table {
border-collapse: collapse;
width: 100%;
}
td, th {
border: solid 1px #666;
padding: 2em 4em;
position: relative;
}
.circle {
font-size: 0.75em;
background: #fff;
border: solid 1px #aaa;
border-radius: 50%;
width: 4em;
height: 4em;
box-shadow: 1px 1px 4px #aaa;
display: flex;
align-items: center;
text-align: center;
justify-content: center;
position: absolute;
z-index: 1;
top: 50%;
right: 0;
transform: translate(50%, -50%);
}
<table>
<tr>
<td>XYZ</td>
<td>
MAR 2
<span class="circle">
10<br>Days
</span>
</td>
<td>MAR 11</td>
<td>9</td>
</tr>
<tr>
<td>ABC</td>
<td>
MAR 6
<span class="circle">
20<br>Days
</span>
</td>
<td>MAR 15</td>
<td>11</td>
</tr>
</table>
Codepen

Dynamic CSS border depends on number of contents

I'm not sure what is this called, and already searched it on google but doesnt found what I want,
but here is what I want to looks like
Can someone help me to achieve this? or maybe what is this called?
and if there are only 1 content, then no border at all
and, I'm using div not table tag
It's taken from codepen but modified as per your requirements.
page.html
<table class="table">
<tbody class="table-body">
<tr class="row">
<td class="cell"><span>Cool</span></td>
</tr>
</tbody>
</table>
<table class="table" style="margin-top:30px;">
<tbody class="table-body">
<tr class="row">
<td class="cell"><span>Cool</span></td>
<td class="cell"><span>Cool</span></td>
</tr>
</tbody>
</table>
<table class="table" style="margin-top:30px;">
<tbody class="table-body">
<tr class="row">
<td class="cell"><span>Cool</span></td>
<td class="cell"><span>Cool</span></td>
</tr>
<tr class="row">
<td class="cell"><span>Cool</span></td>
<td class="cell"><span>Cool</span></td>
</tr>
<tr class="row">
<td class="cell"><span>Cool</span></td>
</tr>
</tbody>
</table>
<table class="table" style="margin-top:30px;">
<tbody class="table-body">
<tr class="row">
<td class="cell"><span>Cool</span></td>
<td class="cell"><span>Cool</span></td>
</tr>
<tr class="row">
<td class="cell"><span>Cool</span></td>
<td class="cell"><span>Cool</span></td>
</tr>
</tbody>
</table>
page.css
.cell {
border-collapse: collapse;
border: 1px solid #000;
padding: 5px;
}
.cell span{
background-color: #000;
color: #fff;
display: block;
padding: 10px;
}
.table {
border-collapse: collapse;
border-style: hidden;
}
.table-head > .row {
border-collapse: collapse;
border: 2px solid pink;
}
See the screenshot
http://prnt.sc/pdptlg
try checking out this example, it shows a table with inner borders only, without the outer borders.
.cell {
border-collapse: collapse;
border: 1px solid pink;
padding: 5px 10px;
}
.table {
border-collapse: collapse;
border-style: hidden;
}
.table-head > .row {
border-collapse: collapse;
border: 2px solid pink;
}
<table class="table">
<tbody class="table-body">
<tr class="row">
<td class="cell">Cool</td>
<td class="cell">Cool</td>
</tr>
<tr class="row">
<td class="cell">Cool</td>
<td class="cell">Cool</td>
</tr>
</tbody>
</table>
Taken from https://codepen.io/sirinity/pen/dDsLx
One way only using pure css. Hope this help
.container {
display: flex;
flex-wrap: wrap;
width: 150px;
}
.wrapper {
width: 50px;
height: 50px;
padding: 5px;
border: 0 solid;
}
.content {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
color: white;
background-color: #030;
}
.wrapper:nth-of-type(odd) {
border-right-width: 1px;
}
.wrapper:nth-of-type(odd), .wrapper:nth-of-type(even) {
border-bottom-width: 1px;
}
.wrapper:last-child, .wrapper:nth-last-of-type(-n+2):not(:nth-child(even)) {
border-bottom-width: 0;
}
<div class="container">
<div class="wrapper"><div class="content">1</div></div>
<div class="wrapper"><div class="content">2</div></div>
<div class="wrapper"><div class="content">3</div></div>
<div class="wrapper"><div class="content">4</div></div>
<div class="wrapper"><div class="content">5</div></div>
<div class="wrapper"><div class="content">6</div></div>
<div class="wrapper"><div class="content">7</div></div>
</div>
You can do it with css pseudo-classes
More info here: Css pseudo-classes
Yout HTML dosnt change:
<table class="table">
<tbody class="table-body">
<tr class="row">
<td class="cell">Cool</td>
<td class="cell">Cool</td>
</tr>
<tr class="row">
<td class="cell">Cool</td>
<td class="cell">Cool</td>
</tr>
</tbody>
</table>
in css:
.table {
border-collapse: collapse;
border-style: hidden;
}
.cell {
padding: 5px 10px;
}
.row:nth-of-type(1n+1) {
border-bottom: 2px solid pink;
}
.cell:nth-of-type(2n-1) {
border-right: 2px solid pink;
}
Explanation:
Just skip first row to set top border:
.row:nth-of-type(1n+1) {
border-bottom: 2px solid pink;
}
and then, set border only to odd cells:
.cell:nth-of-type(2n-1) {
border-right: 2px solid pink;
}
Code here
Hope it helps you.
Edit: Sorry but i didnt notice that you are not using table tags, Hải Bùi response is the way for that, my css only works properly with tables.

full height of a div inside a table

Is it possible to align the following div's to be always on same position width and height on any webpage? I have try anything but I cannot manage to get it working. Something is not compatible in my code.
.content-box-gray .content {
overflow: hidden;
padding: 10px;
font-size: 15px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border: 1px solid gray;
color: #3385FF;
}
.content-box-gray .title {
height: 30px;
line-height: 30px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
background: gray;
font-size: 18px;
font-weight: bold;
font-family: verdana;
display: block;
color: white;
display: block;
padding: 10px;
border: 1px solid gray;
border-bottom: none;
}
<table width="100%" height="100%" border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td colspan="2" rowspan="3">
<div class="content-box-orange">
<div class="titleorange">3</div>
<div class="content">Lorem Ipsum is simply dummy text</div>
</div>
</td>
</tr>
<tr style="height:100% ">
<td style="background-color: aqua;height: 50%">1</td>
</tr>
<tr>
<td style="background-color: aqua;height: 50%">2</td>
</tr>
<tr>
<td colspan="3" style="background-color: #FFF">4</td>
</tr>
<tr>
<td style="background-color: #FFF">5</td>
<td colspan="2" rowspan="2">
<div class="content-box-gray">
<div class="title">7</div>
<div class="content">Lorem Ipsum</div>
</div>
</td>
</tr>
<tr>
<td style="background-color: #FFF">6</td>
</tr>
</tbody>
</table>
jsfiddle
I cannot manage to fix it.
here is a pic alignment of divs
thank you very much!
Give the td a height of 100%. Then use the calc property to set the height of .content-box-orange .content
fiddle
I think that you could explore flexbox instead of table for this layout. Update your question if you are open to that...
html,
body {
height: 98%;
background-color: #E5E5E3
}
table tbody tr td {
height: 100%;
}
.content-box-gray .content {
overflow: hidden;
padding: 10px;
font-size: 15px;
border: 0px;
color: #3385FF;
background: #FFFFFF;
}
.content-box-gray .title {
height: 30px;
line-height: 30px;
background: #F1F1F1;
font-size: 18px;
font-weight: bold;
font-family: verdana;
display: block;
color: #464648;
display: block;
padding: 10px;
border: 0px;
border-bottom: none;
}
.content-box-orange {
height: 100%;
}
.content-box-orange .content {
overflow: hidden;
padding: 10px;
font-size: 15px;
border: 0px;
color: #000;
background: #FFFFFF;
height: calc(100% - 66px);
}
.titleorange {
height: 30px;
line-height: 30px;
background: #F78D27;
font-size: 18px;
font-weight: bold;
font-family: verdana;
display: block;
color: #FFF;
display: block;
padding: 10px;
border: 0px;
border-bottom: none;
}
<table width="100%" height="100%" border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td colspan="2" rowspan="3">
<div class="content-box-orange">
<div class="titleorange">3</div>
<div class="content">Lorem Ipsum is simply dummy text</div>
</div>
</td>
</tr>
<tr style="height:100% ">
<td style="background-color: aqua;height: 50%">1</td>
</tr>
<tr>
<td style="background-color: aqua;height: 50%">2</td>
</tr>
<tr>
<td colspan="3" style="background-color: #FFF">4</td>
</tr>
<tr>
<td style="background-color: #FFF">5</td>
<td colspan="2" rowspan="2">
<div class="content-box-gray">
<div class="title">7</div>
<div class="content">Lorem Ipsum</div>
</div>
</td>
</tr>
<tr>
<td style="background-color: #FFF">6</td>
</tr>
</tbody>
</table>
Using Flexbox
Here is a rough guide to achieving the layout in your image using flexbox. Refer to caniuse for browser compatibility information. You can toggle properties in Chrome Dev tools to get an idea of how flexbox properties work if it's new to you.
fiddle
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
html {
height: 100%;
}
body {
background: #FFF;
font-family: sans-serif;
height: 100%;
margin: 0;
padding: 5px;
}
.box,
.main {
border: 5px solid #43c2eb;
}
.title--orange {
background: orange;
text-align: center;
padding: .4em;
margin: 0;
}
.wrapper {
display: flex;
flex-direction: column;
height: 100%;
}
.row {
display: flex;
min-height: 200px;
flex: 1 1 auto;
}
.box-wrap {
flex: 1 1 auto;
display: flex;
flex-direction: column;
}
.box {
margin: 5px;
display: flex;
flex-direction: column;
}
.box--big {
flex: 2 1 auto;
}
.box--small {
flex: 1 1 auto;
}
.main {
align-items: center;
justify-content: center;
margin: 5px;
}
.content {
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
font-size: 22px;
}
<div class="wrapper">
<div class="row upper">
<div class="box box--big">
<h1 class="title--orange">div header</h1>
<div class="content">
content
</div>
</div>
<div class="box-wrap">
<div class="box box--small">
<div class="content">content</div>
<h2 class="title--orange">div header</h2>
</div>
<div class="box box--small">
<div class="content">content</div>
<h2 class="title--orange">div header</h2>
</div>
</div>
</div>
<div class="row main">
<div class="main__inner">content</div>
</div>
<div class="row lower">
<div class="box-wrap">
<div class="box box--small">
<div class="content">content</div>
</div>
<div class="box box--small">
<div class="content">content</div>
</div>
</div>
<div class="box box--big">
<h1 class="title--orange">div header</h1>
<div class="content">
content
</div>
</div>
</div>
</div>
Remove style attributes and width,height attributes on your HTML code, no need it if you use CSS.
Also dont use % on Width y if you want a static table.
<table width="100%" height="100%" border="0" cellspacing="5" cellpadding="5">
<tr style="height:100% ">
<td style="background-color: aqua;height: 50%">1</td>
Give style="height:100%;overflow:hidden;" to outer div and style="height:100%;" to content & td
html,
body {
height: 98%;
background-color: #E5E5E3
}
.content-box-gray .content {
overflow: hidden;
padding: 10px;
font-size: 15px;
border: 0px;
color: #3385FF;
background: #FFFFFF;
}
.content-box-gray .title {
height: 30px;
line-height: 30px;
background: #F1F1F1;
font-size: 18px;
font-weight: bold;
font-family: verdana;
display: block;
color: #464648;
display: block;
padding: 10px;
border: 0px;
border-bottom: none;
}
.content-box-orange .content {
overflow: hidden;
padding: 10px;
font-size: 15px;
border: 0px;
color: #000;
background: #FFFFFF;
}
.titleorange {
height: 30px;
line-height: 30px;
background: #F78D27;
font-size: 18px;
font-weight: bold;
font-family: verdana;
display: block;
color: #FFF;
display: block;
padding: 10px;
border: 0px;
border-bottom: none;
}
<table border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td colspan="2" rowspan="3" style="height:100%;">
<div class="content-box-orange" style="height:100%;overflow:hidden;">
<div class="titleorange">3</div>
<div class="content" style="height:100%;">Lorem Ipsum is simply dummy text</div>
</div>
</td>
</tr>
<tr>
<td style="background-color: aqua;height: 50px">1</td>
</tr>
<tr>
<td style="background-color: aqua;height: 50px">2</td>
</tr>
<tr>
<td colspan="3" style="background-color: #FFF">4</td>
</tr>
<tr>
<td style="background-color: #FFF">5</td>
<td colspan="2" rowspan="2" style="height:100%;">
<div class="content-box-gray" style="height:100%;overflow:hidden;">
<div class="title">7</div>
<div class="content" style="height:100%;">Lorem Ipsum</div>
</div>
</td>
</tr>
<tr>
<td style="background-color: #FFF">6</td>
</tr>
</tbody>
</table>