Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Dynamic resize to fit images
Old 03-10-2011, 02:39 PM Dynamic resize to fit images
Super Talker

Posts: 142
Name: William
Trades: 0
I am in the middle of coding a photography portfolio for myself.

I have mocked up 1 page so far.
Rather than making 200 pages or so, It would be best if I could write the code once then just change images
the problem is that my images are of different sizes, I would stick to a height of 460px though, but I need the width to expand to accomodate the image

http://www.freewebs.com/uuilliam/header.html

that is a link to the mock (~it is written using php too but for the host I had to put it into html.)

rules: there must be 10px of white space around the image and 20px of the grey space around the white at minimum.
UUilliam is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-10-2011, 04:32 PM Re: Dynamic resize to fit images
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,376
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Put the image in an floated block container with a 10px margin on the image and a grey 20px border on the container

Code:
#image_holder {
	overflow: auto;
	border: 20px solid grey;
	float:left;
}
#image_holder img {
	margin: 10px;
}
HTML Code:
<div id="image_holder"><img src="image_path" alt="text" /></div>
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-10-2011, 05:10 PM Re: Dynamic resize to fit images
Super Talker

Posts: 142
Name: William
Trades: 0
my code atm is
Quote:
<div class="content_background">
<div class="content">
<div class="display">
<img src="images/test1.jpg" height="450" width="389"/>
</div>
</div>
</div>
and css:

Quote:
/*content*/
.content_background {
margin: 10px auto;
background: #2c2c2c;
border: thin solid #363636;
min-height: 500px;
width: 880px;
}
.content {
background: #ffffff;
height: 470px;
width: 409px;
border: solid thin #000000;
margin:20px auto;
}
.display {
margin: 10px 0px 0px 10px;
clear: both;
}
UUilliam is offline
Reply With Quote
View Public Profile
 
Old 03-10-2011, 05:34 PM Re: Dynamic resize to fit images
Super Talker

Posts: 142
Name: William
Trades: 0
I done what you said but it no longer centers

http://www.freewebs.com/uuilliam/header.html

Code:
/*content*/
.content_background {
    margin: 10px auto;
    overflow: auto;
    background: #2c2c2c;
    border: thin solid #363636;
    min-height: 500px;
    width: 880px;
}
.content {
    background: #ffffff;
    overflow: auto;
    border: solid thin #000000;
    margin:20px;
    float: left;
}
.content img {
    margin: 10px;
}

Last edited by chrishirst; 03-14-2011 at 08:59 AM..
UUilliam is offline
Reply With Quote
View Public Profile
 
Old 03-14-2011, 05:53 AM Re: Dynamic resize to fit images
shivaji's Avatar
Ultra Talker

Posts: 321
Trades: 0
You need to keep margin on auto and insert padding instead, and remove float left. Div class="center" actually you don't need it, and in content_background you can insert text-align: center; for IE6 (if you care about it).

Code:
.content {
background: #ffffff;
overflow: hidden;
border: solid thin #000000;
margin:20px auto;
padding: 10px;
}
__________________

Please login or register to view this content. Registration is FREE
- uncommon free scripts

Please login or register to view this content. Registration is FREE
- Städte, Sport, Party, Gourment, Apartments, Hotels

Last edited by shivaji; 03-14-2011 at 05:55 AM..
shivaji is offline
Reply With Quote
View Public Profile Visit shivaji's homepage!
 
Old 03-14-2011, 09:19 AM Re: Dynamic resize to fit images
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,376
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You cannot float an element AND centre it in it's parent at the same time.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-22-2011, 11:39 PM Re: Dynamic resize to fit images
Super Talker

Posts: 142
Name: William
Trades: 0
I figured it out, the code was:

in .center

{
position:relative;
float:left;
left:50%
}

then in .content

{
Position: relative;
float: left;
left: -50%;
}

that centers it for me

so got the center done, got my thumb nails...
just trying to figure out (without having to make a new page for each image) how to make it so when you click the thumbnail, the image comes up.

Also, if I could figure a way to make it so thumbnails are auto generated with the longest side being 100px, it would help.

and to do with calibrating for all browsers, if it doesn't work in internet explorer, so be it.
my main target is firefox users and chrome.
UUilliam is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Dynamic resize to fit images
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41451 seconds with 12 queries