CSS3 :nth-child(odd) Selector neither selecting columns nor rows - html

I have a simple table using tr:nth-child(odd) to alternate background for rows in a table.
HTML
/*-----------#602 SAO Styles-----------------------------*/
/*---------SAO Global------------*/
.sao-pricing-table table {
border-collapse: collapse;
width: 80%;
margin: 0 auto;
background: #ffffff;
}
.sao-pricing-table table td {
height: 20px;
}
table.sao-table {
border-collapse: collapse;
}
/*-----Basic Title Cells---------*/
.sao-top-1 {
border: 0px;
background: #FFFFFF;
height: 40px;
width: 40%;
}
.sao-top-2 {
font-size: 16px;
text-shadow: 2px 4px 3px rgba(0, 0, 0, 0.3);
color: #FFFFFF;
border: 0px solid #a8b5b9;
background-color: #003869;
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
height: 40px;
width: 30%;
}
.sao-top-2-title {
font-size: 110%;
}
.sao-top-2-type {
font-size: 120%;
}
.sao-top-2-price {
font-size: 100%;
}
/*------Gold Title Cells------*/
.sao-top-3 {
font-size: 16px;
text-shadow: 2px 4px 3px rgba(0, 0, 0, 0.3);
color: #FFFFFF;
border: 0px solid #a8b5b9;
background-color: #F2A405;
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
height: ;
width: 30%;
}
.sao-top-3-title {
font-size: 110%;
}
.sao-top-3-type {
font-size: 130%;
}
.sao-top-3-price {
font-size: 100%;
}
/*----Regular Cells-----*/
#sao-table table {
border-collapse: collapse;
width: 100%;
}
th,
td {
padding: 0.25rem;
text-align: center !important;
border: 1px solid #ccc;
height: 20%;
}
tr.sao-zebra:nth-child(odd) {
background: #23282D !important;
}
.sao-feature {
text-align: left !important;
}
/* Checkmark Style-----*/
.sao-checkmark {
font-size: 125%;
color: #F2A405;
text-shadow: 2px 4px 3px rgba(0, 0, 0, 0.2);
}
<div class="sao-pricing-table">
<table class="sao-table">
<thead>
<tr>
<th class="sao-top-1">
</th>
<th class="sao-top-2">
<span class="sao-top-2-title">Some Text</span>
<span class="sao-top-2-type">More Text</span>
<span class="sao-top-2-price">Even More Text</span>
</th>
<th class="sao-top-3">
<span class="sao-top-3-title">Some Text</span>
<span class="sao-top-3-type">More Text</span>
<span class="sao-top-3-price">Even More Text</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th class="sao-feature">Text</th>
<td class="sao-detail">Text</td>
<td class="sao-detail">Text</td>
</tr>
<tr>
<th class="sao-feature">Text</th>
<td class="sao-detail">Text</td>
<td class="sao-detail">Text</td>
</tr>
as is stands, the table has 3 columns. The nth-child pseudo selector is causing every other column to be black, not every other row. What have I done wrong? Edit: the example for row span that was suggested doesn't include the nth-child selector so I'm failing to see how its the same. Can someone fill me in?

You have a space in your selector where there shouldn't be one, just before :nth-child
tr.sao-zebra:nth-child(odd) {
background: #23282D;
}

Related

How to span this text across?

