Highlight a row on Click not working. CSS precedence - html

Here's the table in my html file. I have to highlight a row on click.
<tbody>
<!--display none-->
<!--onclick-->
<tr ng-repeat="case in lastten" ng-click="setSelected(case.Name)" ng-class="{selected: case.Name === idSelected}">
<td colspan="1">{{case.Name}}</td>
<td colspan="1">{{case.total}}</td>
<td colspan="1">{{case.passed}}</td>
<td colspan="1">{{case.failed}}</td>
</tr>
</tbody>
css- initialTable is the class for the above table
table.InitialTable {
table-layout: fixed;
width: 100%;
font-family: Helvetica, Arial, sans-serif;
margin-top: 20px;
margin-bottom: 20px;
border-collapse: collapse;
border-spacing: 0;
}
table.InitialTable td,
th {
border: 1px solid transparent;
height: 40px;
transition: all 0.3s;
overflow: hidden;
}
table.InitialTable th {
font-weight: bold;
text-align: center;
vertical-align: middle;
}
table.InitialTable td {
text-align: center;
vertical-align: middle;
}
table.InitialTable tr:nth-child(even) {
background: #f3f7fb;
}
table.InitialTable tr:nth-child(odd) {
background: #ffffff;
}
.InitialTable tr:hover td {
background: #eee;
}
.selected {
background: red;
}
Here's the angular code-
$scope.idSelected = null;
$scope.setSelected = function(idSelected) {
$scope.idSelected = idSelected;
};
So basically whenever a row is selected it gets the class selected and it should be highlighted. But the css is not working. So is the precedence of .selected below the hover ? I also tried a lot of other combinations , but it didn't work. Even important isn't working . I've been stuck at this for quite a while now .

Related

HTML table doesn't start until next page if it's too large

I'm using WickedPDF to convert HTML to PDF and for some reason, even though I thought I had the proper HTML code, my tables still seem to be breaking onto the next page. Mind you, the information that starts in the <td> is actually a nested table, so I'm not sure if this has anything to do with it.
Here's what it looks like in the report:
Here's my CSS code that I'm working with:
<style>
p, ul {
color: #545658;
font-size: 12pt;
font-family: "Arial";
font-weight: 500;
}
* {
font-family: "Arial";
}
h1 {
color: #ED1C24;
font-weight: normal;
font-family: "Arial";
}
th {
padding-top: 12px;
padding-bottom: 12px;
text-align: center;
background-color: black;
color: white;
}
td {
color: #545658;
padding-top: 5px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 5px;
}
table.bordered {
border-collapse: collapse;
}
table.bordered td {
border: 1px solid black;
}
table.bordered tr:first-child td {
border-top: 0;
}
table.bordered tr td:first-child {
border-left: 0;
}
table.bordered tr:last-child td {
border-bottom: 0;
}
table.bordered tr td:last-child {
border-right: 0;
}
tr.bordered:nth-child(even) {background-color: #f2f2f2}
img.finding {
position:absolute;
width:60%;
height: 40px;
margin-left: -20px;
max-width: 100%;
z-index:-1;
}
p.finding {
display: inline;
color: white;
font-weight: bold;
font-size: 16pt;
line-height: 1.75em;
}
code {
background-color: #eee;
border: 1px solid #999;
display: block;
padding: 5px;
font-family: "Courier";
font-size: 9.5pt;
color: black;
}
pre {
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-break: break-all;
}
table { page-break-inside: auto; width: 100%;}
thead { display: table-row-group; }
tr { page-break-inside: auto; }
</style>
What am I doing wrong that's causing my table to not start until the next page just because its contents is too large for the remainder of the previous page? I thought my tr { page-break-inside: auto; } line would have taken care of this. Is it because I have a nested table perhaps?
This ONLY happens on nested HTML tables. Normal HTML tables start on the same page no matter the length of the content.
Here's an example HTML table:
<html>
<body >
<table border=5 bordercolor=red>
<tr>
<td>
Fisrt Column of Outer Table
</td>
<td>
<table border=5 bordercolor=green>
<tr>
<td>
[lots of data right here]
</td>
</tr>
<tr>
<td>
[lots of data right here]
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

Table in div container with weird gap

Hi there's this weird gap beside the td, when viewed at 375px. Which part causes this, and how do I get rid of it?
The table is inside a div with container class btw. Both the table and tr inherit 100% of the width (375.2px when viewed at that pixel), but for some reason the td only inherits 370.4 - there is a missing 4.8px.
HTML:
<div className="container container--margin--top container--font">
<table className="header__table--margin--btm">
<thead>
<tr>
<th className="text article__title">Article Title</th>
<th className="text snippet">Snippet (click to view article)</th>
</tr>
</thead>
</table>
<ArticleRow dataArray={dataArray} />
</div>
JS:
const ArticleRow = ({dataArray}) => {
const dataRow = dataArray.map(row => {
return (
<tr key={row.title}>
<td className="title">{row.title}</td>
<td className="content__div">
{row.content}
</td>
</tr>
);
});
return (
<table>
<tbody>
{dataRow}
</tbody>
</table>
);
}
CSS:
table {
border-collapse: separate;
border-spacing: 2px;
border-color: grey;
.title {
background: $title-bg;
color: $content-bg;
text-align: right;
width: 15.4rem;
padding-right: 1rem;
font: 500 2.1rem "Garamond", serif;
border: 1px solid rgba(39, 41, 50, 0.1);
}
.content__div {
//border: 1px solid rgba(250, 250, 250, 0.1);
}
.content {
display: block;
background: $content-bg;
color: $title-bg;
text-decoration: none;
padding: 1rem 1.5rem;
:hover {
text-decoration: none;
color: $title-bg;
opacity: 0.9;
}
}
}
#media (max-width: 550px) {
table .title {
padding-left: 0.4rem;
padding-right: 0.4rem;
width: auto;
}
.container {
padding: 0;
}
.container--margin--top {
margin-top: 1.5rem;
}
.article__title {
width: 9.8rem;
padding-right: 0.4rem;
text-align: inherit;
}
.search__bar {
width: 20rem;
}
}
#media (max-width: 376px) {
.title {
position: absolute;
margin-top: -2.8rem;
margin-left: 2px;
}
.container--margin--top {
margin-top: 1rem;
}
.header__table--margin--btm {
margin-bottom: 2.9rem;
}
tbody tr:not(:last-child) .content__div {
padding-bottom: 4rem;
}
}
https://github.com/helplah/react-wikipedia
I found the answer. The missing 4px originated from border-collapse: separate. Once I unset it, the gap disappears. I tested it on both firefox and chrome, it works on both browsers.

