Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



SEO Class in Chicago, IL

Learn How To Optimize Your Website on July 26, 2013


Looking for personalized in-depth SEO training among your peers?



High Rankings is offering a 1-day customized SEO training class in Chicago. Class size is limited so please sign-up now if you want in!



 


Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Simple Style Sheet Question


  • Please log in to reply
4 replies to this topic

#1 qwerty

qwerty

    HR 10

  • Moderator
  • 8,296 posts
  • Location:Somerville, MA

Posted 03 December 2004 - 01:55 PM

If I set an image to float:left, but I want a text caption right under it, does that mean I need to put both elements into a div and set that to float:left?

#2 chrishirst

chrishirst

    A not so moderate moderator.

  • Moderator
  • 5,888 posts
  • Location:Blackpool UK

Posted 03 December 2004 - 02:19 PM

setting set float:left and clear:right on the image container

post code, it's easier than explaining

CODE
CSS

<style type="text/css">
.image_block {
    position:relative;
    width:150px;
    float:left;
    margin:0px 10px 10px 0px;
}
.image {
    position:relative;
    float:left;
    clear:right;
}
.caption {
    float:left;
    width:100%;
    text-align:center;
}
</style>

HTML

   <div class="image_block">
     <div class="image">
       <img src="/images/image.gif">
       <div class="caption">
         This is a caption
       </div>
     </div>
   </div>
This text will wrap itself around the image



(I will get all this finished soon !!!)

#3 qwerty

qwerty

    HR 10

  • Moderator
  • 8,296 posts
  • Location:Somerville, MA

Posted 03 December 2004 - 02:41 PM

Many thanks thumbup1.gif

I had to do two versions, one to float left and the other right, but that worked nicely.

#4 lyn

lyn

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 940 posts
  • Location:London, Ontario

Posted 03 December 2004 - 10:41 PM

This is great Chris! thumbup1.gif

If I wanted to define this kind of image block in a CSS file so I could apply it to different sized images, would I be able to spec the width of the block in the html page?

L.

#5 chrishirst

chrishirst

    A not so moderate moderator.

  • Moderator
  • 5,888 posts
  • Location:Blackpool UK

Posted 04 December 2004 - 04:32 AM

sure, all you would need is to redefine the width parameter in the inpage style
CODE
.image_block {
width:150px;
}

or as an alternative you can create some width classes in your CSS file and combine them.
CODE
.w_100 {
width:100px;
}
.w_150 {
width:150px;
}
.w_200 {
width:200px;
}


<div class="image_block w_200"><img ...></div>

both methods have their own merits depending on your particular requirements.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users