问题描述:

I have this code: http://jsfiddle.net/LW9DJ/1/

Now i want the overlay text to appear centered (wich is currently working) but i dont want the css class 'mycell' to have the width or height attributes setted, i want them inherited from 'container' class.

This is because i am going to implement this in a responsive website in wich the width and height of 'container' class are automatically changed.

<div class="container">

<img src="http://i.imgur.com/o7iAFMu.jpg" class="test" />

<div class="overlay">

<div class="mycell">Some Text</div>

</div>

</div>

网友答案:

You should make left-margin and right-margin properties of style, auto. When you assign auto values to these two properties, the div would be located at the center.

相关阅读:
Top