tags:

views:

27

answers:

3

I am modifying a skin for the CKEdit component so that the toolbar is hidden unless clicked. To do so, I moved the toolbar collapser to the row below it using position: relative and top:18px.

My goal is to have the parent tr of the anchor element a height of 2px, but keep the anchor at 11px. Is this possible? I cannot alter the DOM, just the styles.

Here's my reduced code

<style type="text/css">
    table { width: 80px;}
    td { border: solid 1px #ccc; }
    .header  
    {
        background-color: #99f;
        /* This is being ignored */
        height:2px; 
        }
    .below 
    {
        float: right; 
        position: relative;
        top: 18px;
        /*If I shrink,  the BG image goes Away*/
        height: 11px;
        width: 11px;
        background-image: url('http://ckeditor.com/apps/ckeditor/3.3/skins/kama/images/sprites.png');
        background-position: 4px -1387px;
        border: 1px outset #D3D3D3;
    }
    .hidden { display:none; }

</style>

<table>
<tr><td class="header"><a class="below"><span class="hidden">#</span></a></td></tr>
<tr><td>next row</td></tr>
</table>

am reposting new code per the suggestions below. This shows the arrow at the top right of the page now

<style type="text/css">
    table { width: 80px; position:relative;}
    td { border: solid 1px #ccc; }
    .header  
    {
        position: relative;
        background-color: #99f;
        /* This is being ignored */
        height:2px; 
        }
    .below 
    {
        float: right; 
        position: absolute;
        top: 6px;
        right: 2px;
        /*If I shrink,  the BG image goes Away*/
        height: 11px;
        width: 11px;
        background-image: url('http://ckeditor.com/apps/ckeditor/3.3/skins/kama/images/sprites.png');
        background-position: 4px -1387px;
        border: 1px outset #D3D3D3;
    }
    .hidden { display:none; }

</style>

<br /><br /><br /><br /><br /><br />
<table>
<tr><td class="header"><a class="below"><span class="hidden">#</span></a></td></tr>
<tr><td>next row</td></tr>
</table>

Edit (per comments):
If I add a relatively positioned div between the anchor and the cell, I can achieve the results, but again, I can't modify the DOM.

<td class="header">
<div style="position:relative; ">
    <a class="below"><span class="hidden">#</span></a>
</div>
</td>
A: 

RTFM my friend :)

@CKeditor, you can set the toolbar to startup hidden like so:

CKEDITOR.replace( 'editor1', {toolbarStartupExpanded : false} );

Hope it helps :)

Zuul
Unfortunately, I'm already doing that but it still leaves a 12px header to accommodate the collapse button. It's that button I'm trying to get into the next row. Thanks for the tip though:)
Laramie
+1  A: 

Try setting .below to position:absolute instead of relative then add left:69px (table width - anchor width).

EDIT

  td { border: solid 1px #ccc; }
.header  
{
    background-color: #99f;
    /* This is being ignored */
    height:2px; 
    position:relative;

    }
.below 
{
    float: right; 
    position: absolute;
    top: 18px;
    left:69px;
    /*If I shrink,  the BG image goes Away*/
    height: 11px;
    width: 11px;
    background-image: url('http://ckeditor.com/apps/ckeditor/3.3/skins/kama/images/sprites.png');
    background-position: 4px -1387px;
    border: 1px outset #D3D3D3;
}
.hidden { display:none; }
table { width: 80px; position:relative; }

and

<table>
<tr><td class="header"><a class="below"><span class="hidden">#</span></a></td></tr>
<tr><td>next row</td></tr>
</table>
edl
works for collapsing the title, but top then becomes relative to the page so I can't set the anchor down to the next row.
Laramie
Try setting .header to `position:relative;`
edl
no dice. mVChr suggested the same, but to the table. They're both set to relative now, and the arrow still shows at the top right of the page. re-posted adjusted code for demo
Laramie
If you don't mind setting absolute coordinates, set top:18px, left:69px; the css i put above works for me.
edl
Actually, Im getting different results in IE. Let me re-tinker. :)
edl
since the actual page was a bit more complicated, I got it to work applying your suggestions. Thanks.
Laramie
+1  A: 

Set position:relative on the <table> to make absolute positioning in children relative to it. Then add position:absolute on the <a class="below"> and adjust top and left to your liking. (see example)

table { display:block; position:relative; width:80px; }
.header { width:80px; }
.below {
  float: right; 
  position: absolute;
  top: 6px; right:2px; // adjust as needed
}

With the <a> positioned absolutely you're free to alter the parent <td> height as if it doesn't contain .below

EDIT: For it to work in FF needed to add display:block to the table and duplicate the width in .header (see updated example)

mVChr
same as above:( It sets the anchor to the top right of the page, not the table. It's good to know how that works though. Am I stuck?
Laramie
re-posted adjusted code per your suggestion.
Laramie
Interesting. It works in Safari/Chrome. It doesn't in FF because it doesn't like adding relative position to table elements for some reason. If I wrap a div around the table and add relative position to that then it works, but obviously that's not a solution for you. Will see if I can figure something else out, but seems tricky now.
mVChr
@Laramie Ok, figured it out, see update.
mVChr
Nice catch. I was trying the same thing while you were leaving the comment. I only tested in Firefox. It works in IE/Chrome, and as you said, with the shim div in Firefox. Odd.
Laramie
@mVChr Still displays at top right of page in FF. btw, jsfiddle is a great tool.
Laramie
since the actual page was a bit more complicated, I got it to work applying your suggestions. Thanks.
Laramie