Listview Items To Html

So today im trying to take items and subitems from a listview and put it in my html template. i can see how this is hard to understand so im going to be showing u what i mean.
This is the Source code for the HTML File
body {
font-size: 13px;
font-family: verdana, helvetica, arial, sans-serif;
color: #666666;
background-color: #333333;
margin: 0px;
}
table {
border-collapse: collapse;
width: 100%;
}
tr:nth-child(odd) {
background-color: #ffffff;
}
tr:nth-child(even) {
background-color: #f1f1f1;
}
tr.h th {
background-color: #333333;
border: none;
}
th {
color: #ffffff;
background-color: #00E5EE;
border: 1px solid #00E5EE;
padding: 3px;
vertical-align: top;
text-align: left;
}
td {
border: 1px solid #d4d4d4;
padding: 5px;
padding-top: 7px;
padding-bottom: 7px;
vertical-align: top;
}
pre {
font-size: 13px;
font-family: verdana, helvetica, arial, sans-serif;
padding: 0px;
margin: 0px;
font-weight: normal;
white-space: pre-wrap;
word-wrap: break-word;
}
<body>
<div class="center" style="margin:auto;width:80%;">
<table>
<tr class="h">
<th>
<h2>Stats... </h2>
</th>
<th></th>
<th></th>
</tr>
<tr>
<th>name</th>
<th>age</th>
<th>gander</th>
</tr>
<pre><tr><td>Quan</td><td>12</td><td>male</td></tr></pre>
<pre><tr><td>sam</td><td>14</td><td>male</td></tr></pre>
</table>
<p><small>lit stuff right here </small></p>
</div>
</body>
So now to tell you what i want happening, i want when i click the button that says "Turn to html" that i show in the form photo, to convert the items and subitems into the html layout that i also show in the second photo.
i hope this is enough information.

HTML/CSS Table height ignored in Internet Explorer

