4

How to make foo invisible using CSS (CSS3 if needed) while keeping bar and fizz visible?

<table>
  <tr>
    <td>
      <textarea>bar</textarea>
      <input type='button' title='fizz' />
      foo
    </td>
  </tr>
</tbody>

Making foo in the same color as background is acceptable, but the trick is - background is an image, hence - foo must be transparent instead of solid color.

JavaScript isn't an option either.

Changing HTML is not an option either.

Any ideas?

2
  • Can the real text you're representing with "foo" be identified? That is, could you select it in javascript? Commented Jul 23, 2010 at 17:00
  • I know you accepted another answer, but you have got to check out the second part of my answer, I cannot believe it worked! Commented Jul 23, 2010 at 17:34

7 Answers 7

9

This worked fine in IE8 and Firefox (IE7 left little dots for words, which I guess if you set the font-color to something that blends with the background image, it might do fine. Note that this does not affect either the text-area or the input for any text in them.

td {font-size: 0;}

ADDED ON EDIT

WOW I mean, really! This worked on IE7-8, Firefox, and Safari

td {visibility: hidden}
td textarea,
td input {visibility: visible;}

As a side note, I tested this with elements wrapped in div rather than a table, I even did a div in a div and the inner div shows while other content is hidden.

Apparently, the visibility property acts on the element, and (unlike opacity) propagates to the child elements by inheritance, so that if one explicitly sets a child element visibility it no longer inherits the hidden but uses its own setting of visible and the fact that the wrapper is hidden does not matter.

Sign up to request clarification or add additional context in comments.

1 Comment

This is vaguely what I thought of, but I reasoned you can't re-visible-ize a child element. I guess you can...
3

EDIT: Scott's is better. Use his.

I don't think a proper solution is going to be pretty.

td {
    position: relative;
    left: 9001px;
}

textarea {
    position: relative;
    right: 9001px;
}

5 Comments

I was just about to post the same thing. Bravo!
But what happens when somebody comes along that has a 12000px screen? This would have been my solution also so I will vote you up. :-)
It helped. Things look real fancy now.
Just wanted you to be aware, I discovered a better way (see second part of my answer)
@Justin, Then have some JavaScript to wrap the text and hide it. I'm not sure we'll see 12000px displays any time soon, and by then people will probably have JS enabled anyway.
1

If you don't have to support IE then setting the text to transparent is easy:

table {
    background-color: cyan;
}
td {
    color: rgba(255,255,255,0);
}
td textarea, td input {
    color: #000;
}

Comments

0

You need to put it inside a container like a div then hide the container ..

1 Comment

Sorry... Forgot to mention that can't change html either. :)
0

Set the size of the td to be the same as the size of the textarea (via CSS width and height), then set overflow: hidden on the TD so that the text you want to hide is outside the bounding box?

2 Comments

That might work... There's button before foo. I guess it must be set to display:block, right (some padding-bottom maybe)?
If you know the size of the button, you could add that to the size of the TD (and yes, set the button to block, so that the text will get pushed down below it).
0

whoops... should've read the OP a bit more closely. Guess the following won't work after all, since changing the html isn't an option.

Set a css class on the container you want to hide (the textarea?):

...
   <textarea class="hideme">bar</textarea>
...

and the following css:

.hideme {
   display: hidden;
}

'hidden' makes the element disappear (it's literally not displayed), but still is still accounted for in the document flow and takes up the space it normally would. If you want it to literally be gone and not have any effect on the document, then use display: none.

Comments

0

How about the reverse of Amber's suggestion -

Set overflow to overflow: hidden on the TD, fix the size where it is right now and add a huge padding-bottom on the textarea or button.

1 Comment

Don't know. Fixed with position:relative. Too lazy to check out. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.