WeLoveCSS Logo
Home Profile Members Search Rules Help New Posts



WeLoveCSS > WEB DESIGN > CSS > noobie image collage

Reply
  Thread Tools Display Modes
Old 11th June 10, 10:52 PM   #1
cway
WLC Member
 
Join Date: Jul 2008
Location: USA
Posts: 22
Default noobie image collage

I'm working on an image collage and I wonder if anybody has any ideas how I get a text box to appear over an image.
Here's my css.
And I don't really know if what I've built so far is good programming.
Thanks!
Cway
cway is offline   Reply With Quote
Old 12th June 10, 11:18 AM   #2
chrishirst
Banned
 
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,197
Default Re: noobie image collage

Set the image as a background to a fixed size element, put the text in the element
chrishirst is offline   Reply With Quote
Old 13th June 10, 01:15 PM   #3
cway
WLC Member
 
Join Date: Jul 2008
Location: USA
Posts: 22
Default Re: noobie image collage

Thanks for the response!
I'm sorry. I should have explained a little more. I want a text box to appear when you mouse over an image. It would also be keen if the box with the text in it was centered vertically and horizontally to the image. Each image would have their own mouse-over text box.
cway is offline   Reply With Quote
Old 13th June 10, 02:07 PM   #4
MinatureCookie
WLC Member
 
MinatureCookie's Avatar
 
Join Date: Jun 2010
Posts: 22
Default Re: noobie image collage

Just using CSS? I'd really go with Javascript for niceness, but here's how I'd do it just using CSS.

HTML:
HTML Code:
<img src="image.png" alt="Image" class="img" />
<div class="imgText">Blah blah</div>
CSS:
HTML Code:
.imgText, img{
width: 500px;
height: 200px;
}
.imgText{
position: absolute;
margin-top: -200px;
text-align: center;
opacity: 0;
filter: alpha(opacity = 0);
}
.imgText:hover{
opacity: 1;
filter: alpha(opacity = 100);
}
I haven't tested that code, so let me know if there are glitches in it... Should work though. As for centering vertically, there aren't really any nice ways to do it... If you really want it done though, I can link you to some ways... None are good, though.

Also, note that those widths and heights are made up... Put in the actual image width and height, and the margin-top is the image height * -1
__________________

To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts.
MinatureCookie is offline   Reply With Quote
Old 13th June 10, 03:04 PM   #5
meesa
WLC Mod
 
meesa's Avatar
 
Join Date: Jul 2009
Location: Milky Way Galaxy
Posts: 3,167
Default Re: noobie image collage

Quote:
I'd really go with Javascript for niceness
It's typically better to go with CSS, reason being that Javascript can be turned off.
__________________
Praise be to the Lord God for the ability to learn, the capability to analyze, and the time to help users on this forum.
meesa is offline   Reply With Quote
Old 13th June 10, 03:09 PM   #6
MinatureCookie
WLC Member
 
MinatureCookie's Avatar
 
Join Date: Jun 2010
Posts: 22
Default Re: noobie image collage

Quote:
Originally Posted by meesa View Post
It's typically better to go with CSS, reason being that Javascript can be turned off.
Sorry, I meant 'niceness' as in flashy effects and whatnot. But yeah, definitely better to go with CSS as at least backup if JS is disabled.
__________________

To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts.
MinatureCookie is offline   Reply With Quote
Old 13th June 10, 03:49 PM   #7
chrishirst
Banned
 
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,197
Default Re: noobie image collage

HTML Code:
<div class="imgbox">
    <img .... />
    <span>Text</span>
</div>
Code:
.imgbox {
    position:relative;
}
.imgbox span {
     position:absolute;
     visibility:hidden;
}
.imgbox:hover span {
     visibility:visible;    
     z-index:20;
}
.imgbox:hover img{
     z-index:10;
}
Quick bit of code for a disjointed rollover.
(keyboard code not tested )
chrishirst is offline   Reply With Quote
Old 15th June 10, 08:16 PM   #8
cway
WLC Member
 
Join Date: Jul 2008
Location: USA
Posts: 22
Default Re: noobie image collage

Thanks to everyone who's responded! Very much appreciated!

I've implemented some of the changes here
CSS here.

I assume to get the same mouse-over to work, I'll simply duplicate this code and change the div:

Code:
.kit
{
	position: relative;
	border: 2px black solid;
	width: 344px;
	height: 238px;
}
.kit span
{
	position: absolute;
	visibility: hidden;
	top: 10px;
	left: 10px;
	background-image: url(graphics/80white.png);
	padding: 4px;
	width: 300px;
}
.kit:hover span
{
	visibility: visible;
	z-index: 20;
}
.kit:hover img
{
	z-index: 10;
}
I've made some adjustments so the text would appear on top of the image and with a background png. I also added a border and some padding. But now there's two borders - the default blue border and my black border.

Does anybody have any suggestions on how I remove the blue border?

Thanks!
Cway
cway is offline   Reply With Quote
Old 15th June 10, 08:26 PM   #9
MinatureCookie
WLC Member
 
MinatureCookie's Avatar
 
Join Date: Jun 2010
Posts: 22
Default Re: noobie image collage

Code:
a img{
  border-width: 0;
}
I think - if it's a border because you've added a link
__________________

To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts.
MinatureCookie is offline   Reply With Quote
Old 15th June 10, 08:26 PM   #10
rkrause
WLC Mod
 
Join Date: Sep 2009
Posts: 883
Default Re: noobie image collage

the default blue border on all images is removed by adding the following css style.

img {border:none;}
rkrause is offline   Reply With Quote
Reply


Thread Tools
Display Modes
Linear Mode Linear Mode

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

Forum Jump


All times are GMT. The time now is 06:29 AM.



Home | Advertise | Contact Us | Top
Home | Advertise | Contact Us | Top

Copyright© 2006 WeLoveCSS.com. All Rights Reserved.
Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.