html - How to improve the positioning code? -
html - How to improve the positioning code? -
the next code positioning text on image. requirements are:
image should adapt screen automatically. on smart phone, image should displayed completely. showing part of image not allowed. text should accurately positioned anywhere wish. class="snippet-code-css lang-css prettyprint-override">.txtimg{ position: relative; overflow: auto; color: #fff; border-radius: 5px; } .txtimg img{ max-width: 100%; height: auto; } .bl, .tl, .br, .tr{ margin: 0.5em; position: absolute; } .bl{ bottom: 0px; left: 0px; } .tl{ top: 0px; left: 0px; } .br{ bottom: 0px; right: 0px; } .tr{ top: 0px; right: 0px; }
class="snippet-code-html lang-html prettyprint-override"><div class="txtimg"> <img src="http://vpnhotlist.com/wp-content/uploads/2014/03/image.jpg"> <p class="bl">(text appear @ bottom left of image)</p> <p class="tr"> (text appear @ top right of image)</p> </div>
however, bottom left text hide displayed on firefox browser.
it wired code snippet runs pretty in stackoverflow clicking run code snippet
below.
i don't know why. anywhere found solution: alter overflow:auto
overflow:visible
. problem disappear.
anyone advice?
i can't reproduce problem on specific code, know problem. add together vertical-align on image.
.txtimg img { max-width: 100%; height: auto; vertical-align: bottom; }
this work :
.txtimg img { max-width: 100%; height: auto; display: inline-block; }
html css css-position smartphone
Comments
Post a Comment