html - How to use CSS to place text on different sizes of images? -


i have bunch of photos different sizes , place texts on left-hand corner , right-hand corner. how achieve this?

here's example code of i'm trying do.

http://jsfiddle.net/noppanit/29pgw/

<div class="content" id="panel_photos"> <p>popular photos</p>   <div class="tweet_photo">     <img src="http://pbs.twimg.com/media/bh_yprmimaasiye.jpg" />     <span class="twitter_name">@twitter_name</span>               <span class="someother">something_cool</span>   </div>   <div class="tweet_photo">     <img src="http://pbs.twimg.com/media/bh-td9iiuaahu8-.jpg" />     <span class="twitter_name">@twitter_name</span>     <span class="someother">something_cool</span>   </div>   <div class="tweet_photo">     <img src="http://pbs.twimg.com/media/bh7ceuwccaamy2c.jpg" />     <span class="twitter_name">@twitter_name</span>               <span class="someother">something_cool</span>   </div>   <div class="tweet_photo">     <img src="http://pbs.twimg.com/media/bh6bqxkiiaaz0i4.jpg" />     <span class="twitter_name">@twitter_name</span>               <span class="someother">something_cool</span>   </div>   <div class="tweet_photo">     <img src="http://pbs.twimg.com/media/bh5cdniigaahhsh.jpg" />     <span class="twitter_name">@twitter_name</span>               <span class="someother">something_cool</span>   </div>   <div class="tweet_photo">     <img src="http://pbs.twimg.com/media/bh4idriceaaia2c.jpg" />     <span class="twitter_name">@twitter_name</span>               <span class="someother">something_cool</span>   </div> </div> 

<div> elements block-level fill entire space of containing block. float divs , clear float each 1 decrease width of them content keep each 1 in separate row.

then use bottom/left , right properties position absolutely positioned elements within containing block (the relatively positioned parent .tweet_photo) follows:

.tweet_photo {     position: relative;     float: left;     clear: left; }  .twitter_name {     position: absolute;     color: white;     bottom: 20px;     left: 20px; }  .someother {     position: absolute;     right: 20px;     bottom: 20px;     color: white; } 

working demo.


Comments

Popular posts from this blog

visual studio - vb.net filter binding source by time -

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -