Volker E.
Volker E.

Reputation: 6044

Caption element and 100% width on nested tables

I'm using caption on a table that includes children table elements. Within the caption element I've got a div incl. two links that should be on the right edge of the uppermost table.
But as soon as I'm defining display: block; besides position: relative; on caption, it's size is shrinking to the first child table cell's width.

See http://jsfiddle.net/Volker_E/zjFmv/

The important CSS selectors:

table {
    width: 100%;
    margin-bottom: 1.8rem;
    border-collapse: collapse;
    border-spacing: 0;
}

caption {
    background: none repeat scroll 0 0 #F5F5F5;
    text-align: left;
    padding: 1rem 1.4rem;
    overflow: hidden;
}
/* Variations */
.caption-01 {
    position: relative;
}
.caption-02 {
    display: block;
    position: relative;
}
.caption-03 {
    display: table-header-group;
}

caption div {
    position: absolute;
    right: 0;
    text-align: right;
    top: 10px;
    width: 50%;
    white-space: nowrap;
}

Is there a way to let the div be on right edge of caption at full primary table width in my construct?

Thanks in advance.

Upvotes: 2

Views: 3808

Answers (1)

Moishy
Moishy

Reputation: 3638

Remove the display properties form caption 2 & 3

.caption-02 {
    position: relative;
}
.caption-03 {
}

Jsfiddle

Upvotes: 0

Related Questions