I have a parent container that has some text (anonymous block) and a child element (a div or a pseudo-element). I am taking a look to the Image Replacement Museum but am not sure about what is the best solution for my case.
I need to hide the text and still display the inner div.
<div class="parent">
Some text
<!--<div class="child">
</div>-->
</div>
.parent {
display:table;
}
.child,
.parent:after {
display:table-cell;
vertical-align: middle;
text-align: center;
}
.parent:after {
content: "Icon";
}
How can I hide "Some text" maintaining my child element in the flow (so no position:absolute
; child should resize the parent) and vertically/horizontally centered?
Note: the only size I know is the width
of the child; all the other measures should be flexible and assumptions should not be made.
[EDIT] I need to maintain the support for screen readers so that the original text would be still read.
Moreover wrapping the text in an element is not always possible for me (I would like a CSS solution).