I have some text in a table cell in a table row that I'm trying to have the text span.
The text keeps on stopping in place.
This is what I currently have:
However this is what I want:
I want the text to span all way.
How would I implement this?
This is my code:
.normal-cell-styling-left-second {
width: 350px;
padding-top: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #E6E6E6;
}
.normal-cell-styling-middle-second {
width: 425px;
padding-left: 60px;
padding-top: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #E6E6E6;
}
.normal-cell-styling-right-second {
width: 700px;
padding-top: 20px;
padding-left: 200px;
padding-bottom: 20px;
border-bottom: 1px solid #E6E6E6;
}
.gray-dynamic {
display: inline-block;
background-color: #F6F8FA;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
border-radius: 4px;
margin-top: 5px;
margin-bottom: 5px;
font-weight: normal;
font-size: 16px;
font-family: 'PureHeadlineRegular', Sans-serif;
line-height: 19px;
color: #212121;
}
.image-placeholder5 {
display: inline-block;
width: 196px;
height: 36px;
background-color: #F1F1F1;
}
<table>
<tr>
<td className="normal-cell-styling-left-second">
<span class="gray-dynamic">
SHADOW_SPREAD_0
</span>
</td>
<td className="normal-cell-styling-middle-second">
0 0 0px 0 rgba(0,0,0,0.12) <br></br>0 0px 0px 0 rgba(0,0,0,0.24)
</td>
<td className="normal-cell-styling-right-second">
<div className="image-placeholder5"></div>
</td>
</tr>
<table>
Just put it in a span like your SHADOW_SPREAD
.normal-cell-styling-left-second {
width: 350px;
padding-top: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #E6E6E6;
}
.normal-cell-styling-middle-second {
width: 425px;
padding-left: 60px;
padding-top: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #E6E6E6;
}
.normal-cell-styling-right-second {
width: 700px;
padding-top: 20px;
padding-left: 200px;
padding-bottom: 20px;
border-bottom: 1px solid #E6E6E6;
}
.gray-dynamic {
display: inline-block;
background-color: #F6F8FA;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
border-radius: 4px;
margin-top: 5px;
margin-bottom: 5px;
font-weight: normal;
font-size: 16px;
font-family: 'PureHeadlineRegular', Sans-serif;
line-height: 19px;
color: #212121;
}
.image-placeholder5 {
display: inline-block;
width: 196px;
height: 36px;
background-color: #F1F1F1;
}
<table>
<tr>
<td className="normal-cell-styling-left-second">
<span class="gray-dynamic">
SHADOW_SPREAD_0
</span>
</td>
<td className="normal-cell-styling-middle-second">
<span class="gray-dynamic">
0 0 0px 0 rgba(0,0,0,0.12) <br>0 0px 0px 0 rgba(0,0,0,0.24)
</span>
</td>
<td className="normal-cell-styling-right-second">
<div className="image-placeholder5"></div>
</td>
</tr>
<table>
Modify the css
.table thead tr th td {
white-space:nowrap
}
Then use white-space-no-wrap in the table data style
<td style="white-space:nowrap;" className="normal-cell-styling-middle-second"> 0 0 0px 0 rgba(0,0,0,0.12) <br></br>0 0px 0px 0 rgba(0,0,0,0.24) </td>
Not sure, but it looks like there is a few things about table styling you are not familiar with :
vertical-align can be used on a cell to tell if the content is to centered, aligned on top or bottom without using padding or line-height for an average alignment. https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align (look farther down about table cells )
border-collapse or border-spacing can be used to avoid gaps in between cells border. see https://developer.mozilla.org/en-US/docs/Web/CSS/border-collapse & https://developer.mozilla.org/en-US/docs/Web/CSS/border-spacing might look similar but involves different behavior when drawing borders on a table.
table-layout:fixed can be used to set a fixed width to the table and the cells so they do not shrink/expand anymore. ( height cannot be set on a fixed value, table will not show scrollbars) this is the one thing to know about the table (or display:table / table-cell / ... properties) rendering behavior.
white-space can be used anywhere and you might know more about it https://developer.mozilla.org/en-US/docs/Web/CSS/white-space
Here is a snippet that could be closer to what you expect, do not hesitate to clarify your needs and misunderstandings of myself.
table{
border-spacing:0;/* or border-collapse:collapse; */
}
.normal-cell-styling-left-second {
width: 350px;
border-bottom: 1px solid ;
vertical-align:top;
}
.normal-cell-styling-middle-second {
width: 425px;
padding-left: 60px;/* needed ?*/
border-bottom: 1px solid ;
white-space:nowrap;
}
.normal-cell-styling-right-second {
border-bottom: 1px solid ;
}
.gray-dynamic {
display: inline-block;
background-color: #F6F8FA;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
border-radius: 4px;
margin-top: 5px;
margin-bottom: 5px;
font-weight: normal;
font-size: 16px;
font-family: 'PureHeadlineRegular', Sans-serif;
line-height: 19px;
color: #212121;
}
.image-placeholder5 {
display: inline-block;
width: 196px;
height: 36px;
background-color: #F1F1F1;
}
<table>
<tr>
<td class="normal-cell-styling-left-second">
<span class="gray-dynamic">
SHADOW_SPREAD_0
</span>
</td>
<td class="normal-cell-styling-middle-second">
0 0 0px 0 rgba(0,0,0,0.12) <br>0 0px 0px 0 rgba(0,0,0,0.24)
</td>
<td class="normal-cell-styling-right-second">
<div class="image-placeholder5"></div>
</td>
</tr>
<table>

