I am creating a dynamic html page which result in a code similar to below:
<!DOCTYPE html>
<html>
<head>
<style>
.ini table, th, td {
border: 1px solid grey;
}
#hello table.tk-dtbl tbody tr td {
background-color: white;
}
#hello tbody>:nth-child(2){
height: 130px;
}
</style>
</head>
<body>
<div id ="hello">
<table>
<tr>
<td>first</td>
<td>second</td>
</tr>
<tr>
<td>third</td>
<td>fourth</td>
</tr>
<tr>
<td>This</td>
<td>
<div class="ini">
<table style="width:100%" >
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>fifth</td>
<td>sixth</td>
</tr>
<table>
</div>
</body>
</html>
Check the html rendered here
I want only the second row Containing third fourth to be of size 150px and not the second row inside class ini is there any way to prevent nth-child from modifying content inside div ini.
Also border property of ini is used in id ="hello" can that be prevented using html and css only.
Edit:
the table I am printing is dynamic one i.e.
it's code is something like
<uitk-tab-panel >
<uitk-dynamic-table id="hello" [model]="MyDetailModel"
[modelObservable]="MyDetails$"></uitk-dynamic-table>
</uitk-tab-panel>
values are present in MyDetailModel so cannot directly modify it.
You an modify the code as below to output the requirement. Add a new id for that specific which contain third and fourth. Also have a control over ini border by editing the css.
/** CSS **/
table, th, td {
border: 1px solid grey;
}
tr#h-150 {
height: 150px;
}
.ini table, .ini th, ini td {border: none}
<!-- HTML -->
<body>
<div id ="hello">
<table>
<tr>
<td>first</td>
<td>second</td>
</tr>
<tr id="h-150">
<td>third</td>
<td>fourth</td>
</tr>
<tr>
<td>This</td>
<td>
<div class="ini">
<table style="width:100%" >
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>fifth</td>
<td>sixth</td>
</tr>
<table>
</div>
</body>
Here is a part of my HTML code.
<link rel="stylesheet" href="{% static "css/mystyle.css" %}"/>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>Here are your patient records:</h1>
<h2>Go to /formpage to fill the form</h2>
{% if patients %}
<table>
<thead>
<th>Patient Name</th>
<th>Identity Document Number</th>
<th>Date of Birth</th>
<th>Date Case Confirmed</th>
<th>Case Number</th>
</thead>
{% for pat in patients %}
<tr>
<td>{{ pat.name }}</td>
<td>{{ pat.idn }}</td>
<td>{{ pat.date_of_birth }}</td>
<td>{{ pat.confirm_day }}</td>
<td>{{ pat.case_no }}</td>
</tr>
{% endfor %}
</table>
I want to edit the table according to my CSS rules.
h1{
color: red;
}
table, td, th{
border: 1px solid black;
}
table {
border-collapse: collapse;
}
However, the table does not respect the changes from CSS. Funny thing is, h1 header is actually following the CSS rule and is red.
What am I missing?
Try to inspect element the table and check if your border: 1px solid black; applies to the element (on inspect element window, on css box, make sure the text isn't in strikethrough), if the text is in strikethrough, try adding !important keyword next to black and before ;.
Your CSS gets applied to the table elements, you can check it with the developer tools in your browser.
Also a running example of your table:
h1 {
color: red;
}
table,
td,
th {
border: 1px solid black;
}
table {
border-collapse: collapse;
}
<h1>Here are your patient records:</h1>
<h2>Go to /formpage to fill the form</h2>
<table>
<thead>
<th>Patient Name</th>
<th>Identity Document Number</th>
<th>Date of Birth</th>
<th>Date Case Confirmed</th>
<th>Case Number</th>
</thead>
<tbody>
<tr>
<td>name</td>
<td>idn</td>
<td>date_of_birth</td>
<td>confirm_day</td>
<td>case_no</td>
</tr>
<tr>
<td>name</td>
<td>idn</td>
<td>date_of_birth</td>
<td>confirm_day</td>
<td>case_no</td>
</tr>
<tr>
<td>name</td>
<td>idn</td>
<td>date_of_birth</td>
<td>confirm_day</td>
<td>case_no</td>
</tr>
</tbody>
</table>
I need to do a project in school but we have to follow set example. How can I change text color in a table?
I have already tried many things but they only work with CSS or HTML5.
<center><table bgcolor="black" color="yellow" border =2 cell pading=30 cell spacing=10 >
You try this way:
<table style="color: yellow;" bgcolor="black">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
This is good to know that center tag obsoleted.
With plain HTML you would use an old and deprecated tag <font> as also you're using <center> which is also obsolete, but without CSS nor HTML5 ...
Here's how it'd look like :
<center>
<table bgcolor="black" color="yellow" border =2 cell pading=30 cell spacing=10 >
<tr>
<td>
<span>
<font color="yellow"> Testing</font>
</span>
</td>
</tr>
</table>
</center>
you can set style for your table:
table {
color: yellow;
background-color: black;
}
table td, th {
padding: 30px;
border: 1px solid white;
}
<table>
<tbody>
<tr>
<th>Name</th>
</tr>
<tr>
<td>Name 1</td>
</tr>
<tr>
<td>Name 2</td>
</tr>
</tbody>
</table>
I have a screenshot as show below which I have replicated in Bootstrap 4.
In the screenshot, on row hover the background-color: #EDEDED; shows up.
Here is the fiddle for the above screenshot.
The HTML code which I have used in order to create the table is :
<div class="body-manage-attendees">
<table class="table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Number</th>
<th scope="col">Table</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Amanda Doe</th>
<td>250</td>
<td>2</td>
<td>Bill</td>
</tr>
<tr>
<th scope="row">Andy Doe</th>
<td>14</td>
<td>1</td>
<td>Bill</td>
</tr>
<tr>
<th scope="row">Cameron Doe</th>
<td>250</td>
<td>4</td>
<td>No Bill</td>
</tr>
<tr>
<th scope="row">Dana Doe</th>
<td>53</td>
<td>5</td>
<td>Bill</td>
</tr>
<tr>
<th scope="row">Fred Doe</th>
<td>250</td>
<td>2</td>
<td>Bill</td>
</tr>
</tbody>
</table>
</div>
Problem Statement:
I am wondering what I need to add in the CSS so that on row hover, the background-color: #EDEDED; appears.
The bootstrap 3 class appears to still work. Try adding the hover class to your table.
<table class="table table-hover">
By doing so, this CSS class from bootstrap is applied:
.table-hover tbody tr:hover {
background-color: rgba(0,0,0,.075);
}
Feel free to override that class and change the color to whatever you wish!
Add .table-hover class to your table:
<table class="table table-hover">
Alterinatively you an also use CSS:
table.table tr:hover td, table.table tr:hover th {
background-color: #EDEDED;
}
Edit: updated JSFiddle
I'm kinda stuck with a CSS problem while using Bootstrap. I'm also using Angular JS with Angular UI.bootstrap (which might be part of the problem).
I'm making a website that displays data in a table.
Sometime, the data contains object that I have to display in tables.
So I want to put borderless tables inside a normal table while keeping inside separation lines for the borderless tables.
But it seems that even if I specifically say to not show the borders on a table, it is forced:
HTML:
<table class='table borderless'>
CSS:
.borderless table {
border-top-style: none;
border-left-style: none;
border-right-style: none;
border-bottom-style: none;
}
So here, what I want is just the inside borders.
Using Bootstrap 3.2.0 I had problem with Brett Henderson solution (borders were always there), so I improved it:
HTML
<table class="table table-borderless">
CSS
.table-borderless > tbody > tr > td,
.table-borderless > tbody > tr > th,
.table-borderless > tfoot > tr > td,
.table-borderless > tfoot > tr > th,
.table-borderless > thead > tr > td,
.table-borderless > thead > tr > th {
border: none;
}
The border styling is set on the td elements.
html:
<table class='table borderless'>
css:
.borderless td, .borderless th {
border: none;
}
Update: Since Bootstrap 4.1 you can use .table-borderless to remove the border.
https://getbootstrap.com/docs/4.1/content/tables/#borderless-table
similar to the rest, but more specific:
table.borderless td,table.borderless th{
border: none !important;
}
Don’t add the .table class to your <table> tag. From the Bootstrap docs on tables:
For basic styling—light padding and only horizontal dividers—add the base class .table to any <table>. It may seem super redundant, but given the widespread use of tables for other plugins like calendars and date pickers, we've opted to isolate our custom table styles.
Since Bootstrap v4.1 you can add table-borderless to your table, see official documentation:
<table class='table table-borderless'>
Install bootstrap either with npm or cdn link
<table class="table table-borderless">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td colspan="2">Larry the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
get the reference with this link
In my CSS:
.borderless tr td {
border: none !important;
padding: 0px !important;
}
In my directive:
<table class='table borderless'>
<tr class='borderless' ....>
I didn't put the 'borderless' for the td element.
Tested and it worked!
All the borders and paddings are completely stripped off.
I expanded the Bootstrap table styles as Davide Pastore did, but with that method the styles are applied to all child tables as well, and they don't apply to the footer.
A better solution would be imitating the core Bootstrap table styles, but with your new class:
.table-borderless>thead>tr>th
.table-borderless>thead>tr>td
.table-borderless>tbody>tr>th
.table-borderless>tbody>tr>td
.table-borderless>tfoot>tr>th
.table-borderless>tfoot>tr>td {
border: none;
}
Then when you use <table class='table table-borderless'> only the specific table with the class will be bordered, not any table in the tree.
Try this:
<table class='borderless'>
CSS
.borderless {
border:none;
}
Note: What you were doing before was not working because your css code was targeting a table within your .borderless table (which probably didn't exist)
I know this is an old thread and that you've picked an answer, but I thought I'd post this as it is relevant for anyone else that is currently looking.
There is no reason to create new CSS rules, simply undo the current rules and the borders will disappear.
.table>tbody>tr>th,
.table>tbody>tr>td {
border-top: 0;
}
going forward, anything styled with
.table
will show no borders.
Use the border- class from Boostrap 4
<td class="border-0"></td>
or
<table class='table border-0'></table>
Be sure to end the class input with the last change you want to do.
Use hidden instead of none:
.hide-bottom {
border-bottom-style: hidden;
}
This one worked for me.
<td style="border-top: none;">;
The key is you need to add border-top to the <td>
I'm late to the game here but FWIW: adding .table-bordered to a .table just wraps the table with a border, albeit by adding a full border to every cell.
But removing .table-bordered still leaves the rule lines. It's a semantic issue, but in keeping with BS3+ nomenclature I've used this set of overrides:
.table.table-unruled>tbody>tr>td,
.table.table-unruled>tbody>tr>th {
border-top: 0 none transparent;
border-bottom: 0 none transparent;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-xs-5">
.table
<table class="table">
<thead>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tbody>
<tfoot>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</tfoot>
</table>
</div>
<div class="col-xs-5 col-xs-offset-1">
<table class="table table-bordered">
.table .table-bordered
<thead>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tbody>
<tfoot>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-5">
<table class="table table-unruled">
.table .table-unruled
<thead>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tbody>
<tfoot>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</tfoot>
</table>
</div>
<div class="col-xs-5 col-xs-offset-1">
<table class="table table-bordered table-unruled">
.table .table-bordered .table-unruled
<thead>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tbody>
<tfoot>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
Most examples seem to be too specific and/or bloated.
Here was my trimmed down solution using Bootstrap 4.0.0 (4.1 includes .table-borderless but still alpha)...
.table-borderless th{border:0;}
.table-borderless td{border:0;}
Similar to many proposed solutions, but minimal bytes 😉
Note: Ended up here because I was viewing BS4.1 references and couldn't figure out why .table-borderless was not working with my 4.0 sources (eg: operator error, duh) 💩
In some cases, one must also use border-spacing in the table class, like:
border-spacing: 0 !important;
Bootstrap supports scss, and he has a special variables. If this is a case then you can add in your main variables.scss file
$table-border-width: 0;
More info here https://github.com/twbs/bootstrap/blob/6ffb0b48e455430f8a5359ed689ad64c1143fac2/scss/_variables.scss#L347-L380
Mi solucion fue esta:
<table width="100%" border='0'>
<tr align='center'>
<td>Data1</td>
<td>Data2</td>
</tr>
</table>