How to display the below given data row wise? - html

How to change below html to required format as in below image when I get dynamic data?
<div id="pdfTable" #pdfTable style="display: none;">
<table class="table table-borderless mb-0" style="font-size:14px;margin-bottom: 15px;">
<thead>
<tr>
<td style="border:0"><b>Rating Scale: </b></td>
<td style="border:0" colspan="4"></td>
</tr>
<tr *ngFor='let rating of ratings'>
<td colspan="5" style="border:0"><b>{{rating.ratingId}}</b><span>.
</span><b>{{rating.ratingName}}</b></td>
</tr>
</thead>
</table>
</div>
Required Format
What I am getting from above html
Change html to format which is Shown in Required Format image dynamically.

Your current markup creates a new <tr> (table row) for each rating. But your design shows you want two cells:
one with "Rating Scale:"
one with the actual ratings.
In the second column, I used a CSS columns layout, with two columns.
The rest are details.
Template:
<div id="pdfTable" #pdfTable style="display: none">
<table
class="table table-borderless mb-0"
style="font-size: 14px; margin-bottom: 15px"
>
<tbody>
<tr>
<td>Rating Scale:</td>
<td>
<div class="ratings">
<div *ngFor="let rating of ratings">
<div>{{ rating.ratingName }}.</div>
<div>{{ rating.ratingName }}</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
SCSS:
#pdfTable {
border: 2px solid black;
td {
border: none;
font-weight: bold;
&:first-child {
vertical-align: top;
white-space: nowrap;
}
}
.ratings {
columns: 2;
& > div {
font-weight: bold;
break-inside: avoid;
display: flex;
& > div:first-child {
flex: 0 0 2rem;
text-align: right;
padding-right: 0.5rem;
}
& > div:last-child {
flex-grow: 1;
}
}
}
}
You might need to tweak the CSS a bit in terms of margins/paddings, according to your project.
Rough demo of the output (just the HTML and CSS, no angular):
#pdfTable {
border: 2px solid black;
font-size: 14px;
}
#pdfTable td {
border: none;
font-weight: bold;
}
#pdfTable td:first-child {
vertical-align: top;
white-space: nowrap;
}
#pdfTable .ratings {
columns: 2;
}
#pdfTable .ratings > div {
font-weight: bold;
break-inside: avoid;
display: flex;
}
#pdfTable .ratings > div > div:first-child {
flex: 0 0 2rem;
text-align: right;
padding-right: 0.5rem;
}
#pdfTable .ratings > div > div:last-child {
flex-grow: 1;
}
<div id="pdfTable" #pdfTable>
<table>
<tbody>
<tr>
<td>Rating Scale:</td>
<td>
<div class="ratings">
<div>
<div>5.</div>
<div>Outstanding</div>
</div>
<div>
<div>4.</div>
<div>Excellent-exceeds expectations</div>
</div>
<div>
<div>3.</div>
<div>Competent-acceptable proficiency</div>
</div>
<div>
<div>2.</div>
<div>Below average - does not meet requirements</div>
</div>
<div>
<div>1.</div>
<div>Unable to determine or not applicable to this candidate</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>

Related

Image confined to element is cut off even though z-index is larger

