hiding text and changing images with css - javascript

I am trying to generate a html page with css that works as an image preview kind of thing. An example of this is here:
http://www.nomorepasting.com/getpaste.php?pasteid=22463
however this approach has several drawbacks. One of which is the text must always be smaller than the images. I tried using a different attempt here:
http://www.nomorepasting.com/getpaste.php?pasteid=22464
But could not get it to work. Would someone please be able to show me how to modify the code at the second link to work as the first, or to suggest an overall better method?

The error in second one is you haven't specified the height attribute.
Try the following, it worked for me.
.class1{
color:#000;
background-image:url('images/2.jpg');height:1000px;
}
The reason you are not able to see the back ground image is, since there is nothing inside the div, and the height is not specified the height is 0.
Try putting a few elements in the div and you will see that the image is being displayed.
Ramjee

Related

DIV inside another DIV Not Loading Images

I am trying to create a drop down menu. The smaller DIV inside the main DIV that contains an image gallery does not load properly when the website is live (space is there but images do not show up). I am looking for the proper code to make this work properly. This is the code I am using for the drop down of the main DIV with the smaller image gallery DIVs inside.
Read More
The smaller DIVs with the image galleries work fine when the website is live until I change the beginning of the code to . I would like to get the drop down to start off closed and not open when the page is visited.
I am going blind here, but I am assuming that your div does not have height. Give height property to a div and that should solve the problem. Its a common mistake.
Please leave us some code sample next time. Ty.
Don't see your code yet, but here is some possible help.
With showing or hiding HTML elements, like div's, you are dealing with visibility and display. One hides the element altogether and the other takes up the space but does not display the inner elements.
You can read more about display and visibility here:
https://www.lifewire.com/display-none-vs-visibility-hidden-3466884

Getting appended items to detect when hovering links

In one of my projects, I am replacing the default cursor in the browser with an SVG one. I am appending this SVG cursor via jQuery. This works fine, but I want to change the cursor when it hovers over links, and right now, nothing I have tried has worked.
I think it is because even though the cursor has a position of fixed and a high z-index value, it cannot tell what it is hovering over because technically it is below the content.
Does anyone have suggestions?
EDIT: Right after I posted this question and after I included a JS Fiddle in the comments, I changed my code to make the cursor appear before the content. The issue remains, however.
Look above in the comments for #mcbex's JS Fiddle! Apparently, one does not simply add a class to an SVG, one must customize it with fill colors.

Trouble with fill(url#) on loading inline SVG

I don't know if anyone has already asked about something like this but I've been searching and I didn't find anything about this issue.
Some div is shown first and the others appear after a transition with JS. Inside one of these divs, I have an inline SVG. When the first div loads (the one that has the SVG inline), it appears OK like in this image:
https://drive.google.com/file/d/0B-1un9u8DWH-UExQeXpQOXJBMzA/edit?usp=sharing
But, when the div that has the inline SVG appears only after some transition, it appears this way:
https://drive.google.com/file/d/0B-1un9u8DWH-U0RHMnRoV3Y4OE0/edit?usp=sharing
The divs suffering transitions are the ones that hold the entire blocks (other than the parent div's block with the svg inline). What seems to happen is that the fill of the svg that is called by url(#idofgradient) is not found, nor recognized. And the fill that only has #F7F7F7 called works fine (the line part of the SVG on the middle of the image).
I have no idea what is happening in this case.
If anyone can help me, you have my thanks.
It will be nice to see some code, but I think that the problem that you are having is related with the inline fill. Remove the inline fill and apply the fills with css (if you are making fill transitions).
.class{
fill:#aaa;
}
.class:hover{
fill:#fff;
}

Wordpress template div not expanding

I have a wordpress theme that i'm building but i've hit a snag with some code and can't seem to get my div to expand correctly. I've tried clearing the floats at different positions, i've tried overflow: hidden, but nothing seems to work.
What i'm trying to do is have the content slide in from either side based on what header you click. The content is based on a wordpress post for each link. So the client can easilly edit it to any size.
Because of this it isn't viable to use pixels in the sizing of it. And i know that absolute positioning means that pixels are very nearly the only option.
I've messed with everything i can think of in firebug and just cannot get it to expand.
You'll find the site here: http://tinyurl.com/okd5wnf
However i couldn't get this to work either. Maybe that'll give you a clue as to what might be wrong.
I know it's a long winded post, and i apologise. If i have time later, i should be able to make a jsfiddle. However time is short at the moment.
Any help would be appreciated. Thank you very much.
Your problems stems from setting the <div class="box"></div>'s position property to absolute. Give the parent element(<div id="body-wrapper"></div>) overflow-x:hidden; to hide children that are not being displayed, and then use negative margins to position child elements within the viewport (the parent element). This is basically how most sliders work.
Remove position absolute from box class. please also mention what desired layout you need for content. we will suggest you classes for that.
Romove position:absolute from div.box
I guess that's all.

Can I add more after "this" in jQuery?

I'm working on a script that fades in and out both an image and a div I have set behind the image when you hover over the image. I'm having two problems:
The fades on the image and div don't seem to move at the same speed even though I have them set to.
I can't figure out how to get the div's to only show for the image you hover over. If I could type ("this" div.info) as an object, it would work fine. Is there a way to do that?
I can't get $(".info",this), $(this).find(".info"), or $(".info", $(this).closest("li")) to work.
Result: I have found the solution. I was able to get it to work by using lthibodeaux's suggestion and using $(".info", $(this).closest("li")) as the object and making all the functions .fadeTo go here for the result:
http://jsfiddle.net/Z5p4K/7/
Edit:
I found out the image and the div animations really were moving at the same speed, just the image only had it's z-index set on hover, so if you took your mouse off the image while the animation was running, it would appear to move at a different speed than the div when really the image was behind the div, it only appeared to be moving at different speeds because when the div became invisible you could see the image behind it but when it became opaque, the image was gone (making you think the image became invisible when really the div was in front of the image). This was easily fixed by moving the the z-index property from ul.columns li:hover img to ul.columns li img.
The div only had a border around it while you hovered over it. This was easily fixed by changing the border properties from ul.columns li:hover .info to ul.columns li .info
Check out the final version here: http://jsfiddle.net/tV9Bw/
This is the final version because I can no longer find any problems with any of the code; everything is optimized, there are no glitches, and it looks great.
Thanks to everyone who answered and to Yi Jiang for editing this post with better formatting. I'm new to this site so I wasn't sure how to properly format my question.
and a Huge thanks to artyom.stv for fixing the last glitch in the script that I didn't know how to fix.
You've got the general idea. One thing you should know about a selector is that you are able to define a second argument as the scope of the selector, i.e.
$("selectorString", scopeObject)
In your case, make the second argument $(this).closest("li"). It will find the list item containing your image and select .info descendants of that container:
$(".info", $(this).closest("li")).fadeIn(1000);
Change $(".info") to $(this).find(".info") and all will be sweet.
Yes you can use something like $(this).find(".info") as mentioned by Bundy
but as The jQuery constructor accepts a 2nd parameter which can be used to override the context of the selection.
You can also do something like this:
$(".info",this)

Categories