I saw several questions on this forum related to my problem but neither of them were helpful, so am posting here.
I have a table where a style is applied at table level(.tblSignal) and td level (.tdSignalName). Here is jsfiddler link
My problem is, when I hover on the table, all the text should turn to white color. But since there is a style applied on .tdSignalName as "#0072c6", it does not override the color to white. I tried "!important" but it did not work. Please advise !
.tblSignal{
/* border-width:1px; */
border-style:solid;
}
.tblSignal:hover{
background-color:#0072c6;
color:#FFFFFF !important;
font-size:initial;
}
.tdSignalName{
font-weight:bold;
height:30px;
font-size:16px;
color:#0072c6;
}
/* .tdSignalName:hover{
color:#FFFFFF !important;
} */
.tdSignalDescription{
}
.tdSigButton{
text-align:center;
vertical-align:middle;
}
<table class="tblSignal" width="500px">
<tr >
<td class="tdSignalName" width="400px">
<div>Title</div>
</td>
<td rowspan="2" class="tdSigButton" width="100px">
<div id="divButton">
<button id="btnReport" onclick="window.open('_#=SignalReportURL=#_')">Run Report</button>
</div>
</td>
</tr>
<tr>
<td class="tdSignalDescription" width="400px">
<!-- _#=ctx.RenderBody(ctx)=#_ -->
<div><i>SignalDescription </i></div>
</td>
</tr>
</table>
You need to also override the .tdSignalName colour declaration when the parent is hovered...
.tblSignal:hover .tdSignalName {
color:#FFFFFF;
}
Example...
.tblSignal {
border-style: solid;
}
.tblSignal:hover {
background-color: #0072c6;
color: #FFFFFF !important;
font-size: initial;
}
.tdSignalName {
font-weight: bold;
height: 30px;
font-size: 16px;
color: #0072c6;
}
.tblSignal:hover .tdSignalName {
color: #FFFFFF;
}
.tdSigButton {
text-align: center;
vertical-align: middle;
}
<table class="tblSignal" width="500px">
<tr>
<td class="tdSignalName" width="400px">
<div>Title</div>
</td>
<td rowspan="2" class="tdSigButton" width="100px">
<div id="divButton">
<button id="btnReport" onclick="window.open('_#=SignalReportURL=#_')">Run Report</button>
</div>
</td>
</tr>
<tr>
<td class="tdSignalDescription" width="400px">
<!-- _#=ctx.RenderBody(ctx)=#_ -->
<div><i>SignalDescription </i></div>
</td>
</tr>
</table>
Related
Here's what I want to do (simplified example):
<table>
<tr>
<td style = "border:2px solid green">stuff1 </td>
<td style = "border:2px solid green">stuff2 </td>
<td style = "border:2px solid green">stuff3 </td>
</tr>
<tr>
<td style = "border:1px solid red">stuff4 </td>
<td style = "border:1px solid red">stuff5 </td>
<td style = "border:1px solid red">stuff6</td>
This gives precisely the right result, one row bordered in green, the next in red, but I'd like to get rid of all those "style" statements.
I tried several ways to cascade css for this, but couldn't figure out one that would work. The closest I got was:
<head>
<style>
.test {
font-size: 15px;
}
.test td {
border: 2px solid green
}
.test td a{
border: 1px solid red
}
</style>
</head>
<body>
<table class = "test">
<tr>
<td>stuff1 </td>
<td>stuff2 </td>
<td>stuff3 </td>
</tr>
<tr>
<td><a>stuff4</a> </td>
<td><a>stuff5</a> </td>
<td><a>stuff6</a> </td>
</tr>
</table>
</body>
This almost worked. The top row was bordered in green. But the bottom row was bordered in both red and green.
Could someone explain to me how to set up my css so that I can get the result I want.
**************Well, I found a solution using .test th { for the second color. But this does not solve anything if I want a third color.
You can just add a class to the second set of tds. See below for the code or check the Codepen for a working example.
<html>
<head>
<style>
.test {
font-size: 15px;
}
td {
border: 2px solid green;
}
td.red {
border: 1px solid red;
}
</style>
</head>
<body>
<table class="test">
<tr>
<td>stuff1</td>
<td>stuff2</td>
<td>stuff3</td>
</tr>
<tr>
<td class="red">stuff4</td>
<td class="red">stuff5</td>
<td class="red">stuff6</td>
</tr>
</table>
</body>
</html>
Codepen: https://codepen.io/anon/pen/NzygNV
you can do like this as well, Like keeping css classes in a separate css file and then just adding a link tag pointing towards the css file in the html where you have your table.Refer link below for same.
.tbl {
font-size: 15px;
}
td {
border: 2px solid green;
}
td.red {
border:1px solid red;
}
<html>
<head>
<!-- you can ad link to css here -->
</head>
<body>
<table class="tbl">
<tr>
<td>column1</td>
<td>column2</td>
<td>column3</td>
</tr>
<tr>
<td class="red">data1</td>
<td class="red">data2</td>
<td class="red">data3</td>
</tr>
</table>
</body>
</html>
https://codepen.io/anon/pen/PaQJNK
I have a table within a table. I have set table background-color to white.
The inner table's background is to remain white while all other cells of the outer table are set to lightgrey.
However, the outer table's white background-color is showing up as a border around all its <td> cells which I cannot figure out how to get rid of - all grey cells should be borderless. I have tried setting the border property of all elements to none without success. Any help would be appreciated.
Here is a jsfiddle
<style>
body{
background-color: lightcyan;
}
.gems {
margin:0 8px;
padding:0;
}
.gems table{
width:100%;
background-color:white;
}
.gems td {
padding:0px 1px;
margin:0;
}
.gems tr.filelist {
margin:5px;
background-color: lightgrey;
}
.gems tr.tools {
background-color: lightgrey;
}
div.textarea {
background-color: white;
}
</style>
<body>
<div class="gems">
<table>
<tr class="filelist">
<td>filelist</td>
<td>filelist</td>
</tr>
<tr class="tools">
<td>tools</td>
<td>
<div class="textarea">
This is a table
<table>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</body>
<table cellspacing="0">
Add this property in your table tag.
You can see the differences what i get for my table styling with and without using bootstrap but i want the same behavior instead.
table styling without bootstrap
table styling after bootstrap
application.css.scss
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_self
*= require_tree .
*/
#import "bootstrap-sprockets";
#import "bootstrap";
general.css
.pos { color: #000; }
.neg { color: #f00; }
h1 {
color:orange;
text-align: center;
}
table.listing{
background: #C3D9FF none repeat scroll 0% 0%;
-moz-border-radius:10px;
-webkit-border-radius:10px;
padding:20px 20px 40px;
border-radius:10px;
}
table.listing tr.tr-head{
background: #fff;
color:#990a10;
font-weight:bold;
text-align:center;
}
table.listing .tr-head td{
padding:5px;
padding-left:10px;
}
table.listing .tr-odd{
background: #fff;
text-align:center;
padding:50px;
color:#27292b;
font-weight:600;
font-size:14px;
}
table.listing .tr-even{
background: #f1f6ff;
text-align:center;
padding:50px;
color:#27292b;
font-weight:600;
font-size:14px;
}
table.listing td.col-1{
width:10%;
padding: 5px;
padding-left:10px;
}
table.listing td.col-3{
width:13%;
padding: 5px;
padding-left:10px;
}
index.html.erb
<h1>361° YAZD Statement</h1>
<% balance = 0 %>
<table class="listing" align="center" width="100%" cellpadding="1" cellspacing="1">
<tr class="tr-head">
<td>Date</td>
<td>Description</td>
<td>Amount</td>
<td>Discount</td>
<td>Paid</td>
<td>Balance</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<% #statements.each do |statement| %>
<tr class="tr-<%= cycle('odd', 'even') %>">
<td class="col-1"><%= statement.date %></td>
<td class="col-3"><%= statement.description %></td>
<td class="col-1"><%= number_with_precision(statement.amount, :delimiter => ",", :precision => 2) %></td>
<td class="col-1 neg"><%= number_with_precision(statement.discount, :delimiter => ",", :precision => 2) %></td>
<td class="col-1 neg"><%= number_with_precision(statement.paid, :delimiter => ",", :precision => 2) %></td>
<% balance += statement.amount.to_f - statement.discount.to_f - statement.paid.to_f %>
<% color = balance >= 0 ? "pos" : "neg" %>
<td class="col-1 <%= color %>"><%= number_with_precision(balance.abs, :delimiter => ",", :precision => 2) %></td>
</tr>
<% end %>
</table>
The problem is when I import bootstrap the background property is missing;
table.listing{
background: #C3D9FF none repeat scroll 0% 0%;
}
I really appreciate if anybody could help me out!!!
div h1 {
color: orange;
text-align: center;
}
.pos {
color: #000;
}
.neg {
color: #f00;
}
.myTable {
background: #C3D9FF none repeat scroll 0% 0%;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
padding: 20px 20px 40px;
}
.myTable .table,
.myTable tr {
border: 2px solid #C3D9FF;
}
.table.listing tr.tr-head {
background: #fff;
color: #990a10;
font-weight: bold;
border: 2px solid #C3D9FF;
}
.table.listing .tr-head td {
padding: 5px;
border: 2px solid #C3D9FF;
}
.table.listing .tr-odd {
background: #fff;
color: #27292b;
font-weight: 600;
font-size: 14px;
border: 2px solid #C3D9FF;
}
.table.listing .tr-even {
background: #f1f6ff;
color: #27292b;
font-weight: 600;
font-size: 14px;
border: 2px solid #C3D9FF;
}
.table.listing td.col-1 {
width: 10%;
padding: 5px;
border: 2px solid #C3D9FF;
}
.table.listing td.col-3 {
width: 13%;
padding: 5px;
border: 2px solid #C3D9FF;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<h1>361° YAZD Statement</h1>
<div class="table-responsive myTable">
<table class="table table-bordered listing text-center">
<tr class="tr-head">
<td>Date</td>
<td>Description</td>
<td>Amount</td>
<td>Discount</td>
<td>Paid</td>
<td>Balance</td>
</tr>
<tr class="tr-even">
<td class="col-1">11-20-2015</td>
<td class="col-3">Something</td>
<td class="col-1">10,000</td>
<td class="col-1 neg">20,000</td>
<td class="col-1 neg">20,000</td>
<td class="col-1">50,000</td>
</tr>
<tr class="tr-odd">
<td class="col-1">11-20-2015</td>
<td class="col-3">Something</td>
<td class="col-1">10,000</td>
<td class="col-1 neg">20,000</td>
<td class="col-1 neg">20,000</td>
<td class="col-1">50,000</td>
</tr>
<tr class="tr-even">
<td class="col-1">11-20-2015</td>
<td class="col-3">Something</td>
<td class="col-1">10,000</td>
<td class="col-1 neg">20,000</td>
<td class="col-1 neg">20,000</td>
<td class="col-1">50,000</td>
</tr>
<tr class="tr-odd">
<td class="col-1">11-20-2015</td>
<td class="col-3">Something</td>
<td class="col-1">10,000</td>
<td class="col-1 neg">20,000</td>
<td class="col-1 neg">20,000</td>
<td class="col-1">50,000</td>
</tr>
</table>
</div>
</div>
You need to first change general.css to general.css.scss then import it into application.css.scss with your other SCSS files (and since you're using SCSS you should remove all of the comments/text/requires that you have at the top of your current application.css.scss):
#import "bootstrap-sprockets";
#import "bootstrap";
#import "general";
You should probably restart your server as well after these changes are made.
In your HTML first load bootstrap and then load your custom stylesheets. Something like this:
<!-- styles -->
<link rel="stylesheet" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/style.css" />
This solved my problem when I experienced the same issue yesterday.
I have a dropdown menu that appears when mousing over cells in a large table in the page. The table gets large enough that cells can sometimes appear at the far right of the window. Mousing over a row shows the menu just below the row, and it dynamically shifts to be under the cell you are hovering (all via JQuery). A menu button or header div is revealed that you can mouseover to show the dropdown, which is a container div which contains two ul's that float: left so they stay side-by-side.
It works fine unless I mouseover a cell at the far right of the page. It works in Safari, in that if the dropdown is outside the window, the ul's stay in their float and bleed off the page/window. But in Firefox, there's a line break/the ul's lose their float the second one breaks to the next line to stay within the window.
I tried this hack, but Firefox 7 still doesn't like it:
CSS floats - how do I keep them on one line?
Any help is greatly appreciated. Relevant markup/code:
HTML
<table summary="" class="tbl">
<thead>
<tr>
<th>Select</th>
<th>Employee<br>ID</th>
<th>Position Title</th>
<th>Job Code</th>
<th>Name</th>
<th>Employee<br>Dept</th>
<th>Organization</th>
<th>Location</th>
<th>FTE</th>
<th>Annualized FTE<br>Base Pay</th>
<th>Performance<br>Rating</th>
<th>Grade</th>
<th>Annualized<br>Base Min</th>
<th>Annualized<br>Base Max</th>
<th>Annualized<br>Compa-ratio</th>
<th>Annualized Range<br>Penetration</th>
</tr>
</thead>
<tbody>
<tr class="dataRow">
<td class="dataCell"><input type="checkbox"></td>
<td class="dataCell">1002</td>
<td class="dataCell">Accounting Manager</td>
<td class="dataCell">ACC1000</td>
<td class="dataCell">Doe, John</td>
<td class="dataCell">Accounting</td>
<td class="dataCell">Portland</td>
<td class="dataCell columnGreen">Abbottabad</td>
<td class="dataCell">1</td>
<td class="dataCell">$82,000</td>
<td class="dataCell">3</td>
<td class="dataCell"></td>
<td class="dataCell columnBlue">$30,000</td>
<td class="dataCell">$50,000</td>
<td class="dataCell">2.050</td>
<td class="dataCell">260%</td>
</tr>
<tr class="dataRow">
<td class="dataCell"><input type="checkbox"></td>
<td class="dataCell">1002</td>
<td class="dataCell">Accounting Manager</td>
<td class="dataCell">ACC1000</td>
<td class="dataCell">Doe, John</td>
<td class="dataCell">Accounting</td>
<td class="dataCell">Portland</td>
<td class="dataCell columnGreen">Abbottabad</td>
<td class="dataCell">1</td>
<td class="dataCell">$82,000</td>
<td class="dataCell">3</td>
<td class="dataCell"></td>
<td class="dataCell columnBlue">$30,000</td>
<td class="dataCell">$50,000</td>
<td class="dataCell">2.050</td>
<td class="dataCell">260%</td>
</tr>
</tbody>
</table>
<div id="menu">
<div id="menuHeader">Menu</div>
<div id="menuItems">
<ul>
<li>Select</li>
<li>View or Edit</li>
<li>Assign to Job Markets</li>
<li>Add a Note</li>
<li>Delete</li>
</ul>
<ul>
<li>Select</li>
<li>View or Edit</li>
<li>Assign to Job Markets</li>
<li>Add a Note</li>
<li>Delete</li>
</ul>
<br style="clear: both"/>
</div>
</div>
CSS
#menu {
position: absolute;
top: 36px;
left: 600px;
display: none;
white-space: nowrap;
}
#menu #menuHeader {
line-height: 24px;
height: 24px;
padding: 0 15px 0 0px;
}
#menu #menuHeader a {
height: 23px;
width: 61px;
margin: 0 58px 0 0;
display: inline-block;
padding: 0 0 0 15px;
}
#menu #menuItems {
border-collapse: collapse;
position: relative;
display: none;
}
#menu #menuItems ul {
float: left;
position: relative;
}
#menu #menuItems li {
display: block;
position: relative;
height: 23px;
line-height: 23px;
}
#menu #menuItems a {
display: block;
position: relative;
padding: 0 15px 0 15px;
}
JQuery
// row highlighting, menu display (visiblity)
$('tr.dataRow').mouseenter(
function () {
$('div#menu').css('display', 'block');
}
);
// menu offset relative to td hovered
$('td').mouseenter(
function () {
var tempOffset = $(this).offset();
var tempHeight= $(this).outerHeight();
var tempTop = tempOffset.top + tempHeight - 1;
var tempLeft = tempOffset.left;
$('div#menu').offset({top:tempTop, left:tempLeft});
}
);
I am using ie 8.
I have the following CSS where I want to show the border for the outer table, but not the table nested inside one of the cells;
table#ScheduledLeaveCalendar
{
table-layout:fixed;
}
/* Calendar that shows annual leave */
#ScheduledLeaveCalendar
{
border-collapse:collapse;
}
#ScheduledLeaveCalendar td, #ScheduledLeaveCalendar th
{
font-size:0.8em;
border:1px solid #2906A6; /* dark blue */
}
#ScheduledLeaveCalendar th
{
width:30px;
font-size:0.9em;
text-align:center;
padding:5px 3px 4px 3px;
padding-top:5px;
padding-bottom:4px;
background-color:#6640EE; /* blue */
color:#ffffff;
}
#ScheduledLeaveCalendar td
{
padding: 0px;
margin: 0px;
}
#ScheduledLeaveCalendar table
{
border-collapse: collapse;
border: 0px;
margin: 0px;
padding: 0px;
}
This CSS gives me
The Markup is;
<table id="ScheduledLeaveCalendar">
<tr>
<th colspan="2"></th>
<th colspan="6">Oct 2011</th>
<th colspan="1"></th>
</tr>
<tr>
<th>F</th><th></th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th></th><th>M</th>
</tr>
<tr>
<th>14</th><th></th><th>17</th><th>18</th><th>19</th><th>20</th><th>21</th><th></th><th>24</th>
</tr>
<tr>
<td class="StandardCellHeight DefaultColour"></td>
<td class="StandardCellHeight DefaultColour"></td>
<td><table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%"><tr><td />
<td class="StandardCellHeight AnnualLeaveColour" />
</tr></table></td>
<td><table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%"><tr><td class="StandardCellHeight AnnualLeaveColour" />
<td />
</tr></table></td>
<td class="StandardCellHeight DefaultColour"></td>
<td class="StandardCellHeight DefaultColour"></td>
<td class="StandardCellHeight DefaultColour"></td>
<td class="StandardCellHeight DefaultColour"></td>
<td class="StandardCellHeight DefaultColour"></td>
</tr>
</table>
See http://jsfiddle.net/Dqm68/1/
You can use
#ScheduledLeaveCalendar td td {
border: 0;
}
which means the td elements that are nested in other td elements should have no border..
Demo at http://jsfiddle.net/Dqm68/5/
Simply add another line to remove the border from the nested table td.
#ScheduledLeaveCalendar table td {border:none}
http://jsfiddle.net/blowsie/Dqm68/3/