I'm trying to figure out how to emulate this image using HTML and CSS. It will be something that will be displayed below the avatar on a message board.
This is what I have so far: https://jsfiddle.net/J7VBV/220/
table.avatarStats {
border-spacing: 0;
border-collapse: collapse;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
<table class="avatarStats" width="200" border="0">
<tr>
<td bgcolor="purple">RECENT WR<br /><strong>61%</strong></td>
<td bgcolor="teal">OVERALL<br /><strong>55%</strong></td>
</tr>
<tr>
<td bgcolor="purple">RECENT WN8<br /><strong>2469</strong></td>
<td bgcolor="teal">OVERALL<br /><strong>1737</strong></td>
</tr>
</table>
The main problem I'm having is decreasing the size of the text above the numbers. Nothing I've tried is making the text smaller.
Also, is there a better way of bolding the numbers?
Use this
table.avatarStats {
border-spacing: 0;
border-collapse: collapse;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
td small{
font-size:7pt;
font-weight:bold;
}
td strong{
font-size:18pt;
font-weight:bold;
}
<table class="avatarStats" width="200" border="0">
<tr>
<td bgcolor="purple"><small>RECENT WR</small><br /><strong>61%</strong></td>
<td bgcolor="teal"><small>OVERALL</small><br /><strong>55%</strong></td>
</tr>
<tr>
<td bgcolor="purple"><small>RECENT WN8</small><br /><strong>2469</strong></td>
<td bgcolor="teal"><dev font-size: 10pt;><small>OVERALL</small><br /><strong>1737</strong></td>
</tr>
</table>
You can use CSS to make the font smaller.
font-size: 10pt;
Just replace 10pt with whatever size you want to use.
I would use a CSS class like:
.small {
font-size: 10pt;
}
and add
class="small"
to the text you want to be small
You can do like this.
table.avatarStats {
border-spacing: 0;
border-collapse: collapse;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
.cap{
font-size:8px;
font-weight:normal;
}
td{
font-weight:bold;
font-size:22px
}
<table class="avatarStats" width="200" border="0">
<tr>
<td bgcolor="purple"><span class="cap">RECENT WR</span><br /><strong>61%</strong></td>
<td bgcolor="teal"><span class="cap">OVERALL</span><br /><strong>55%</strong></td>
</tr>
<tr>
<td bgcolor="purple"><span class="cap">RECENT WN8</span><br /><strong>2469</strong></td>
<td bgcolor="teal"><span class="cap">OVERALL</span><br /><strong>1737</strong></td>
</tr>
</table>
Adjust the font-size accordingly as needed
try this https://jsfiddle.net/fd9x06jq/
table.avatarStats tr td strong{
font-size:9pt;
font-weight:bold;
color:black
}
Although I'd advise some changes to your markup, add this to you CSS:
table tr td:last-child{
font-size: 8pt;
}
EDIT:
My first code was off. Now it's correct. Here's a fiddle
Updated your code here: https://jsfiddle.net/70gtky65/1/
<table class="avatarStats">
<tr>
<td>RECENT WR<br/><span>61%</span></td>
<td>OVERALL<br/><span>55%</span></td>
</tr>
<tr>
<td>RECENT WN8<br/><span>2469</span></td>
<td>OVERALL<br/><span>1737</span></td>
</tr>
</table>
<style type="text/css">
table.avatarStats {
border-spacing: 0px;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
width: 108px;
}
table.avatarStats td {
font-size: 7px;
width: 50px;
padding: 2px;
}
table.avatarStats td span {
font-size: 16px;
}
table tr td:first-child {
background-color: #7842B3;
}
table tr td:last-child {
background-color: #459ABD;
}
</style>
You should try to avoid inline CSS and here is why
Related
I have this tiny web page:
This is the source code:
<head>
<meta charset="UTF-8">
<style>
body {
margin-left: 20px;
margin-top: 20px;
}
h1 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h2 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h3 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h4 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h5 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h6 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
hr {
height: 3px;
border-radius: 2px;
border-width: 0;
color: lightgray;
background-color: lightgray;
}
.button {
display: inline-block;
background-color: darkgray;
color: white;
text-decoration: none;
border-radius: 2px;
padding: 6px;
margin-left: 2px;
margin-right: 2px;
}
.button:hover {
color: black;
}
.button:visited {
color: white;
}
.button:active {
color: white;
}
a {
color: gray;
}
</style>
</head>
<body nyxt-identifier="0">
<style nyxt-identifier="1">
body {
margin-left: 20px;
margin-top: 20px;
}
h1 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h2 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h3 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h4 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h5 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h6 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
hr {
height: 3px;
border-radius: 2px;
border-width: 0;
color: lightgray;
background-color: lightgray;
}
.button {
display: inline-block;
background-color: darkgray;
color: white;
text-decoration: none;
border-radius: 2px;
padding: 6px;
margin-left: 2px;
margin-right: 2px;
}
.button:hover {
color: black;
}
.button:visited {
color: white;
}
.button:active {
color: white;
}
a {
color: gray;
}
</style>
<h1 nyxt-identifier="2">Bindings</h1>
<p nyxt-identifier="3">
</p>
<div nyxt-identifier="4">
<h3 nyxt-identifier="5">override-map</h3>
<table nyxt-identifier="6">
<tbody nyxt-identifier="7">
<tr nyxt-identifier="8">
<td nyxt-identifier="9">C-S
</td>
<td nyxt-identifier="10">search-buffers
</td>
</tr>
<tr nyxt-identifier="11">
</td>
</tr>
</tbody>
</table>
</div>
<div nyxt-identifier="44">
<h3 nyxt-identifier="45">web-cua-map</h3>
<table nyxt-identifier="46">
<tbody nyxt-identifier="47">
<tr nyxt-identifier="48">
<td nyxt-identifier="49">f3
</td>
<td nyxt-identifier="50">search-buffer
</td>
</tr>
<tr nyxt-identifier="51">
</td>
</tr>
</tbody>
</table>
</div>
<div nyxt-identifier="195">
<h3 nyxt-identifier="196">base-cua-map</h3>
<table nyxt-identifier="197">
<tbody nyxt-identifier="198">
<tr nyxt-identifier="199">
<td nyxt-identifier="200">f5
</td>
<td nyxt-identifier="201">reload-current-buffer
</td>
</tr>
<tr nyxt-identifier="202">
</td>
</tr>
</tbody>
</table>
</div>
</body>
The code and image above are a simplification of the real problem. In the real problem, the page is way bigger because the table has more elements than the currently shown.
I would like to use the space in a better way so that printing it would not spend too much paper. There is a lot of space being wasted on the right side of the screen.
The content could be more widespread horizontally instead of only vertically.
Two feasible approaches to achieve this goal would be (i) reducing the font-size, and (ii) making the table be a 2 column-table or 3-column instead of 1-column.
OK. I can reduce the font-size with CSS:
tr { font-size: 10px}
Thus, I would like to ask:
1 - How to make the table be 3-column or 2-column table using CSS?
I tried this approach following the example on W3C:
table {
column-span: all;
}
But it did not work out.
2 - Would you have any suggestions beyond the font and column number tweak to maximize the use of space and reduce the use of paper?
This is not complicated at all. You just have to put all the key bindings and headings in one table instead of each in it's own. Then, we use a little bit of CSS to get a small border line between the table cells - just remove the CSS part if you don't want a border. Like this:
table {
border-spacing: 0;
}
td {
border: 1px solid black;
padding: 10px;
}
<h1>Bindings</h1>
<table>
<tbody>
<tr>
<td colspan="2">
override-map
</td>
<td colspan="2">
web-cua-map
</td>
<td colspan="2">
base-cua-map
</td>
</tr>
<tr>
<td>
C-S
</td>
<td>
search-buffers
</td>
<td>
F3
</td>
<td>
search-buffer
</td>
<td>
F5
</td>
<td>
reload-current-buffer
</td>
</tr>
</tbody>
</table>
I have a problem while creating a table, I want to change the text color depending on certain conditions, but the cell border becomesthe same color as my text for some reasons.
Here is the code
.tg {
border-collapse: collapse;
border-spacing: 0;
}
.tg td {
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
}
.tg th {
font-family: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
}
.tg .tg-baqh {
text-align: center;
vertical-align: top
}
.tg .tg-edkd {
color: #9a0000;
text-align: center;
vertical-align: top
}
.tg .tg-kxdw {
font-weight: bold;
background-color: #036400;
color: #ecf4ff;
text-align: center;
vertical-align: top
}
.tg .tg-24w0 {
font-weight: bold;
font-size: 22px;
background-color: #ffffff;
text-align: center;
vertical-align: top
}
.tg .tg-9ewa {
color: #fe0000;
text-align: center;
vertical-align: top
}
.tg .tg-yw4l {
vertical-align: top
}
.tg .tg-cd3k {
font-weight: bold;
background-color: #036400;
color: #ffffff;
text-align: center;
vertical-align: top
}
.tg .tg-zlvv {
color: #3531ff;
text-align: center;
vertical-align: top
}
<table class="tg">
<tr>
<th class="tg-24w0" colspan="6">Nomenclature de Nomenclature, OF054453, OF054581, OF054600, OF054395, OF054063,</th>
</tr>
<tr>
<td class="tg-kxdw">Action</td>
<td class="tg-kxdw">Poste</td>
<td class="tg-kxdw">Pièce</td>
<td class="tg-kxdw">Description</td>
<td class="tg-kxdw">Quantité initiale ? Nouvelle quantité</td>
<td class="tg-kxdw">Code lien procédure</td>
</tr>
<tr>
<td class="tg-9ewa">Retirer</td>
<td class="tg-baqh">4000</td>
<td class="tg-baqh">TJA1050TD-T</td>
<td class="tg-baqh">CI COM H-SPEED CAN TX SO8 SMT</td>
<td class="tg-edkd">1 ? 0</td>
<td class="tg-baqh">PM120</td>
</tr>
<tr>
<td class="tg-yw4l" colspan="6">Commentaire Ligne : </td>
</tr>
<tr>
<td class="tg-yw4l" colspan="6">Remarques : </td>
</tr>
</table>
Use secund attribute:
<style>
table {
border-collapse: collapse;
}
.tg {
font-weight: bold;
text-align: center;
padding: 6px 12px;
border: 1px solid #333;
}
.red {
color: red;
}
.green {
color: green;
}
</style>
<table>
<tr>
<td class="tg">Text 1</td>
<td class="tg red">Text 2</td>
<td class="tg green">Text 3</td>
</tr>
</table>
Specify a border color together with your border width and style on .tg td like in this edited snippet:
.tg {
border-collapse: collapse;
border-spacing: 0;
}
.tg td {
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 5px;
border: 1px solid #000;
overflow: hidden;
word-break: normal;
}
.tg th {
font-family: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
}
.tg .tg-baqh {
text-align: center;
vertical-align: top
}
.tg .tg-edkd {
color: #9a0000;
text-align: center;
vertical-align: top
}
.tg .tg-kxdw {
font-weight: bold;
background-color: #036400;
color: #ecf4ff;
text-align: center;
vertical-align: top
}
.tg .tg-24w0 {
font-weight: bold;
font-size: 22px;
background-color: #ffffff;
text-align: center;
vertical-align: top
}
.tg .tg-9ewa {
color: #fe0000;
text-align: center;
vertical-align: top
}
.tg .tg-yw4l {
vertical-align: top
}
.tg .tg-cd3k {
font-weight: bold;
background-color: #036400;
color: #ffffff;
text-align: center;
vertical-align: top
}
.tg .tg-zlvv {
color: #3531ff;
text-align: center;
vertical-align: top
}
<table class="tg">
<tr>
<th class="tg-24w0" colspan="6">Nomenclature de Nomenclature, OF054453, OF054581, OF054600, OF054395, OF054063,</th>
</tr>
<tr>
<td class="tg-kxdw">Action</td>
<td class="tg-kxdw">Poste</td>
<td class="tg-kxdw">Pièce</td>
<td class="tg-kxdw">Description</td>
<td class="tg-kxdw">Quantité initiale ? Nouvelle quantité</td>
<td class="tg-kxdw">Code lien procédure</td>
</tr>
<tr>
<td class="tg-9ewa">Retirer</td>
<td class="tg-baqh">4000</td>
<td class="tg-baqh">TJA1050TD-T</td>
<td class="tg-baqh">CI COM H-SPEED CAN TX SO8 SMT</td>
<td class="tg-edkd">1 ? 0</td>
<td class="tg-baqh">PM120</td>
</tr>
<tr>
<td class="tg-yw4l" colspan="6">Commentaire Ligne : </td>
</tr>
<tr>
<td class="tg-yw4l" colspan="6">Remarques : </td>
</tr>
</table>
The color CSS property sets the foreground color value of an element's text content and text decorations. It also sets the currentcolor value, which may be used as an indirect value on other properties, and is the default for other color properties, such as border-color. Ref
To solve this problem just add border-color property to .tg td as below:
.tg td {
border-color:black;
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
}
Please help, I can't figure out how to get rid of this border underline. It's nowhere to be found in Chrome's Inspect. I've tried everything I could find in the forums but no luck so far.
I'm unable to reproduce it using a fiddle, but here's the live site
HTML
<table class="table table-1" border="0" cellpadding="0" cellspacing="0">
<tr>
<th class="table-header cell-left">Actives</th>
<th class="table-header cell-right">Percentage (%)</th>
</tr>
<tr>
<td class="table-data cell-left">Caster Oil</td>
<td class="table-data cell-right">25</td>
</tr>
<tr>
<td class="table-data cell-left">Peppermint Oil</td>
<td class="table-data cell-right">0.5</td>
</tr>
<tr>
<td class="table-data cell-left">Cinnamon Oil</td>
<td class="table-data cell-right">0.25</td>
</tr>
</table>
CSS
.table {
color: $Blue;
border: none;
border-collapse: collapse;
border-spacing: 0;
background-color: white;
}
th {
font-family: 'PPsans', Fallback, sans-serif;
font-size: 15px;
text-transform: uppercase;
}
td {
font-family: 'Open Sans', sans-serif;
font-size: 14px;
text-transform: capitalize;
padding: 5px 0;
}
.cell-right {text-align:right;}
.cell-left {text-align: left;}
You have tr:first-child th:after, tr:first-child td:after with border-bottom: 1px solid #1c1d1d; which creates that border.
You can override this using:
tr:first-child th:after, tr:first-child td:after {
border: none;
}
Make sure this goes after the previous code (or edit the original css file).
tr:first-child th:after, tr:first-child td:after{
border-bottom: none !important;
}
if you have custom css file then use !important
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<style type="text/css">
.table {
border-collapse: collapse;
border-spacing: 0;
}
.table td {
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 20px;
border-style: solid;
border-width: 2px;
}
.table th {
font-family: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
padding: 10px 20px;
border-style: solid;
border-width: 2px;
}
.table .tg-1 {
text-align: center;
}
.table .tg-2 {
font-weight: bold;
background-color: #c0c0c0;
text-align: center;
}
</style>
<table class="table">
<tr>
<th class="tg-2">Animal Name</th>
<th class="tg-2">Picture</th>
</tr>
<tr>
<td class="tg-1">Cat</td>
<td rowspan="3"></td>
</tr>
<td class="tg-1">Dog</td>
</tr>
<tr>
<td class="tg-1">Horse</td>
</tr>
</table>
</body>
</html>
<br>
I have created the above table with hyperlinks, the hyperlinks are opening in the same window/tab however I would like to open them in the blank column of my table.
Can you please offer some help?
How do I set the target of the hyperlink to the second column of the table?
Using just HTML (and CSS) without client-side scripting, you would need to put an iframe element into the second column and make the links open in that iframe. (With scripting, you could alternatively just change the src attribute of an img element placed in the second column.)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<style type="text/css">
.table {
border-collapse: collapse;
border-spacing: 0;
}
.table td {
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 20px;
border-style: solid;
border-width: 2px;
}
.table th {
font-family: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
padding: 10px 20px;
border-style: solid;
border-width: 2px;
}
.table .tg-1 {
text-align: center;
}
.table .tg-2 {
font-weight: bold;
background-color: #c0c0c0;
text-align: center;
}
.table iframe {
padding: 0;
width: 216px; /* modify as needed according to image size */
height: 116px; /* use +16px in both to allow for internal padding */
border: none;
}
</style>
<table class="table">
<tr>
<th class="tg-2">Animal Name</th>
<th class="tg-2">Picture</th>
</tr>
<tr>
<td class="tg-1">Cat</td>
<td rowspan="3"><iframe src="about:blank" name="pic"></iframe></td>
</tr>
<td class="tg-1">Dog</td>
</tr>
<tr>
<td class="tg-1">Horse</td>
</tr>
</table>
</body>
</html>
I think that what you really need it for the hyperlinks to be replaced with image tags, e.g.:
<td class="tg-1"><image src="Images/Horse.jpg" alt="Horse"/></td>
#table1
{
font-family: Calibri;
font-size: 12pt;
font-style: normal;
text-align:center;
width:500px;
border-collapse: collapse;
border: 3px solid orange;
margin-right:80px
}
table,th,td{
font-family: Calibri;
font-size: 12pt;
font-style: normal;
text-align:center;
width:500px;
border-collapse: collapse;
border: 3px solid red;
margin-right:80px
}
i am using 2 different types of table,with 2 different color, but whenever i try to put th,td in anyone of the table,all the tables get same color as that of th,td table.
how to customize each table?
SAMPLE TABLE FIDDLE
<table class="mytable"></table>
.mytable, mytable.th, mytable.td
{
//some codes
}
<table id="table1"></table>
#table1
{
//some codes
}
You can use as follow
//css
.table1{
//table1 style
}
.table1 th{
//th style for table1 class
}
.table1 td{
//set color for table1
}
.table2{
}
.table2 th{
//set your color
}
.table2 td{
//set color for table1
}
//html code
<table class="table1">
<tr>
<th>...</th>
</tr>
<tr>
<td>...</td>
</tr>
</table>
<table class="table2">
<tr>
<th>.... </th>
</tr>
<tr>
<td>...</td>
</tr>
</table>