CSS3; keep caption width the same as the image -


i'd have caption text stay same width image (without setting 1 fixed width). i've tried playing around , etc., that's harder control.

here's sample of css. hope proper way ask questions here!

<head>   <style type="text/css">     <!--         #floatrightphoto {         float:right;         padding: 6px;         margin-left: 2px;         margin-top: 3px;         margin-bottom: 2px;         margin-right: 0px;         border-top-width: 1px;         border-right-width: 1px;         border-bottom-width: 1px;         border-left-width: 1px;         border-top-style: solid;         border-right-style: solid;         border-bottom-style: solid;         border-left-style: solid;         border-top-color: #ccee77;         border-right-color: #afe165;         border-bottom-color: #afe165;         border-left-color: #ccee77;         background-color: #ccff99;         }          #floatrightphoto  p{         font-weight: normal;         color: #889260;         float: left;         margin-bottom: -3px;         margin-top: 0px;         margin-right: 1px;         margin-left: 0px;         text-align: right;         font-family: "comic sans ms", ariel;         font-style: oblique;         font-size: 14px;         line-height: 16px;         position: static;         display: inherit;         }         body {         width: 750px;         }         -->   </style> </head> <body>   <div id="floatrightphoto">     <img src="somephoto" width="180" height="180">       <br>         <p>caption caption caption caption caption caption caption         caption caption</p>       </br>     </img>   </div> </body> 

whoa that's whole lotta fluff. i'm looking same solution.

i came across solution (modified reflect wanting):

#img-right{display: table; min-width: 1px; float:right; margin-left: 10px;} #img-right p {display: table-caption; caption-side: bottom;} 

however, works in browsers except ie in ie #img-right spans full width of caption (the caption being longer image , doesn't wrap). still trying figure out how make ie behave, works in other browsers.

as other code, suggest simplifying bit reduce load time. modified css little bit...i'd suggest renaming id's smaller , easier read, please, don't ever use comic sans... ever. :)

body { width: 750px; } #img-right {         float:right;         padding: 6px;         margin: 3px 2px 2px 0px;         border-top: 1px solid #ccee77;         border-left: 1px solid #ccee77;         border-bottom: 1px solid #afe165;         border-right: 1px solid #afe165;          background: #ccff99;         }  #img-right p{         font: italic 14px/16px helvetica, arial, lucida sans, verdana;           color: #889260;         float: left;         margin: 0px 0px -3px 1px;         text-align: right;         } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -