css-tables

Different CSS style on odd and even rows

霸气de小男生 提交于 2019-12-04 07:55:06
Is it possible, using only CSS, to set different styles on odd and even rows for a dynamically generated table without myself setting correct style on each row when I iterate the collection? I'm not sure this will work cross-browser, i'd prefer jQuery myself, but css-only this should do the trick: tr:nth-child(even) { ... } tr:nth-child(odd) { ... } Jeff Storey You can use the nth-child selector http://reference.sitepoint.com/css/pseudoclass-nthchild , though it is not supported by all browsers. You can also use jquery as described What is the best way to style alternating rows in a table? You

How to force space inbetween a css table (responsive webpage)

☆樱花仙子☆ 提交于 2019-12-04 07:06:32
问题 I have a CSS table and I would like to have space in-between the cells but not at the left of the first image and the right of the last image. Here is a screenshot of what I have: Here is a screenshot of what I would like: The current HTML is: <div id="footer"> <div class="lower"><img src="images/one.jpg" alt="Ring being put on finger"/></div> <div class="lower"><img src="images/two.jpg" alt="The mens trousers"/></div> <div class="lower"><img src="images/three.jpg" alt="Flowers"/></div> <div

Why does table-caption increase the height of the table?

北城以北 提交于 2019-12-04 03:32:15
问题 Both tables have their height set to 50px and their content is not overflowing. But the table with a caption is actually 70px, because the caption does not appear to be included in the table's height calculation. Can anyone explain the rational for not including the caption in the calculation of the table height? It's a child of the table after all. And if you wanted to exclude it from the table height, could place just the caption outside the table if you didn't want it included. .table {

Issue with applying dotted border to cells in table design

末鹿安然 提交于 2019-12-04 01:15:27
问题 Here's my fiddle: http://jsfiddle.net/gFA4p/84/ In this screenshot, the green lines represent where I'm trying to apply dotted lines. I am able to get the left-right borders to appear as dotted lines, but not the bottom borders. How can I resolve this? 回答1: The issue you're seeing is due to the rules of conflict resolution when it comes to border collapse. Solid takes precedence over dotted: http://lachy.id.au/dev/css/tests/bordercollapse/bordercollapse.html I believe you will need to make

CSS Alternate Rows - some rows hidden

岁酱吖の 提交于 2019-12-03 22:26:16
I'm trying to style a table so that each row is a different colour (odd/even). I have the following CSS: #woo tr:nth-child(even) td { background-color: #f0f9ff; } #woo tr:nth-child(odd) td { background-color: white; } However, some of my rows can be hidden and I'd still like the rows to alternate. How can I adjust the above so it gives the appearance of alternate rows, even if the rows that are next to each others aren't necessarily odd and even? If you are using jQuery, you can employ one of its functions, for example .filter() , to choose only the elements that are visible. But the key here

Adjust table column width to content size

半城伤御伤魂 提交于 2019-12-03 22:18:59
Form (with firebug highlight hover the td): Label column CSS : width: auto; padding: 0; margin: 0; The problem : Why my left columns have that invisible "padding-right"? It's not possible to shrink columns to fit their content? --EDIT-- The problem was the table itself. I defined table with "width: 100%". Removed that and the problem is gone. Rui Carneiro The problem was the table width. I had used width: 100% for the table. The table columns are adjusted automatically after removing the width tag. If you want the table to still be 100% then set one of the columns to have a width:100%; That

How to make a table cell shrink width to fit only its contents?

时间秒杀一切 提交于 2019-12-03 15:16:43
问题 I want the table to have 100% width, but only one column from it should have a free width, like: | A | B | C | so the width of A and B columns should match the width of their contents, but the width of C should go on until the table ends. Ok I could specify the width of of A and B in pixels, but the problem is that the width of the contents of these columns is not fixed, so if I set a fixed width it wouldn't match the contents perfectly :( PS: I'm not using actual table items, but a DL list

Table with Rowspan Hover and Zebra effect

狂风中的少年 提交于 2019-12-03 15:04:11
问题 I am trying to create a table that has a rowspan, zebra effect and highlights the row on hover. I kind of got it working but not quite. It should be like this: http://codepen.io/chriscoyier/pen/wLGDz plus a zebra effect on the rows. Unfortunately a zebra effect using jQuery or CSS does not work for me as the lines won't change on hover if I do that. Any suggestions? 回答1: Something like this? http://codepen.io/anon/pen/gcBlH Basically, doing: $("tr :even").css('background', '#ccc') and .hover

How to stretch background image of a table cell with CSS?

风格不统一 提交于 2019-12-03 13:58:46
How can I stretch background image of a table cell with CSS? I have Googled it with no results. When you set background image of a cell and the background size is smaller than the cell, then it will be repeated. How can I force this background to stretch the entire table cell instead? You can't stretch a background image. If you want to stretch an image, you have to put it in an img tag. You can use absolute positioning to put content on top of the image. It is possible to stretch a background image using the background-size CSS property . Examples: body { background-size: 100% auto } /*

Lock table cells to their default size regardless of content

谁说胖子不能爱 提交于 2019-12-03 13:09:47
If I have <table> <tr> <td></td> <td></td> </tr> <tr> <td></td> <td></td> </tr> </table> and table { width: 100%; height: 100%; } Each cell takes up an equal quarter of the table, and the table stretches to fit the window. How can I prevent these table cells from resizing themselves to fit the content within the cells (while still fitting the table's container)? You could try table-layout:fixed; - this sets the layout to a certain fixed size (specified in CSS) and ignores the content of the cells, so the width of the cell never changes. I'm not sure if this affects vertical layout or not. More