Bottom border for table in overflowing div

I have a table inside an overflowing < div >. I am struggling to make bottom-border, either for the table or for the div, that will look nice. The current situation is: when overflowing, the bottom-border of the div looks nice. When not overflowing, it looks out of place. I have put the bottom-border on the table, when overflowing, it will obviously not show. I don't have any experience with JavaScript/Jquery/etc. and have tried to only use CSS for this so far.
#container {
width: 100%;
height: 0 auto;
overflow: auto;
}
#table_wrapper {
border-bottom: 1px solid #5C6F8C;
float: none;
overflow: auto;
height: 80vh;
width: 80%;
}
#test_table {
border-collapse: separate;
border-spacing: 0;
letter-spacing: 1px;
font-family: Verdana, Tahoma, Arial, sans-serif;
font-size: calc(8px + 0.3vw);
text-align: center;
width: 100%;
/*border-bottom: 1px solid #5C6F8C;*/
}
#top_header {
border: 2px solid #5C6F8C;
border-right: 0px;
background-color: #ADBEDA;
}
caption {
background-color:white;
}
td, th {
border: 1px solid #5C6F8C;
border-right: 0px;
border-bottom: 0px;
padding: 5px 10px;
text-align: left;
}
tbody > tr:first-child > td {
border-top: 0px;
}
tbody > tr:first-child > th {
border-top: 0px;
}
th {
background-color: #ADBEDA;
}
tr:nth-child(even) {
background-color: #CFDDF5;
}
tr:nth-child(odd) {
background-color: #E3ECFD;
}
tr:hover {
background-color: #F0F5FF;
text-shadow:0px 0px 0.25px black;
}
<div id="container">
<div id="table_wrapper">
<table id="test_table">
<thead>
<th id="top_header">No.</th>
<th id="top_header">asdad.</th>
<th id="top_header">asdad</th>
</thead>
<tbody>
<tr><th>1</th><td>asdad</td><td>asdad</td></tr>
<tr><th>2</th><td>asdad</td><td>asdad</td></tr>
<tr><th>3</th><td>asdad</td><td>asdad</td></tr>
<tr><th>4</th><td>asdad</td><td>asdad</td></tr>
<tr><th>5</th><td>asdad</td><td>asdad</td></tr>
<tr><th>6</th><td>asdad</td><td>asdad</td></tr>
<tr><th>7</th><td>asdad</td><td>asdad</td></tr>
<tr><th>8</th><td>asdad</td><td>asdad</td></tr>
<tr><th>9</th><td>asdad</td><td>asdad</td></tr>
<tr><th>10</th><td>asdad</td><td>asdad</td></tr>
</tbody>
</table>
</div>
</div>
Better observable here, because the result screen can be resized:
https://jsfiddle.net/s43yuebt/2/
Can I achieve what I want by only using CSS?
use max-height on #table_wrapper
#table_wrapper {
border-bottom: 1px solid #5C6F8C;
float: none;
overflow: auto;
max-height: 80vh;
width: 80%;
}
#container {
width: 100%;
height: 0 auto;
overflow: auto;
}
#table_wrapper {
border-bottom: 1px solid #5C6F8C;
float: none;
overflow: auto;
max-height: 80vh;
width: 80%;
}
#test_table {
border-collapse: separate;
border-spacing: 0;
letter-spacing: 1px;
font-family: Verdana, Tahoma, Arial, sans-serif;
font-size: calc(8px + 0.3vw);
text-align: center;
width: 100%;
/*border-bottom: 1px solid #5C6F8C;*/
}
#top_header {
border: 2px solid #5C6F8C;
border-right: 0px;
background-color: #ADBEDA;
}
caption {
background-color:white;
}
td, th {
border: 1px solid #5C6F8C;
border-right: 0px;
border-bottom: 0px;
padding: 5px 10px;
text-align: left;
}
tbody > tr:first-child > td {
border-top: 0px;
}
tbody > tr:first-child > th {
border-top: 0px;
}
th {
background-color: #ADBEDA;
}
tr:nth-child(even) {
background-color: #CFDDF5;
}
tr:nth-child(odd) {
background-color: #E3ECFD;
}
tr:hover {
background-color: #F0F5FF;
text-shadow:0px 0px 0.25px black;
}
<div id="container">
<div id="table_wrapper">
<table id="test_table">
<thead>
<th id="top_header">No.</th>
<th id="top_header">asdad.</th>
<th id="top_header">asdad</th>
</thead>
<tbody>
<tr><th>1</th><td>asdad</td><td>asdad</td></tr>
<tr><th>2</th><td>asdad</td><td>asdad</td></tr>
<tr><th>3</th><td>asdad</td><td>asdad</td></tr>
<tr><th>4</th><td>asdad</td><td>asdad</td></tr>
<tr><th>5</th><td>asdad</td><td>asdad</td></tr>
<tr><th>6</th><td>asdad</td><td>asdad</td></tr>
<tr><th>7</th><td>asdad</td><td>asdad</td></tr>
<tr><th>8</th><td>asdad</td><td>asdad</td></tr>
<tr><th>9</th><td>asdad</td><td>asdad</td></tr>
<tr><th>10</th><td>asdad</td><td>asdad</td></tr>
</tbody>
</table>
</div>
</div>

