Setting a default image size using CSS?

This is a discussion on "Setting a default image size using CSS?" within the Web Page Design section. This forum, and the thread "Setting a default image size using CSS? are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 11th, 2007, 20:48
Junior Member
Join Date: Jan 2007
Location: UK
Age: 23
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Setting a default image size using CSS?

First off, I will say that I had a look for similar threads with such a topic and couldn't seem to find one anywhere so if I have actually missed one then I do apologise >.<

This is a sort of query/stroke confirmation really. If I have an image in the same place every time on a page (like a banner) that changes in the pages, could I set up size and layout specifics in the CSS then in the div on the page just link in the image so that it's formatted straight away by the CSS layout assigned to that particular div id?

So for example in my div id "bannerImage" I have one image that is always say, centered and is 250px wide and 100px high. Instead of writing the positioning EVERY time on the pages, link to the div id in the css that has the above formats laid out in something like:

Code: Select all
(hash)bannerImage {
position: center
width: 250px
height 200px;
}
However, I'm still getting to grips with CSS and have begun using XHTML over plain HTML - is it stronger coding to use different positioning 'formats'? I've seen such terms as absolute and relative and am a little unsure as to how they're used.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 11th, 2007, 23:42
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Setting a default image size using CSS?

What is your banner code? I may be able to simplify this for you if you explain how it is displayed.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 12th, 2007, 10:39
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Setting a default image size using CSS?

Whenever you use an <img>, you should specify the height and width. This speeds up browser rendering by telling the browser how much space to allocate. For example:

Code: Select all
<img src="myImage.jpg" width="300" height="100">
These values are always pixels. Don't include the "px" unit in HTML.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 12th, 2007, 14:44
Junior Member
Join Date: Jan 2007
Location: UK
Age: 23
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Setting a default image size using CSS?

Quote:
Originally Posted by MikeHopley View Post
Whenever you use an <img>, you should specify the height and width. This speeds up browser rendering by telling the browser how much space to allocate. For example:

Code: Select all
<img src="myImage.jpg" width="300" height="100">
These values are always pixels. Don't include the "px" unit in HTML.

Duh.. of course.. that makes sense *facepalm* What I was really getting at more than the size was the formatting. Though a different image might be used on each page, they would be in the same place, same margin etc.

Would it be better to just have the formatting on the HTML page or could it be linked in by the CSS? I'm still learning the ropes on CSS and am still working out what formatting is best left in the CSS and what is used in the HTML/content pages.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 12th, 2007, 15:10
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Setting a default image size using CSS?

All of the other formatting -- position, borders, whatever -- should be controlled by CSS.

Nonetheless, the location of the <img> in your source code will normally affect its position.

You might also want to read up on CSS background images. These are pure CSS with no <img> tag, and are good for decorative images (as opposed to content images).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image file size help danny322 Graphics and 3D 6 Nov 9th, 2007 11:20
Repeating an image along the bottom of the page without setting it as background. imagius Web Page Design 9 Apr 27th, 2007 08:35
What size image should I allow? JustinStudios Graphics and 3D 10 Apr 25th, 2007 23:57
How to set default size for html page? mohabitar Web Page Design 5 Mar 11th, 2007 19:12
Setting the directory to upload an image php djme PHP Forum 2 Jan 11th, 2006 15:39


All times are GMT. The time now is 21:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42