I'm adding a new 'News Container' to a slightly older webpage at our firm.
This container is made up of a 2x3 table. I want the Cell 2x2 to be as High as the Text.
Here's the Problem:
Everybody uses IE in our offices (Security reasons etc.) but for some reason IE ignores the height attribute given either directly in HTML (style="height:;" or height="") or in a separate CSS.
So in Chrome it looks like this (how it should):
╔════════════════╗
╠══╦═════════════╣
║  ║Test String  ║
║  ╠═════════════╣
╚══╩═════════════╝
And in Internet Explorer like this:
╔════════════════╗
╠══╦═════════════╣
║  ║Test String  ║
║  ║ ║
║  ╠═════════════╣
╚══╩═════════════╝
Picture: http://imgur.com/a/jQXhQ
View it yourself (Open in both Chrome and IE) here.
How can I get IE to use the Height attribute or alternatively is there a different way?
IE Version: 11.0.9600.17358
Update: 11.0.13
Code:
<table id="NewsTable">
<tr>
<th id="NewsHeader" colspan="2">IT Status</th>
</tr>
<tr>
<td rowspan="2">
<img id="NewsAmpel" alt="NewsStatus" src="Ampel/AmpelA.jpg" width="36px" height="100px">
</td>
<td id="NewsStatus"><b>Status:    </b>Test String</td>
</tr>
<tr>
<td id="NewsDesc"><b>Description: </b>Sample Text</td>
</tr>
i have made some changes in html as well as CSS
Working Fiddle
http://jsfiddle.net/UzCRc/60/
HTML
<table id="NewsTable">
<tr>
<th id="NewsHeader" colspan="2">IT Status</th>
</tr>
<tr>
<td id="NewsAmpel">
<img alt="NewsStatus" src="Ampel/AmpelA.jpg" width="36px" height="100px">
</td>
<td id="NewsStatus"><b>Status:    </b>Test String</td>
<td id="NewsDesc"><b>Description: </b>Sample Text</td>
</tr>
</table>
CSS
#NewsAmpel{
width:36px;
}
body {
font-family: Verdana, sans-serif;
font-size: 13px;
}
h1 {
font-size: 15px;
font-weight: bold;
}
h2 {
font-size: 14px;
body {
font-family: Verdana, sans-serif;
font-size: 13px;
}
h1 {
font-size: 15px;
font-weight: bold;
}
h2 {
font-size: 14px;
font-weight: bold;
}
img {
border: 0;
}
a {
color: #00538E;
}
#content {
width: 100%;
float: left;
}
#center {
width: 600px;
height: auto;
margin: 0 auto;
}
font-weight: bold;
}
img {
border: 0;
}
a {
color: #00538E;
}
#content {
width: 100%;
float: left;
}
#center {
width: 600px;
height: auto;
margin: 0 auto;
}
#NewsTable {
border: 2px solid #000000;
background-color: #FFFFFF;
width: 100%;
}
#NewsStatus {
height: 20px;
padding:0;
border-bottom: 1px solid #000000;
width: 100%;
vertical-align: top;
display:block;
}
#NewsDesc {
height: 20px;
width: 100%;
margin:0;
padding:0;
display:block;
}
#NewsHeader {
text-align: center;
font-size: 14px;
font-weight: bold;
border: 1px solid #000000;
background-color: #FF1000;
}
Changes in html
Removed colspan
added image TD in same TR
Instead of image, ID has given to TD
CSS changes
#NewsStatus {
height: 20px;
padding:0;
border-bottom: 1px solid #000000;
width: 100%;//modified
vertical-align: top;
display:block;//added
}
#NewsDesc {
height: 20px; //added
width: 100%;//modified
margin:0;
padding:0;
display:block;//added
}
#NewsAmpel{
width:36px;
}

How to add several td and tr in CSS

I have a CSS that looks like this:
CSS
table {
width: 100%;
font-family: calibri;
word-wrap:break-word;
margin-left: 0;
font-size: 1.1em;
border-collapse: separate;
border-spacing: 1px;
}
td {
text-transform: none;
font-weight: bold;
line-height: 115%;
word-wrap:break-word;
vertical-align: middle;
padding: 2px 10px 0 3px ;
border-radius: 2px;
border: 1px solid #6A797F;
}
tr:nth-child(odd){
background-color: #a9c6c9;
}
tr:nth-child(even){
background-color: #d4e3e5;
}
How can I add a separate <table>, <td> & <tr> somewhere down the CSS file where by I can change the styles to fit the purpose of the design of that specific page. I tried to this solution but it didn't work:
.members_col1 tr td{
text-transform: none;
line-height: 115%;
word-wrap: break-word;
vertical-align: left;
}
.member_col1 is the <div> containing the <table> I want to add a new set of styles to.
Use the attribute id or class in your table, then cover them as selectors in the css, for example:
<table id="another-table">...
css
#another-table{
....
}
or
<table class="tables">...
<table class="tables">...
css
.tables{
...
}
use this in your html:
<table class="newTable">
...
</table>
and use this CSS:
.newTable tr td{
text-transform: none !important;
line-height: 115% !important;
word-wrap:break-word !important;
vertical-align: left !important;
}