![]() |
|
||||||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||||
|
|
#1 |
|
WLC Member
Join Date: Jul 2008
Location: USA
Posts: 22
|
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 |
|
|
|
|
|
#2 |
|
Banned
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,197
|
Set the image as a background to a fixed size element, put the text in the element
|
|
|
|
|
|
#3 |
|
WLC Member
Join Date: Jul 2008
Location: USA
Posts: 22
|
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. |
|
|
|
|
|
#4 |
|
WLC Member
Join Date: Jun 2010
Posts: 22
|
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> 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);
}
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. |
|
|
|
|
|
#5 | |
|
WLC Mod
Join Date: Jul 2009
Location: Milky Way Galaxy
Posts: 3,167
|
Quote:
__________________
Praise be to the Lord God for the ability to learn, the capability to analyze, and the time to help users on this forum. |
|
|
|
|
|
|
#6 |
|
WLC Member
Join Date: Jun 2010
Posts: 22
|
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. |
|
|
|
|
|
#7 |
|
Banned
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,197
|
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;
}
(keyboard code not tested )
|
|
|
|
|
|
#8 |
|
WLC Member
Join Date: Jul 2008
Location: USA
Posts: 22
|
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;
}
Does anybody have any suggestions on how I remove the blue border? Thanks! Cway |
|
|
|
|
|
#9 |
|
WLC Member
Join Date: Jun 2010
Posts: 22
|
Code:
a img{
border-width: 0;
}
__________________
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. |
|
|
|
|
|
#10 |
|
WLC Mod
Join Date: Sep 2009
Posts: 883
|
the default blue border on all images is removed by adding the following css style.
img {border:none;} |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
Linear Mode |
|
|