I have a page that generates a table from an API request. Part of this is an image of the item, which I have created an icon which when the user hovers over, it displays the image for that row. I may have misunderstood how z-index works, but I have set the image z-index to 99 and it still it getting cut off because the element the table sits in is too small.
/* Card Large */
#sets-individual-page .background .card-large {
background-color: #283046;
border-radius: .4rem;
display: block;
position: relative;
margin-bottom: 1rem;
padding: 1rem;
overflow: auto;
}
/* Tables */
#sets-individual-page .background .box-table {
margin-bottom: 2rem;
}
#sets-individual-page .background .table {
color: #fff !important;
font-size: .8rem;
border-spacing: 2px;
}
#sets-individual-page .background tr {
min-height: 2rem;
}
#sets-individual-page .background th,
#sets-individual-page .background td {
padding: .3rem .5rem .2rem .5rem !important;
vertical-align: middle;
}
#sets-individual-page .background tr .standard > div,
#sets-individual-page .background tr .foil > div {
display: inline;
padding-right: .75rem;
margin: 0;
}
#sets-individual-page .background tr .standard .btn-icon,
#sets-individual-page .background tr .foil .btn-icon,
#sets-individual-page .background tr .standard .btn-icon .icon,
#sets-individual-page .background tr .foil .btn-icon .icon {
margin: 0 .2rem;
text-align: center;
}
#sets-individual-page .background tr .standard input,
#sets-individual-page .background tr .foil input {
height: 1.25rem;
width: 2.5rem;
margin: 0;
text-align: right;
}
#sets-individual-page .background .table-hover tbody tr:hover td,
#sets-individual-page .background .table-hover tbody tr:hover th {
color: #f6f6f6;
background-color: #161d31;
}
#sets-individual-page .background .icon,
#sets-individual-page .background .symbol {
width: 1rem;
height: 1rem;
margin-right: .3rem;
margin-bottom: .1rem;
}
/* MTG Card Images */
#sets-individual-page .background .large {
position: absolute;
display: none;
left: 20%;
top: 15%;
}
#sets-individual-page .background .btn-icon:hover + .large {
display: block;
z-index: 999 !important;
}
#sets-individual-page .background .large-image {
position: absolute;
border-radius: 1rem;
z-index: 999 !important;
width: 18.75rem;
height: 26.125rem;
}
<div class="card-large">
<h4 class="">Cards</h4>
<table class="table table-hover table-sm text-nowrap">
<thead>
<tr>
<th scope="col" style="width: 03%;" class="text-end">
<h5>#</h5>
</th>
<th scope="col" style="width: 25%;" class="">
<h5>Name</h5>
</th>
<th scope="col" style="width: 15%;" class="">
<h5>Type</h5>
</th>
<th scope="col" style="width: 07%;" class="">
<h5>Rarity</h5>
</th>
<th scope="col" style="width: 10%;" class="">
<h5>Mana Cost</h5>
</th>
</tr>
</thead>
<tbody id="card-listings">
<tr>
<td class="text-end">1</td>
<td class="">
<span class="btn-icon btn-icon-primary">
<img class="icon" src="/static/img/icons/image.png">
</span>
<span class="large">
<img class="large-image" src="https://c1.scryfall.com/file/scryfall-cards/normal/front/c/7/c7bbb911-9de2-455d-9677-e1004db65dbd.jpg?1593559500" height="500">
</span>
Chandra, Torch of Defiance
</td>
<td class="">Legendary Planeswalker — Chandra</td>
<td class="">Mythic</td>
<td class="">
<img class="symbol" src="/static/img/symbology/2.png">
<img class="symbol" src="/static/img/symbology/R.png">
<img class="symbol" src="/static/img/symbology/R.png">
</td>
</tr>
<tr>
<td class="text-end">2</td>
<td class="">
<span class="btn-icon btn-icon-primary">
<img class="icon" src="/static/img/icons/image.png">
</span>
<span class="large">
<img class="large-image" src="https://c1.scryfall.com/file/scryfall-cards/normal/front/8/c/8c1a02f9-3ce7-46e9-8d0e-0d491bb13012.jpg?1593559582" height="500">
</span>
Cathartic Reunion
</td>
<td class="">Sorcery</td>
<td class="">Rare</td>
<td class="">
<img class="symbol" src="/static/img/symbology/1.png">
<img class="symbol" src="/static/img/symbology/R.png">
</td>
</tr>
...
</tbody>
</table>
</div>
screenshot
EDIT:
added html of card element
added css of card element
The reason why your card image isn't appearing at the top of stack and above the <div class="card-large"> container like you expect when giving it the highest z-index value is because the <img> elements are absolutely positioned relative to the parent .card-large. Since the images are absolutely positioned relative to the parent div, they are essentially constrained to that content box.
If you nest your .card-large container in its own parent <div> and give the new parent position: relative, your images will appear at the top of stacking context when the .icon images are hovered and display above the .card-large container like expected.
/* Card Large */
.wrapper {
position: relative;
}
.card-large {
background-color: #283046;
border-radius: .4rem;
display: block;
margin-bottom: 1rem;
padding: 1rem;
overflow: auto;
color: #fff;
}
.card-large > h4 {
color: #eee;
font-size: 1.3em;
margin: 0;
}
/* Tables */
#sets-individual-page .background .box-table {
margin-bottom: 2rem;
}
.table {
color: #fff !important;
font-size: .8rem;
border-spacing: 2px;
}
.table tr {
min-height: 2rem;
}
.table th,
.table td {
padding: .3rem .5rem .2rem .5rem !important;
vertical-align: middle;
}
.table tr .standard > div,
.table tr .foil > div {
display: inline;
padding-right: .75rem;
margin: 0;
}
#sets-individual-page .background tr .standard .btn-icon,
#sets-individual-page .background tr .foil .btn-icon,
#sets-individual-page .background tr .standard .btn-icon .icon,
#sets-individual-page .background tr .foil .btn-icon .icon {
margin: 0 .2rem;
text-align: center;
}
.table tr .standard input,
.table tr .foil input {
height: 1.25rem;
width: 2.5rem;
margin: 0;
text-align: right;
}
.table-hover tbody tr:hover td,
.background .table-hover tbody tr:hover th {
color: #f6f6f6;
background-color: #161d31;
}
.table .icon,
.table .symbol {
width: 1rem;
height: 1rem;
margin-right: .3rem;
margin-bottom: .1rem;
}
/* MTG Card Images */
.large {
position: absolute;
display: none;
left: 20%;
top: 15%;
}
.btn-icon:hover + .large {
display: block;
z-index: 999;
}
.large-image {
position: absolute;
border-radius: 1rem;
z-index: 999;
width: 18.75rem;
height: 26.125rem;
}
<div class="wrapper">
<div class="card-large">
<h4>Cards</h4>
<table class="table table-hover table-sm text-nowrap">
<thead>
<tr>
<th scope="col" style="width: 03%;" class="text-end">
<h5>#</h5>
</th>
<th scope="col" style="width: 25%;" class="">
<h5>Name</h5>
</th>
<th scope="col" style="width: 15%;" class="">
<h5>Type</h5>
</th>
<th scope="col" style="width: 07%;" class="">
<h5>Rarity</h5>
</th>
<th scope="col" style="width: 10%;" class="">
<h5>Mana Cost</h5>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-end">1</td>
<td class="">
<span class="btn-icon btn-icon-primary">
🖼️
<img class="icon" src="/static/img/icons/image.png">
</span>
Chandra, Torch of Defiance
<span class="large">
<img class="large-image" src="https://c1.scryfall.com/file/scryfall-cards/normal/front/c/7/c7bbb911-9de2-455d-9677-e1004db65dbd.jpg?1593559500" height="500">
</span>
Chandra, Torch of Defiance
</td>
<td class="">Legendary Planeswalker — Chandra</td>
<td class="">Mythic</td>
<td class="">
<img class="symbol" src="/static/img/symbology/2.png">
<img class="symbol" src="/static/img/symbology/R.png">
<img class="symbol" src="/static/img/symbology/R.png">
</td>
</tr>
<tr>
<td class="text-end">2</td>
<td class="">
<span class="btn-icon btn-icon-primary">
🖼️
<img class="icon" src="/static/img/icons/image.png">
</span>
<span class="large">
<img class="large-image" src="https://c1.scryfall.com/file/scryfall-cards/normal/front/8/c/8c1a02f9-3ce7-46e9-8d0e-0d491bb13012.jpg?1593559582" height="500">
</span>
Cathartic Reunion
</td>
<td class="">Sorcery</td>
<td class="">Rare</td>
<td class="">
<img class="symbol" src="/static/img/symbology/1.png">
<img class="symbol" src="/static/img/symbology/R.png">
</td>
</td>
</tr>
<tr>
<td class="text-end">3</td>
<td class="">
<span class="btn-icon btn-icon-primary">
🖼️
<img class="icon" src="/static/img/icons/image.png">
</span>
Chandra, Torch of Defiance
<span class="large">
<img class="large-image" src="https://c1.scryfall.com/file/scryfall-cards/normal/front/c/7/c7bbb911-9de2-455d-9677-e1004db65dbd.jpg?1593559500" height="500">
</span>
Chandra, Torch of Defiance
</td>
<td class="">Legendary Planeswalker — Chandra</td>
<td class="">Mythic</td>
<td class="">
<img class="symbol" src="/static/img/symbology/2.png">
<img class="symbol" src="/static/img/symbology/R.png">
<img class="symbol" src="/static/img/symbology/R.png">
</td>
</tr>
</tbody>
</table>
</div>
</div>
Could you try display: flow-root; instead of "block" in the .btn-icon:hover + .large{} selector ?
Flow-root display creates a new block formating context that may allow the large-images to overflow the whole table. It is mostly used as a clearfix method and I don't know if it works on table elements, but it's worth giving it a try.