Round corner in Table

I need to create a table with two columns and the first column, the cells only have a bottom border, where the cells in the second column have borders all around with round corner for the top and bottom.
My code looks like this, and work in Explorer, but in Firefox and Chrome it gives me round corner border plus normal corners:
table {
border-collapse: collapse;
width: 50%;
font-family: Proxima Nova, Arial;
}
.h1 {
/*Head cell red*/
text-align: center;
border: 1px solid #D81541;
border-radius: 20px 20px 0px 0px;
background-color: #D81541;
color: white;
font-size: 1.5em;
font-weight: bold;
width: 60%;
}
.td1 {
/*right column cells*/
border: 1px solid #6D6E70;
text-align: left;
width: 60%;
}
.td2 {
/*left column cells bold*/
border-bottom: 1px solid #6D6E70;
font-weight: bold;
vertical-align: top;
}
.td3 {
/*last cell right column*/
border: 1px solid #6D6E70;
border-radius: 0px 0px 20px 20px;
text-align: left;
width: 60%;
}
.td4 {
/*last cell left column*/
vertical-align: top;
font-weight: bold;
}
<table>
<tr>
<td class="td2"></td>
<td class="h1">My top corners should be round</td>
</tr>
<tr>
<td class="td2">bla</td>
<td class="td1">blabla</td>
</tr>
<tr>
<td class="td4">last row</td>
<td class="td3">my bottom corners should be round</td>
</tr>
</table>
Just remove border-collapse: collapse; from .table & add border-spacing:0 to it
Check the snippet. with thanks to #Abhitalks for his previous fiddle.
table {
border-spacing: 0;
width: 50%;
font-family: Proxima Nova, Arial;
}
.h1 {
/*Head cell red*/
text-align: center;
border: 1px solid #D81541;
border-radius: 20px 20px 0px 0px;
background-color: #D81541;
color: white;
font-size: 1.5em;
font-weight: bold;
width: 60%;
}
.td1 {
/*right column cells*/
border: 1px solid #6D6E70;
text-align: left;
width: 60%;
}
.td2 {
/*left column cells bold*/
border-bottom: 1px solid #6D6E70;
border-top: 1px solid #6D6E70;
font-weight: bold;
vertical-align: top;
}
.td3 {
/*last cell right column*/
border: 1px solid #6D6E70;
border-radius: 0px 0px 20px 20px;
text-align: left;
width: 60%;
}
.td4 {
/*last cell left column*/
vertical-align: top;
font-weight: bold;
border-top: 1px solid #6D6E70;
}
.td5 {
/*left column first cells*/
border-bottom: 1px solid #6D6E70;
font-weight: bold;
vertical-align: top;
}
<table>
<tr>
<td class="td5"></td>
<td class="h1">My top corners should be round</td>
</tr>
<tr>
<td class="td2">bla</td>
<td class="td1">blabla</td>
</tr>
<tr>
<td class="td4">last row</td>
<td class="td3">my bottom corners should be round</td>
</tr>
</table>
Have you tried this?
td
{
border-radious:0px;
}

