/    Sign up×
Community /Pin to ProfileBookmark

Last one for tonight…..

I am using a class so I can store an image and it’s caption within a bordered area:

[CODE].photobox {
text-align: center;
font-style: italic;
background-color: #FFFFFF;
font-size: 80%;
border: 1px solid #000000;
padding: 1;
}[/CODE]

Its usage is as such:

[CODE]<div class=”photobox”>
<a href=”image_source.jpg” target=”_blank”>
<img src=”thumbnail.jpg” />
<br />
Image caption
</div>[/CODE]

My problem is that the width of the box is stretching. For example i have an image that is 125 px wide held in a column that is 150 px wide. When I use the photobox class on the image, the box is stetching to fill the whole column, leaving a lot of white space to the sides of the image, which I do not want. I cannot specify a width, as different sized images will be used.

Am I missing an instruction somewhere? This did work, but then stopped, seemingly of its own accord.

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 27.2005 — Is this the effect you want?

CSS:
<i>
</i>.photobox {
text-align: center;
font-style: italic;
background-color: #FFFFFF;
font-size: 80%;
padding: 0;
margin: 0;
}
.photobox * {
display: block;
margin: 0;
padding: 0;
text-align: center;
}
.photobox img {
padding: 1px;
border: solid 1px black;
margin: 0 auto;
}

HTML:
[code=html]
<div class="photobox">
<a href="image_source.jpg" target="_blank">
<img src="thumbnail.jpg" alt="" />
</a>
<p>Image caption</p>

</div>
[/code]
Copy linkTweet thisAlerts:
@4damauthorNov 27.2005 — Thanks, but not really,

Here are some links to screenshots:

[URL=http://www.4dam.co.uk/b3ta/example1.jpg]The effect I want[/URL]

[URL=http://www.4dam.co.uk/b3ta/example2.jpg]What is happening at present[/URL]

[URL=http://www.4dam.co.uk/b3ta/example3.jpg]Using your suggestion[/URL]

I basically want the second example, without the left and right hand side of the image box stretching to fit the column - I only want 1px of padding.

Any suggestions?
Copy linkTweet thisAlerts:
@NogDogNov 27.2005 — This seems to work pretty well in both FF and IE. Maybe you can play around with it to get what you need?
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>
<title>Page title</title>
<style type="text/css">
<!--
div.photobox {
width: 180px;
background-color: #cc99cc;
text-align: center;
font: 10px arial, sans-serif;
font-style: italic;
padding: 10px 2px 0 2px;
}
.photobox img {
margin: 3px;
padding: 1px 1px 1.6em;
border: solid 1px black;
background-color: white;
}
.photobox p {
text-align: center;
position: relative;
margin: 0;
padding: 0;
line-height: 1em;
position: relative;
top: -2em;
}
-->
</style>
</head>
<body>
<div class="photobox">
<img src="leaves.png" alt="" width="150" height="120">
<p><a href="#">The caption</a></p>
<img src="leaves.png" alt="" width="140" height="120">
<p><a href="#">The caption</a></p>
<img src="leaves.png" alt="" width="145" height="120">
<p><a href="#">The caption</a></p>
</div>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@4damauthorNov 29.2005 — Thanks
×

Success!

Help @4dam spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...