Changing position of overlapping Canvases - html

I have layered 4 canvases over the top of each over, however i want to be able to click a button and the linked canvas will come to the top.
http://jsfiddle.net/5g3Fe/ shows what i have currently got. I tried to put the following code into the button click functions. however this doesn't work.
function canvasView1()
{
document.getElementById("canvas1").style.z-index="1";
document.getElementById("canvas2").style.z-index="0";
document.getElementById("canvas3").style.z-index="0";
document.getElementById("canvas4").style.z-index="0";
}
can anyone suggest a way to be able to get specific canvas from a button click.
Thanks

For some reason, jsFiddle was ignoring your JavaScript code because of this reason. You can get around that by choosing No wrap - in <body> on the left hand side options.
Then your problem was that to set the z-index in javascript you use .style.zIndex rather than .style.z-index.
Working fiddle here
Or cleaner code version here

Related

How can I toggle between three canvases (HTML)?

https://www.codepile.net/pile/Lobdr3DV
This is a link to my code, I am essentially trying to make three canvases over top of eachother. There will be 1 button for each canvas and clicking the button will hide the other two canvases and make the active one visible.
function swapCanvases1() {
canvas.style.visibility='hidden';
canvas2.style.visibility='hidden';
canvas3.style.visibility='visible';
}
function swapCanvases2() {
canvas.style.visibility='hidden';
canvas2.style.visibility='visible';
canvas3.style.visibility='hidden';
}
function swapCanvases3() {
canvas.style.visibility='visible';
canvas2.style.visibility='hidden';
canvas3.style.visibility='hidden';
}
I tried doing this but if you try to run my code in browser, all the canvases appear on the screen side by side, and never get hidden even when I press the respective button.
Some help would be awesome, thank you.
The code could use some serious refactoring, anyways this: img.src=... seems to be the issue. There is no img variable set, so the onclick functions end up on an error (so these swap functions don't even run), which you should see in the developer console (F12).
Also consider doing display='none/block'; instead of visibility='visible/hidden'; or set the canvases position: absolute; to overlap.

Display an element only up to a certain depth until expanded

This seems dissimilar to the accordion functionality provided by bootstrap.
To give an example, let's take the "how to format" info starting me in the face right now. I'd want it so that it only displays up to X pixels deep, and then stops until expanded. So it might look like:
and then, once expanded,
I happen to be using bootstrap. Is there a bootstrap native or other HTML solution to create this kind of experience?
Assume that the thing that I only want to show of is a single element, such as an image, rather than a series of text. This means a solution like min-height:50px and overflow:hidden won't work, as it will simply hide the entire image rather than part of it.
We can use jQuery .height() to accomplish knowing the rendered height of an element then making conditional modifications.
Documentation and examples for jQuery .height().
A combination of height and overflow in combination with the toggling of a class should work here.
http://jsfiddle.net/fm56je84/1/
The click of the arrow is bound to the following function:
function expandCollapse() {
$("#container").toggleClass("expanded");
$(".glyphicon").toggleClass("glyphicon-arrow-down"); // Flip Arrow
}

When does dragging select elements on an HTML page?

If you go to a page like youtube.com and drag the mouse around while holding down the left button all kinds of things get selected. In the image below, for example, I'm just dragging the mouse along the red arrow and all the stuff at the top got selected and turned blue.
But if I create a jsfiddle - http://jsfiddle.net/nxwLc/ - with a simple div and drag the mouse around with the left button down, I'm not able to select anything. I can even drag completely around the box without selecting it.
Does anyone know what the difference is?
Thanks
<div id="box1"></div>
The selection (highlight) you see is being applied to textual content elements specifically text and images. In your example you have nothing but a <div> element
Now you'll have something to highlight: http://jsfiddle.net/nxwLc/2/
<div id="box1"><img src="//placehold.it/100x100/cf5"/> asdasdasd</div>
Also worth noting that Firefox will highlight exactly what should be highlighted, while in Chrome the highlight area will have unspecific and also unpredicted results, element-related, keeping an eye to line-heights content-flows etc... strange in any case.
Chrome vs. Firefox

onmouseover just on the non-transparent part of the image

I'm stuck with the menu below. All the website needs to be in HTML.
http://hpics.li/740c57f
WHAT: I want to have an hover image for all the different parts when the mouse go on it. (event/brand/website/print/UI/VIDEO)
PROBLEM: The images are overlapping and the mouseover start when i'm on the transparency of the png.
SOLUTIONS I TRIED: Imagemap to detect the zone and then put javascript code inside the AREA. doesn't work.
Imagemap to detect the zone, put an id in the AREA and use a separated JQUERY with .hover(function(). doesn't work.
Use z-index: impossible because there will be always an image that will hide the one under.
QUESTION: If I can't use ImapeMAP to select my zone and use CSS or JQUERY, how can I do ?
Thank you so much for your help!
Might be too late but the exact case can actually be solved by a class I wrote around 3 months ago. It allows you to check whether you're on a transparent area or not and also check for other elements behind the transparent area, this allows to overlap multiple transparent images and correctly jump from one image to another at the correct point.
http://www.cw-internetdienste.de/pixelselection/

css and z-index - making my submit button appear in and in-front of my search box

I've got a search box, the submit button of which I would like to have inside the box (a bit like bing) I've got some code from a couple of places which I hoped would do the job but I can't make the submit button appear on top of the search box
I've put together a fiddle but coz the image is on my machine it obviously doesn't pick it up, the code is there tho
http://jsfiddle.net/5a3Tr/1/
Anyone any ideas? I thought the z-index thing would work :(
Just remove position: relative from input.rounded - DEMO