The anchor tag link is not working

I am implementing notifications. I have integrated the whole backend with the front end.
I have Notification HTML as :
<span id="notification_count" style="display: none"></span>
<img alt="" src="assets/img/notification-icon.jpg">
<div id="notificationContainer">
<div id="notificationTitle">Notifications</div>
<div id="notificationsBody">
<table style="text-align: center;">
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
</table>
</div>
<div id="notificationFooter"></div>
</div>
And CSS :
#nav{list-style:none;margin: 0px;padding: 0px;}
#nav li {
float: left;
margin-right: 20px;
font-size: 14px;
font-weight:bold;
}
#nav li a{color:#333333;text-decoration:none}
#nav li a:hover{color:#006699;text-decoration:none}
#notification_li
{
position:relative
}
#notificationContainer
{
background-color: #fff;
border: 1px solid rgba(100, 100, 100, .4);
-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
overflow: visible;
color : #ffffff;
position: absolute;
top: 30px;
margin-left: -170px;
width: 400px;
z-index: -1;
display: none; // Enable this after jquery implementation
}
// Popup Arrow
#notificationContainer:before {
content: '';
display: block;
position: absolute;
width: 0;
height: 0;
border: 10px solid black;
border-color: transparent transparent white;
margin-top: -20px;
margin-left: 188px;
}
#notificationTitle
{
text-align: center;
font-weight: bold;
padding: 8px;
font-size: 12px;
background-color: #ffffff;
border-bottom: 1px solid #dddddd;
color: #555;
}
#notificationsBody
{
padding: 33px 0px 0px 0px !important;
min-height:300px;
}
#notificationFooter
{
background-color: #e9eaed;
text-align: center;
font-weight: bold;
padding: 8px;
font-size: 12px;
border-top: 1px solid #dddddd;
}
#notification_count
{
padding: 3px 7px 3px 7px;
background: #cc0000;
color: #ffffff;
font-weight: bold;
margin-left: 25px;
border-radius: 9px;
-moz-border-radius: 9px;
-webkit-border-radius: 9px;
position: absolute;
margin-top: -11px;
font-size: 11px;
}
But the a tags in the notificationsBody are not working. On clicking these a tags nothing is happening.
Please tell what is the issue. There might some problem in the z index. Please help me out.
You can use onclick event to open a link
123
Your HTML is invalid and is a likely cause of your problem.
You aren't allowed to put links as children of table rows. Only table cells may go there.
Use a validator and fix the errors.

How to move a circle down by 15px with CSS HTML

