http://www.polymer-project.org/components/core-animated-pages/demos/music.html
When you change the .card height in chrome console you will see that the small card tiles in the background hiding behind the big card, suddenly disappear completely when the animation is done.
Is there a way to tell a hero transition to not remove the parent section? Or a way to make the parent section disappear but gradually?
In this case it is ok because you don't see them disappear but when the background has a number of small cards that do not fit behind the large card it would look way better if they just stay in the background.
EDIT1:
#mini {
display: block !important;
}
#mini *[hero] {
opacity: 0.5 !important;
}
<section id="mini">
<template repeat="{{items as item}}">
<div class="chip" hero-id="{{item.id}}" hero?="{{muts === item }}" on-tap="{{transition}}">
</div>
</template>
</section>
EDIT2:
The second hero is not in the middle of the view port anymore when the background chips exceed the screen size.
Another workaround I found is to add an id and a bit of CSS to the core-animated-pages component.
My core-animated-pages looks like this :
<core-animated-pages selected="{{page}}" transitions="hero-transition"
on-core-animated-pages-transition-end="{{complete}}">
<section id="mini">
<div class="chip-container" hero-p on-tap="{{transition}}">
...
</div>
<div class="chip-container" hero-p on-tap="{{transition}}">
...
</div>
</section>
<section id="details">
...
</section>
</core-animated-pages>
Nothing special, I just have two lines of "chips". Note the id on the "chip-container container", it's the one that enables us to do some css modification directly in components/core-animated-pages/core-animated-pages.css. Those modifications are the following :
/*
Enables us to keep the "chip-container container" visible even after the hero transition
*/
*#mini {
display: block !important;
}
/*
Fades out the "chip" that realized a transition ([active] and .core-selected are removed
from the "chip-container container" during the transition)
*/
*#mini *[hero] {
opacity: 0 !important;
}
/*
Fades in the "chip" when everything goes back to it's original state ([hero] isn't
removed from the chip, but [active] and .core-selected are re-set on the "chip-container
container", so we use this to distinguish wish state we're in, and so if it's "legit" to
see the "chip")
*/
*#mini[active] *[hero] {
opacity: 1 !important;
}
Might not be the cleanest way but it works, I hope I explained well enough how I managed to achieve this result, and every tiny part of my solution. Feel free to comment / ask if that's not the case :)
If you add cross-fade-all to the list of transitions, the background cards will more gracefully fade out, rather than disappearing at the end of the animation:
<core-animated-pages
selected="{{page}}"
transitions="hero-transition cross-fade-all"
on-core-animated-pages-transition-end="{{complete}}">
You can test it on JS Bin.
Can you show your .js Code? You need to remove object.flush(); from your .js code. Hope this help.
Related
I've been working on a web component that will hide/reveal content by hovering over a <div>. I've got the functionality working the way I want, but I just realized isn't accessible via tabbing.
I was able to include tabindex="0" role="button" aria-pressed="false" to each of the <div> boxes, which allows you to toggle between each box, but I have no way of revealing the hidden content.
You can find my code here, which demonstrates the issue:
https://codepen.io/ckatz/pen/XQaKdB
Is there a markup I'm missing to allow for someone to hit Enter to show the text?
I added this to your CSS and it worked when i press TAB and move from div to div:
.color:focus {
/* Change the flex-basis so that we know what
size to transition to on hover. Arbitrary,
based on our design/content.
*/
flex-basis: 20em;
}
.color:focus .details {
opacity: 1;
}
I have a component that, upon a hover, shows a button and a link that you can click on. This is not a menu... just a box in the middle of the page.
For accessibility, I would like a user to be able to tab into the container (happens now, and displays the content in the .HiddenUntilHover class) AND also continue to tab to the button and link that show up on the hover/focused state.
Right now you can focus on the container and see the hover state; however, when you tab it just goes to the next element and does not allow you to tab to the button or link WITHIN the hover state.
Pseudo code example:
/* My component .jsx */
<div tabIndex="0" className="MainContainer">
<div className="SomeOtherClass">
<div className="HiddenUntilHover">
/* I would like to be able to tab to these clickable things! */
<button>Click me!</button>
I am also clickable
</div>
</div>
</div>
And my SCSS:
.HiddenUntilHover {
display: none;
}
MainContainer:focus,
MainContainer:hover,
> .HiddenUntilHover {
display: block
}
I ran into this issue a few days ago and I solved it using css classes to make the hovered content accessible via keyboard navigation.
The way I got this working was to use css pseudo-classes to ensure that when the div element is active & focused that the buttons inside also display. Specifically the additional use of :focus-within & :focus-visible should ensure that when you tab over the list items, their contents are also displayed and keyboard accessible.
.MainContainer {
&:not(:hover, :focus, :active, :focus-visible, :focus-within) {
.HiddenUntilHover {
visibility: hidden;
}
}
}
<body>
<div tabIndex="0" className="MainContainer">
Content
<div className="SomeOtherClass">
<div className="HiddenUntilHover">
<button>Click me!</button>
I am also clickable
</div>
</div>
</div>
</body>
Here's a link to the Codesandbox demo of this working
When the box is in focus, tabbing further to the button will make the box blur, which will hide it, and its contents, so focus will move to the next accessible element. I think this is the behavior you are experiencing.
You might consider using inserting an aria-activedescendant or tabindex attribute when the box comes into focus. This requires a little javascript.
Strictly speaking, you don't need to rely on the hover state to make that control accessible. You could have an offscreen (or clipped) button/link that is not a DOM child of the hidden (display:none) box. If you take this approach, read up on the aria-owns attribute.
As long as it is marked up as a button or link (or has a tabindex="0" setting), and is not 'really' hidden, it ought to be possible to tab to it.
Try increasing the properties of the class MainContainer
for example.
.MainContainer {
width: 100%;
height: 100px;
}
.MainContainer .HiddenUntilHover {
display: none;
}
.MainContainer:hover .HiddenUntilHover, .MainContainer:focus .HiddenUntilHover {
display: block;
}
Elements appearing on hover are inherently inaccessible. You are experiencing one side of the problem with your code, where it is difficult to make it keyboard accessible.
But think about touch screens that have no real concept of hover: is there some way to reach your button on a smarphone or tablet?
For a more pragmatic answer, if you need to stay with hover, a less hacky solution than the two already posted ones could be the following:
use focusin and focusout events. See for example this question for explanations and differences with focus/blur, and this w3school doc for browser compatibility.
You will have to structure your HTML differently, such as:
<div id="outer">
<div id="hover">
...
</div><!--hover-->
<button>Your button which only appears on hover</utton>
</div><!--outer-->
As well as use a bit of js:
$('#outer').on('focusin', __=>$('#hover').classNames.add('keep-visible'));
$('#outer').on('focusout', __=>$('#hover').classNames.remove('keep-visible'));
With a corresponding .keep-visible class which will leave the element display:block (I'm not a CSS expert, I let you write the code).
The overal functionning is the following: when some element within #outer takes the focus, the focusin element is fired due to bubbling. In the event, you put your class .keep-visible which makes the element to stay visible.
The focusout event is fired when the focus leaves the last element within #outer. At that point you remove the .keep-visible class, which makes the element to disappear.
According to the link above, onfocusin/out aren't standard, but are supported by all major browsers including IE. Firefox is the last one to implement it in 52.0, so it's a kind of defacto standard; we can reasonably expect that it won't disappear soon.
here's the project I'm developing.
Test Project Link
Go to Products.
Click/Toggle Flush Mounts and Press Books
Observe the image below fades-in and out. As you can see, the first image fades out nicely but the second one pops-up instantly. How to make them both fade smooth and nicely?
HTML:
<div class="text-center font-zero">
<a class="category" ng-class="{active: flushMount}" ng-click="flushMount = true" ng-init="flushMount = true">
Flush Mounts
</a>
<a class="category" ng-class="{active: !flushMount}" ng-click="flushMount = false">
Press Books
</a>
</div>
<div class="container">
<div class="book-markers text-center">
<div class="book-item" ng-show="flushMount">
...
</div>
<div class="book-item" ng-hide="flushMount">
...
</div>
</div>
</div>
SCSS
.book-item{
#include transition(all 0.5s ease);
opacity: 1;
&.ng-hide-add,
&.ng-hide-remove{
display: inline-block !important;
}
&.ng-hide{
opacity: 0;
}
}
It's better to use the Angular most important feature, use ng-view and split the two views into two partials....when "Flush Mounts" is clicked the flush mounts div fade in smoothly and when you click "Press Books" the press books div fade in smoothly too.
ng-view example : http://jsfiddle.net/carpasse/mcVfK/3/
<ng-view>
</ng-view>
Part of the problem is that you always see "Flush Mounts" (on the top), either fading in or fading out. Fading out takes twice as long. I think that has to do with Angular's animation process and the fact that animations run in one cycle.
You have defined transition on your base class and display: inline-block; for ng-hide-add / remove. The animation process first adds the add and remove classes. In your case this already adds a transition display: none -> inline-block. Then ng-hide is added, which adds another transition opacity: 1 -> 0. Fading in on the other hand only has one transition.
I'm not entirely sure whose fault it is. I'd suggest that at first you position the divs above each other in terms of z-index instead of y coordinate. You should do that anyway. Then you can put the transition on the hide class (or .book-item.ng-hide), not directly on book-item.
Can anybody recommend a good tool that could give the visual of my html page content stack when using z-index properties for some div tags on a given html document?
At present, I'm facing this troubling bug that is preventing me to navigate to other menu links on top navigation menu bar.
http://cms.tmadev.com.au/companyprovider.html
After spending sometime trouble shooting, I found out the reason the top menu navigation bar is 'disabled' due to the image logo.
<div class="logo">
<img src="images/CRSlogo.png" alt="">
</div>
If you look into the html file closely, if you remove this div class logo, the top menu navigation bar links will be restored to normal.
Thus I'm suspecting because of its default z-index value (whatever it is), it's causing the image to go infront of the top menu navigation bar.
I tried hacking the CSS to push its z-index far back as -9999 - but it's not working! Links are still disabled.
Any ideas how I should handle z-index properties properly?
Cheers!
As a practice, try avoiding giving explicit height to elements
Heres the fix
HTML
<div class="header">
.. some other content ...
</div>
CSS
.header {
/*height:100px --avoiding height */
overflow:hidden; /* one way to force element containing floated elements to have a height */
}
details about above overflow-hidden-float-trick here
although the above should work, if your navigation has some dropdowns, chances are, it will get chopped off because of overflow property of parent set to 'hidden'
a good way to clear floats would be to use something called a "clearfix" detailed here and there and everywhere
So,
HTML
<div class="header clearfix"> <!-- notice the new clearfix class -->
.. some other content ...
</div>
CSS
.header {
/*height:100px --avoiding height */
/* overflow:hidden; --not required */
}
.clearfix:before,
.clearfix:after {
content:"";
display:table;
clear:both;
}
.clearfix {
*zoom:1; /* for ie7 */
}
When I look at the example on which button clicked: "Administrator", I get the div "middle", it is therefore necessary to provide a stronger value to your "menu_tab" z-index: 2", and a lower to your "middle z-index: 1";
http://fr.html.net/tutorials/css/figure020.gif
Envoy !
So FireFox has a 3D view in its web inspector, here's a 3D view of the Google homepage:
To enable it:
Visit your web site
Open the dev tools (View > Toolbar > Web Development Toolbar)
Select the "Inspector" tab and select the 3D box third from the right on the same tab bar.
.header {height: 140px;} without z-index system
Varinder Say the true !
If I have two layers on a page, split horrizontally, with the second layer overlapping part of the first layer, is it possible to make it "click through"?
I have links in the first layer, which the second layer overlaps, which stops the links from being clickable. Is there a way to make the layer display, but be click through, while still having it's own links clickable?
edit:
Here is an example, with html and a stylesheet.
The test links become unclickable when inline with the header in Layer3, but below that they are fine. Is there a way to rectify this?
<title>Test</title>
<link rel="stylesheet" href="test.css" type="text/css">
<body>
<div id="Layer0">
<div id="Layer1" class="Layer1">
<h3 align="left">Brands</h3>
</div>
<div id="Layer2" class="Layer2"><h1>TEST</h1>
<div id="rightlayer">
TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>
</div>
</div>
<div id="Layer3" class="Layer3"><h1>Ed Hardy Auctions</h1>
</div>
</div>
</body>
</html>
And the css
#Layer0 {
width:100%;
height:100%;
}
body {
margin:10px 10px 0px 10px;
padding:0px;
color:#999999;
font-family:"Trebuchet MS",arial,sans-serif;
font-size:70.5%;
}
#Layer1 {
position:absolute;
left:10px;
width:200px;
margin-top:17px;
font-size:1.0em;
padding-left:12px;
padding-top:8px;
}
#Layer2 {
background:#fff;
margin-left:199px;
color:#000;
}
#rightlayer {
float:right;
}
.Layer3 {
position:absolute;
top:67%;
padding:20px;
width: 100%;
}
Thought I would update this as I'd been struggling with this for a few hours and think i've found a solution. Looked into using Jquery but the CSS property:
pointer-events:none;
...did exactly what I wanted.
It is not possible if you want the divs to stay in their current x,y, (and most importantly) z - only the "top" layer is clickable.
Addendum post OP edit:
Think of CSS layout as if you were physically working with bits of paper (this is much easier to visualise if you give all your "layer" divs a different background colour). The rendering engine cuts out a bit of paper in the dimensions you give it (or it works out) for each element it finds. It does this in the order it encounters them putting each bit of paper on the page as it goes - the last item is going to be on top.
Now you've told the rendering engine to put your 3rd div in a position where it overlaps the 2nd. And now you expect to be able to "see" the covered content. Wouldn't work with paper, won't work with HTML. Just because it's transparent doesn't mean it's not taking up space.
So you have to change something.
Looking at your CSS and markup (which honestly could be cleaned up, but I'll assume there's other mark-up you're not showing us which justifies it) there's a couple of easy win ways:
1). Set a z-index of -1 on Layer3 - z-index is how you can change the layering order from the default (as encountered). This just moves the entirety of Layer3 below the rest of the page so what was hidden becomes exposed, but also vice versa depending on content.
2). Change the width from 100% to e.g. 80%, or more likely given your use of pos:abs set left:0px and right:199px; (I'm guessing that padding-left on Layer2 is an intended column width?). The cost of this is that your Layer3 is no longer 100% width
3). Google "CSS column layout" and find a pattern that reflects what you need and adapt that. Every CSS layout which can be done has been done a million times already. Standard techniques exist which solve your problems. CSS is hard if you haven't built up the experience, so leverage the experience of others. Don't reinvent wheels.
It would be a mammoth job, but it is possible.
You would need to capture the click event on the top layer/div, and find the cursor x-y position.
Then find all links in the layer/div underneath the top layer, and see if it's position on the screen falls around the current mouse position.
You could then trigger the click of the matched link.
I would use jQuery (if you are not already) for this and then re-post with a jQuery tag if you run into troubles.
It is hard to tell without seeing some code.
You could try setting z-index on the bottom layer but that works on elements that have been positioned with absolute, relative or fixed (position:absolute).
edit after seeing code:
Add position:relative; z-index:100; to #rightLayer.
Or you could remove the width:100% from .Layer3.
You may want to refactor your code and go with a two column layout for #rightLayer and .Layer3.
css
#Layer0 {
width:100%;
height:100%;
}
body {
margin:10px 10px 0px 10px;
padding:0px;
color:#999999;
font-family:"Trebuchet MS",arial,sans-serif;
font-size:70.5%;
}
#Layer1 {
width:200px;
margin-top:17px;
font-size:1.0em;
padding-left:12px;
padding-top:8px;
}
#Layer2 {
background:#fff;
margin-left:199px;
color:#000;
}
#rightlayer {
float:right;
}
.Layer3 {
}
html
<div id="Layer0">
<div id="Layer2" class="Layer2">
<h1>TEST</h1>
</div>
<div id="Layer1" class="Layer1">
<h3 align="left">Brands</h3>
</div>
<div class="content">
<div id="rightlayer">
TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>TEST><p>
</div>
<div id="Layer3" class="Layer3">
<h1>Ed Hardy Auctions</h1>
</div>
</div>
</div>
I'm assuming from the example that the links in the rightlayer are the only links that need to be clicked, and that you don't have links in the other layers. If so, you could solve the problem by changing the z-index order of the divs.
Layer1 and Layer3 have position absolute, so if you add a position style (absolute or relative) to Layer2, you will be able to pull that div to the front, also pulling the rightlayer div to be in a higher layer than Layer3.
I added the following to the CSS:
#Layer2 {
position: relative;
z-index: 1;
}
From what I can see that leaves the current page setup just the way it is, but pulls all the elements (including the rightlayer with the links) to the front, so you'd be able to click all the links in it.
For debugging purposes I suggest adding background colors to all the different layers to get an idea of the z-index order of the different layers. With the background color in place it was quite easy to spot the layer that was falling over the links, but also to verify that the new z-index order makes the links available.
Hope this helps!
I submitted a bug years ago to the Firefox Bugzilla saying that there was this very bug in Firefox.
I was told by a Mozilla engineer that this was not actually a bug and that it is the correct behaviour as per the HTML/CSS specifications.
Unfortunately I can't find the original bug to reference as it was about 6 years ago.
The reason I submitted the bug was because I could click through the top div onto the links below when using IE (6 I think) but Firefox would not let me.
As usual, it turned out hat IE had the incorrect implementation and Firefox was working as intended by the spec.
Just because a div is transparent does not mean you should be able to click through it.
I'm not sure how you could get around this with JavaScript or CSS. I would take a step back and have a re-think about what you're trying to achieve and how you're trying to achieve it.
Greg
Can you not simply set the width of the div to auto (the default for absolute positioning - i.e. just delete the width:100% from .Layer3).
That way the div will only be as wide as is necessary, rather than unnecessarily overlapping the links.