how to put row onto another one? / CSS

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>

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>

How to horizontally align div element to another div?

I create the following HTML page and I would align the two DIV elements (the ones with lista and scheda id, contained within parent div) to the same position, at the top of the page. Here is my code:
#tabella1,
#tabella1 td {
border: solid 1px;
}
th {
border: solid 1px;
font-style: bold;
background-color: white;
}
#tabella1 tr:nth-child(odd) {
background-color: gray;
}
#tabella1 tr:nth-child(even) {
background-color: lightgray;
}
#tabella1 tr:nth-child(n):not(:nth-child(1)):hover {
background-color: blue;
color: yellow;
cursor: pointer;
}
.titolo {
text-align: center;
font-weight: bold;
}
#lista {
display: inline-block;
margin: 30px;
position: relative;
top: 0px;
}
button {
width: 60px;
height: 20px;
}
form {
display: inline-block;
}
#msg {
font-weight: bold;
}
#scheda {
display: inline-block;
position: relative;
top: 0px;
text-align: center;
}
#tabella2 td:nth-child(even) {
border: solid 1px;
}
.cellaVuota {
width: 140px;
}
<div id="carica">
<form method="post" action="carica2.php">
<label for "n">Inserisci nome:
<input type="text" id="n" name="nome" size="10" />
</label>
<button type="submit">Invia</button>
</form>
<form method="post" action="carica2.php">
<button type="submit" name="logout">Logout</button>
</form>
</div>
<div id="parent">
<div id="lista">
<table id="tabella1">
<tr>
<th>Modello</th>
<th>27.5</th>
<th>29</th>
</tr>
<tr>
<td>Riga 1</td>
<td>Riga 2</td>
<td>Riga 3</td>
</tr>
</table>
<p class="titolo">Bici Mountain Bike</p>
</div>
<div id="scheda">
<p class="titolo">Bici selezionata</p>
<table id="tabella2">
<tr>
<td>Modello</td>
<td class="cellaVuota"></td>
</tr>
<tr>
<td>Misura 27.5</td>
<td class="cellaVuota"></td>
</tr>
<tr>
<td>Misura 29</td>
<td class="cellaVuota"></td>
</tr>
</table>
</div>
</div>
I searched and searched here before post this question (see position and ~top` properties in the CSS code), but I do not figure out how to reach my purpose.
Just add vertical-align: top; to both divs.
You can also remove position: relative; and top: 0; properties

Pixel & Percent in a HTML-Table

I'm working on a stats table for soccer(Football) games.
The table consists of the following columns (from left to right):
icon
text (what happend)
minute
text (what happend)
icon
The icon & minute columns should have a static with (50px & 80px). The text columns should be variable in width.
Now to the tricky part... if the table has a text column with content and one without in the same row the minute column isn't centered anymore. See:
That's how it should look like:
Here is the code:
<table class="table-comparison">
<thead>
<th colspan="5">
Wechsel
</th>
</thead>
<tbody>
<tr>
<td class="column-action"><i class="icon-rotate-left"></i></td>
<td class="column-text text-right">
<i class="icon-caret-right color-green"></i> Sradan Lakic für <i class="icon-caret-right color-red-light"></i> Stefan Aigner
</td>
<td class="column-center" data-toggle="move:insertBefore" data-target="$el.parent().find('td:first-child')">46'</td>
<td class="column-text">
<div>
<i class="icon-caret-right color-green"></i> Mario Götze für <i class="icon-caret-right color-red-light"></i> Toni Kroos
</div>
<div>
<i class="icon-caret-right color-green"></i> Emre Can für <i class="icon-caret-right color-red-light"></i> Thiago Alcantara
</div>
</td>
<td class="column-action"><i class="icon-rotate-left"></i></td>
</tr>
<tr>
<td class="column-action"><i class="icon-rotate-left"></i></td>
<td class="column-text text-right">
<i class="icon-caret-right color-green"></i> Sebastion Jung für <i class="icon-caret-right color-red-light"></i> Marco Russ
</td>
<td class="column-center" data-toggle="move:insertBefore" data-target="$el.parent().find('td:first-child')">88'</td>
<td class="column-text"></td>
<td class="column-action"></td>
</tr>
</tbody>
</table>
and the css:
// ------------------------------
.table-comparison {
color: #black;
width: 100%;
th, td {
padding: 10px 0;
}
th {
.interstate;
.uppercase;
color: #black;
font-size: 14px;
padding-top: 0;
padding-bottom: 15px;
#media #tablet {
padding-bottom: 35px;
text-align: center;
}
}
.column-action {
padding-left: 20px;
padding-right: 20px;
text-align: center;
width: 20px;
#media #phone {
display: none;
}
}
.column-text {
padding-left: 20px;
padding-right: 20px;
#media #phone {
display: block;
height: auto;
text-align: left;
width: 100%;
}
}
.column-center {
.interstate;
text-align: center;
width: 80px;
#media #phone {
display: block;
height: auto;
padding-left: 20px;
text-align: left;
width: 100%;
}
#media #tablet {
border-left: 1px solid #grey-medium;
border-right: 1px solid #grey-medium;
}
}
// stripe that shit down
// stripe down the tables
> tbody > tr:nth-child(even) > td,
> tbody > tr:nth-child(even) > th {
background-color: #f7f7f7;
}
> tbody > tr:nth-child(odd) > td,
> tbody > tr:nth-child(odd) > th {
background-color: transparent;
}
}
use table-layout:fixed; that way, the column that did't get specific width, will 'divide' the rest of the width evenly between them.
Working Fiddle
CSS
.table-comparison
{
width: 100%;
table-layout: fixed;
}
.iconColumn
{
width: 50px; /*fixed width*/
}
.textColumn
{
/*you dont have to fix the width*/
}
.minuteColumn
{
width: 80px; /*fixed width*/
}
/* this part is taken from gvee's solution*/
.table-comparison tr td:first-child, .table-comparison tr td:last-child {
color: red;
background-color: #ddd;
text-align: center;
}
.table-comparison tr td:nth-child(3) {
background-color: lime;
text-align: center;
}
HTML
<table class="table-comparison">
<thead>
<th class='iconColumn'></th>
<th class='textColumn'></th>
<th class='minuteColumn'></th>
<th class='textColumn'></th>
<th class='iconColumn'></th>
</thead>
<tbody>
<tr>
<td><i>i</i></td>
<td></td>
<td>46'</td>
<td>
<div> <i>G</i>Mario Götze für<i>R</i>Toni Kroos</div>
<div> <i>G</i> Emre Can für <i>R</i> Thiago Alcantara</div>
</td>
<td><i>i</i>
</td>
</tr>
<tr>
<td><i>i</i>
</td>
<td></td>
<td>88'</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>