I would like to move the circle down by 15px with CSS as an image below. I've attempted with padding-bottom or margin-bottom in the .circle class, yet it did work in another way as making the circle longer than itself.
HTML:
<table id="showRoom">
<tr class="box_shadow">
<td>
<div class="news_column1">
<a target="_blank" href="http://google.com">
<span class="circle">P1</span>
<span class="imgswap">Showroom 1</span>
<div class="news_img">
<div>
<p>Book Now!</p>
</div>
</div>
</a>
</div>
</td>
</tr>
</table>
CSS:
body {
background-color: #F6F6F6;
}
#showRoom {
margin-left: 10px;
margin-top: 20px;
width: auto;
border-collapse: collapse;
}
table td {
padding: 0;
}
table .box_shadow {
background-color: #FFF;
font-size: 18px;
line-height: 20px;
text-align: center;
font-weight: normal;
font-family: 'Scada', sans-serif;
display: block;
-webkit-box-shadow: -4px 4px 5px 0px rgba(50, 50, 50, 0.3);
-moz-box-shadow: -4px 4px 5px 0px rgba(50, 50, 50, 0.3);
box-shadow: -4px 4px 5px 0px rgba(50, 50, 50, 0.3);
}
table tr .text_plant_address {
background-color: #FFF;
width: 200px;
height: 200px;
line-height: 20px;
text-align: center;
font-weight: normal;
font-family: 'Scada', sans-serif;
margin: 0;
padding: 0;
}
table tr td span {
height: 195px;
width: auto;
}
table tr td div {
width: 200px;
height: 200px;
position: relative;
}
table tr td a {
text-decoration: none;
}
table tr td .text_plant {
border-bottom: 1px solid #D0D0D0;
font-family: ballpark_weiner, Arial;
font-size: 26px;
letter-spacing: 1px;
padding: 0 15px;
}
table tr td .text_address {
font-size: 10px;
font-family: Arial;
display: block;
position: relative;
height: auto;
margin-top: 5px;
}
.news_column1 {
background-color: #FF7F7F;
/*background-color: #FFF;*/
/*border-radius: 15px;*/
}
table tr td div:hover {
cursor: pointer;
}
.news_img {
width: 200px;
height: 70px;
text-align: center;
background-color: rgba(0, 0, 0, 0.4);
font-family: 'Times New Roman';
font-weight: bold;
letter-spacing: 0.5px;
display: none;
position: absolute;
bottom: 0;
left: 0;
opacity: 0.95;
/*border-radius: 0 0 15px 15px;*/
}
.news_img div {
width: 200px;
height: 10px;
margin: 0;
padding: 0;
display: table-cell;
vertical-align: middle;
}
.news_img div p {
display: block;
margin-top: 25px;
font-size: 17px;
color: #FFF;
transform: rotate(-10deg);
-ms-transform: rotate(-10deg);
/* IE 9 */
-webkit-transform: rotate(-10deg);
/* Opera, Chrome, and Safari */
}
span.circle {
width: 100px;
height: 100px;
font-size: 30px;
color: #fff;
line-height: 100px;
text-align: center;
background-color: #111111;
opacity: 0.3;
display: block;
margin: 0 50px 0 50px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
}
span.imgswap {
display: block;
opacity: 0.5;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
font-family: sans-serif;
font-size: 20px;
padding-top: 10px;
font-family: Stark;
letter-spacing: 0.5px;
}
JSFIDDLE: http://jsfiddle.net/huydq91/rB5hX/7/
Just need to add padding to;
table tr td div {
width: 200px;
height: 200px;
position: relative;
padding-top:15px;
}
UPDATED JS FIDDLE
One solution is to add a padding-top:15px; to div.news_column1 as in this JFiddle snippet.
A question: are you stuck with the markup or do you have freedom to change it?
Make Changes in following class. It will come circle below
table tr td a {
text-decoration: none;
display: block;
padding: 40px 0 0 0;
}
and Reduce the height in following class
table tr td span
{
//height:''
}