Jump to content

css property for picture help


dsp77

Recommended Posts

Hello, what i try to accomplish is to force the bigger picture(726px) to go/hide under the div(500px) but display the first 500px. Any advise?

<div style="width:500px;"><a href="#"><img width="726" height="199" src="images/pic1.jpg"></a></div>

Link to comment
Share on other sites

the first advice is separate concerns, Use an external stylesheet. makes your code less sloppy, and it's easier to maintain, faster and less ugly.

second, always use an alt=" " attribute on images.

third, don't change the size of the image in html, use the size that is suitable otherwise you load a larger image than needed and that's a waste.

fourth use indentation.

 

make an external stylesheet and do this

css

div.my-image{ /*target the div element with the class of my-image */
   width:500px;
   overflow:hidden; /* cut off the image at 500px width */
   /* you can set a height for the image */
}

 

in your html

<div class="my-image">
   <a href="#"><img alt=" "src="images/pic1.jpg"></a>
</div>

 

Hope this helps!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.