It should be like
It should be 4 rows and 3 colums. In first column centrall cell takes 2 cells. In second it should be 1 row. And third the same as first
I have this code
<table border="1" width="100%">
<thead></thead>
<tbody>
<tr>
<td>1</td>
<td rowspan="4">2</td>
<td>3</td>
</tr>
<tr>
<td rowspawn="2">4</td>
<td rowspawn="2">5</td>
</tr>
<tr>
<td>6</td>
<td>7</td>
</tr>
</tbody>
</table>
But it looks like this
I am not 100% sure what you are after however, does this give you what you want?
<table border="1" width="100%">
<thead></thead>
<tbody>
<tr>
<td>1</td>
<td rowspan="4">2</td>
<td>3</td>
</tr>
<tr>
<td style="height:200px;" rowspawn="2">4</td>
<td rowspawn="2">5</td>
</tr>
<tr>
<td>6</td>
<td>7</td>
</tr>
</tbody>
</table>
<table height="200px" width="900px" border="1px solid black">
<tr>
<td></td>
<td rowspan="4"></td>
<td></td>
</tr>
<tr>
<td rowspan="2"></td>
<td rowspan="2"></td>
</tr>
<tr>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
Try this code. It Works.
I am using anchor elemnts in an html table and want to add some padding to the top of the viewport. I figured out, that I can place the anchor in a dummy DIV element inside of the TD element to achieve this. However I also want to highlight the targets table row.
How can I achieve this without javascript?
I have tried several solutions from
HTML position:fixed page header and in-page anchors,
but they all do not work well in html tables.
Here is some minimal working example.
The "D" anchor has correct highlighting, but positioning does not
work.
The "E" anchor has correct positioning, but no highlighting.
tr:target {
color: #ee4444;
position: relative;
top: -40px;
}
div:target {
color: #ee4444;
position: relative;
top: -40px;
}
go to D go to E
<table>
<tr>
<th>Symbol</th>
<th>1932 ITU/ICAN Phonetic</th>
</tr>
<tr>
<td>A</td>
<td>Amsterdam</td>
</tr>
<tr>
<td>B</td>
<td>Baltimore</td>
</tr>
<tr>
<td>C</td>
<td>Casablanca</td>
</tr>
<tr id="D">
<td>D</td>
<td>Denmark</td>
</tr>
<tr>
<td>
<div id="E"></div>E</td>
<td>Edison</td>
</tr>
<tr>
<td>F</td>
<td>Florida</td>
</tr>
<tr>
<td>G</td>
<td>Gallipoli</td>
</tr>
<tr>
<td>H</td>
<td>Havana</td>
</tr>
<tr>
<td>I</td>
<td>Italia</td>
</tr>
<tr>
<td>J</td>
<td>Jerusalem</td>
</tr>
<tr>
<td>K</td>
<td>Kilogramme</td>
</tr>
<tr>
<td>L</td>
<td>Liverpool</td>
</tr>
<tr>
<td>M</td>
<td>Madagascar</td>
</tr>
<tr>
<td>N</td>
<td>New York</td>
</tr>
<tr>
<td>O</td>
<td>Oslo</td>
</tr>
<tr>
<td>P</td>
<td>Paris</td>
</tr>
<tr>
<td>Q</td>
<td>Quebec</td>
</tr>
<tr>
<td>R</td>
<td>Roma</td>
</tr>
<tr>
<td>S</td>
<td>Santiago</td>
</tr>
<tr>
<td>T</td>
<td>Tripoli</td>
</tr>
<tr>
<td>U</td>
<td>Upsala</td>
</tr>
<tr>
<td>V</td>
<td>Valencia</td>
</tr>
<tr>
<td>W</td>
<td>Washington</td>
</tr>
<tr>
<td>X</td>
<td>Xanthippe</td>
</tr>
<tr>
<td>Y</td>
<td>Yokohama</td>
</tr>
<tr>
<td>Z</td>
<td>Zurich</td>
</tr>
</table>
The intended behaviour can be achieved if you consider combining both the initial solutions attempted into one standard, as demonstrated by the code snippet embedded below.
Create separate table-rows for your anchor points, assign your
respective ids to these elements.
Use the adjacent sibling combinator Ref (+) to
declare your pseudo-selector :target styles
Declare your anchor point table-row with absolute positioning and
use margin-top property values to offset the position instead of
the top property (as this will position the element n question
relative to the document or the closest containing/parent element with a relative positioning)
Code Snippet Demonstration:
table {
border-spacing: 0;
}
.anchor-row:target + tr {
color: #ee4444;
}
.anchor-row {
position: absolute;
margin-top: -40px;
}
go to D go to E
<table>
<tr>
<th>Symbol</th>
<th>1932 ITU/ICAN Phonetic</th>
</tr>
<tr>
<td>A</td>
<td>Amsterdam</td>
</tr>
<tr>
<td>B</td>
<td>Baltimore</td>
</tr>
<tr>
<td>C</td>
<td>Casablanca</td>
</tr>
<tr class="anchor-row" id="D">
<td colspan="2"></td>
</tr>
<tr>
<td>D</td>
<td>Denmark</td>
</tr>
<tr class="anchor-row" id="E">
<td colspan="2"></td>
</tr>
<tr>
<td>E</td>
<td>Edison</td>
</tr>
<tr>
<td>F</td>
<td>Florida</td>
</tr>
<tr>
<td>G</td>
<td>Gallipoli</td>
</tr>
<tr>
<td>H</td>
<td>Havana</td>
</tr>
<tr>
<td>I</td>
<td>Italia</td>
</tr>
<tr>
<td>J</td>
<td>Jerusalem</td>
</tr>
<tr>
<td>K</td>
<td>Kilogramme</td>
</tr>
<tr>
<td>L</td>
<td>Liverpool</td>
</tr>
<tr>
<td>M</td>
<td>Madagascar</td>
</tr>
<tr>
<td>N</td>
<td>New York</td>
</tr>
<tr>
<td>O</td>
<td>Oslo</td>
</tr>
<tr>
<td>P</td>
<td>Paris</td>
</tr>
<tr>
<td>Q</td>
<td>Quebec</td>
</tr>
<tr>
<td>R</td>
<td>Roma</td>
</tr>
<tr>
<td>S</td>
<td>Santiago</td>
</tr>
<tr>
<td>T</td>
<td>Tripoli</td>
</tr>
<tr>
<td>U</td>
<td>Upsala</td>
</tr>
<tr>
<td>V</td>
<td>Valencia</td>
</tr>
<tr>
<td>W</td>
<td>Washington</td>
</tr>
<tr>
<td>X</td>
<td>Xanthippe</td>
</tr>
<tr>
<td>Y</td>
<td>Yokohama</td>
</tr>
<tr>
<td>Z</td>
<td>Zurich</td>
</tr>
</table>
You can try below this.
tr:target {
color: #ee4444;
position:relative;
top:0px;
}
span:target {
color: #ee4444;
position:relative;
top:0px;
}
<tr id="D"><td>D</td><td>Denmark</td></tr>
<tr><td><span id="E">hello</span>E</td><td>Edison</td></tr>
I have a simple 3 column table (second code sample below). Most of the time it would be displayed on a wide-screen HD TV, so I would like the structure to be like the first code sample below, and yet depending on the width of the screen, if it's viewed on smaller screens instead of having 4 repeating columns groups, change it to 3, then 2 then 1 for phones. How can I do this with CSS/Media queries?
<table>
<tr>
<th>Time</th>
<th>Hole</th>
<th>Player</th>
<th>Time</th>
<th>Hole</th>
<th>Player</th>
<th>Time</th>
<th>Hole</th>
<th>Player</th>
<th>Time</th>
<th>Hole</th>
<th>Player</th>
</tr>
<tr>
<td>12:06 PM</td>
<td>2</td>
<td>Ackerman</td>
<td>11:53 AM</td>
<td>3</td>
<td>Alexander</td>
<td>12:04 PM</td>
<td>3</td>
<td>Allan</td>
<td>02:00 PM</td>
<td>2</td>
<td>Allen</td>
</tr>
</table>
<table>
<tr>
<th>Time</th>
<th>Hole</th>
<th>Player</th>
</tr>
<tr>
<td>12:06 PM</td>
<td>2</td>
<td>Ackerman</td>
</tr>
<tr>
<td>11:53 AM</td>
<td>3</td>
<td>Alexander</td>
</tr>
<tr>
<td>12:04 PM</td>
<td>3</td>
<td>Allan</td>
</tr>
<tr>
<td>02:00 PM</td>
<td>2</td>
<td>Allen</td>
</tr>
<tr>
<td>12:03 PM</td>
<td>1</td>
<td>Anderson</td>
</tr>
<tr>
<td>02:49 PM</td>
<td>3</td>
<td>Apple</td>
</tr>
<tr>
<td>02:53 PM</td>
<td>1</td>
<td>Campbell</td>
</tr>
<tr>
<td>02:15 PM</td>
<td>4</td>
<td>Deane</td>
</tr>
<tr>
<td>04:00 PM</td>
<td>1</td>
<td>Decker</td>
</tr>
<tr>
<td>10:31 AM</td>
<td>5</td>
<td>Esposito</td>
</tr>
<tr>
<td>02:41 PM</td>
<td>4</td>
<td>Estes</td>
</tr>
<tr>
<td>01:29 PM</td>
<td>2</td>
<td>Faidley</td>
</tr>
<tr>
<td>10:31 AM</td>
<td>5</td>
<td>Fisher</td>
</tr>
<tr>
<td>02:16 PM</td>
<td>4</td>
<td>Gaus</td>
</tr>
<tr>
<td>02:15 PM</td>
<td>3</td>
<td>Giancola</td>
</tr>
<tr>
<td>10:31 AM</td>
<td>5</td>
<td>Gibbons</td>
</tr>
<tr>
<td>02:13 PM</td>
<td>3</td>
<td>Hansen</td>
</tr>
<tr>
<td>02:51 PM</td>
<td>2</td>
<td>Healy</td>
</tr>
<tr>
<td>02:42 PM</td>
<td>4</td>
<td>Kain</td>
</tr>
<tr>
<td>04:01 PM</td>
<td>2</td>
<td>Kestner</td>
</tr>
<tr>
<td>02:12 PM</td>
<td>3</td>
<td>King</td>
</tr>
<tr>
<td>11:03 AM</td>
<td>2</td>
<td>Krieger</td>
</tr>
<tr>
<td>02:51 PM</td>
<td>3</td>
<td>Lee</td>
</tr>
</table>
Ok so I have updated my answer to be EXACTLY like your comment there are 3 tables next to eachother with 2 rows of information for an example...here is the code and here is the example site http://codepen.io/anon/pen/eNYvoq
<div class="container-full">
<div class="row">
<div class="col-md-2">
<ul>Time</ul>
<ul>12:06 PM</ul>
<ul>11:53 AM</ul>
</div>
<div class="col-md-1">
<ul>Hole</ul>
<ul>2</ul>
<ul>3</ul>
</div>
<div class="col-md-1">
<ul>Player</ul>
<ul>Ackerman</ul>
<ul>Alexander</ul>
</div>
<div class="col-md-2">
<ul>Time</ul>
<ul>12:06 PM</ul>
<ul>11:53 AM</ul>
</div>
<div class="col-md-1">
<ul>Hole</ul>
<ul>2</ul>
<ul>3</ul>
</div>
<div class="col-md-1">
<ul>Player</ul>
<ul>Ackerman</ul>
<ul>Alexander</ul>
</div>
<div class="col-md-2">
<ul>Time</ul>
<ul>12:06 PM</ul>
<ul>11:53 AM</ul>
</div>
<div class="col-md-1">
<ul>Hole</ul>
<ul>2</ul>
<ul>3</ul>
</div>
<div class="col-md-1">
<ul>Player</ul>
<ul>Ackerman</ul>
<ul>Alexander</ul>
</div>
</div>
</div>
If this doesnt answer your question then comment as to what is not matching what your asking.
This is my table and i like to select all td-s that contains a link.
This selector select all links in td, but i like to style td not link:
#wp-calendar > tbody > tr > td > a:link
My html table:
<table id="wp-calendar">
<tbody>
<tr>
<td colspan="5" class="pad"> </td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>10</td><td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
<tr>
<td>17</td><td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
</tr>
</tbody>
</table>
You cannot select an element in CSS based on its children or contents (other than whether its contents are :empty)
You will need to resort to using Javascript, e.g. in jQuery this can be done via, e.g. :has
$( "td:has(a)" )
How do you get position: sticky working?
I tried the following in Chrome 26.0.1410.43 m and it's not working:
thead {
position: -webkit-sticky;
position: -moz-sticky;
position: -ms-sticky;
position: -o-sticky;
position: sticky;
top: 10px;
}
http://jsfiddle.net/8LRms/
According to this, it should work:
http://updates.html5rocks.com/2012/08/Stick-your-landings-position-sticky-lands-in-WebKit
It seemed to be supported in Chrome 23.0.1247.0, but now it doesn't work in 26.0.1410.43 m.
For a short time, Chrome enabled this feature behind a flag, --enable-experimental-webkit-features, in their about:flags section. However, it was shortly removed due to inefficiencies in how the browser was repainting.
As of Chrome 56, this feature is enabled without a flag once again.
As of Chrome 52.0.2743.116, this feature is enabled by the flag --enable-experimental-webkit-features once more.
To answer the updated question about why it was removed: Google (Chromium) removed support for position: sticky due to the unfinished nature of the spec, and they will focus on other scrolling features in the mean-time:
"We would eventually like to implement position: sticky, but the current
implementation isn't designed in a way that integrates well with the existing
scrolling and compositing system. For example, position: sticky relies upon
updateLayerPositionsAfterDocumentScroll to function correctly, but that
function has no other purpose and can otherwise be removed. Similarly,
position: sticky doesn't work at all with composited overflow scrolling, which
is now the default mechanism for driving scrolling in the engine.
Once we've got our scrolling and compositing house in order, we should return
to position: sticky and implement the feature in a way that integrates well
with the rest of the engine. For now, however, this CL removes our current
implementation so we can focus on improving our implementation of the scrolling
features we've already shipped."
Emphasis mine. You can read more about it here.
EDIT: You need to launch with --enable-experimental-webkit-features flag enabled via about:flags.
Update: This does not work on Chrome v35 through v51, Chrome 52 reenables this with the experimental web platform features flag. Starting from Chrome 56 position: sticky works out of the box.
FilamentGroup released a nice polyfill for position: sticky. Have a look at: https://github.com/filamentgroup/fixed-sticky
It seems that it doesn't work on iOS7 Safari if there is a parent node with overflow: hidden property set.
When Chrome switched over to the Blink rendering engine with version 28, they dropped Webkit, which is the only engine to support this (on Mac and iOS.)
So unless you're using Safari on Mac or iOS, or Chrome on iOS (for now) you will not be able to support this in other browsers.
Sad, it's a great and easy way to float elements.
It does - now at least
Look up https://caniuse.com/#feat=css-sticky
You are targeting the <thead> while Chrome and the Blink engine(Chrome, Edge, Opera) does not support this. Gecko(Mozilla Firefox) and Webkit(Safari) does. Instead try to target the <th> instead as shown below.
Also overflow: hidden on a parent WILL break position:sticky
Be sure to include your vendor prefixes.
Run the snippet and it should show a functional sticky header.
thead > tr > th {
background: white;
position: -webkit-sticky;
position: -moz-sticky;
position: -ms-sticky;
position: -o-sticky;
position: sticky;
top: 10px;
}
<h1>Position sticky</h1>
<table>
<thead>
<tr>
<th>column 1</th>
<th>column 2</th>
<th>column 3</th>
<th>column 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</tbody>
</table>
The great news is that as of Chrome 56 (currently beta as of December 2016, stable in Jan 2017) position: sticky is now back in Chrome.
So, in the near future only Edge would be the only one of all browsers that hasn't implemented it still, except browsers for mobile devices, but I hope they would implement it also soon.