How to following a link without modifying the displayed url and triggering css animation? - css-animations

I have a side menu organised in 2 levels,like
link1
link1.1
link1.2
link1.3
links 1.x are hidden (display:none, applied to the container div) and contained within a div (id = resume-2nd-level)
now, I created a css class:
#resume-2nd-level:target {
display:show
-webkit-transition: height 3s linear 1s;
transition: height 3s linear 1s;
}
link1's href property points to: #resume-2nd-level
My goal is to:
show link1.x when I click on link1 (eventually toggle them: show-hide-show- ..)
link1.x shall not appear immediately but with a css animation with the following specifications: expands in height, starts after 1 second, lasts for 3 seconds before being completely expanded
hide the #resume-2nd-level from browser url (as the link was triggered using Javascript)
However my code doesn't each neither of the two goals.
I tried to show the container containing the links using jQuery's show() onclick and it works (although no animation occurs).
Thanks in advance

The problem you are having is that transition does not work the way you think.
#innerMenu {
height:0%;
width:0%;
position:relative;
overflow:hidden;
-webkit-transition: height 1s linear 3s;
transition: height 3s linear 1s;
-webkit-transition: width 3s linear 1s;
transition: width 3s linear 1s;
}
#innerMenu:target{
height:100%;
width:100%;
}
<ul>
<li>
Menu1
<div id='innerMenu'>
<ul>
<li>Menu2</li>
<li>Menu3</li>
</ul>
</div>
</li>
</ul>
The above snippit shows the proper way to do this.
The transition property needs to see a change in order for it to fire. What you have right now is not changing anything. By trying to show the element you are not actually changing the size of it.
In the snippit you can see what is actually changing is the height and width and the transition can be applied to that change.
Also you need to animate the width because otherwise it will become unhidden instantly.

Related

Safari a:hover changing sibling in fixed element

I am making a simple fixed SoMe sharing button set for a blog. Everything is fine and dandy except in Safari. Hovering over one of the buttons changes the background-color of the siblings to a color I do not specify anywhere in my CSS. This behavior goes away as soon as I change the wrapper from fixed to relative/static/absolute.
Has anyone ever run into this?
Am I doing something wrong?
If not, is there a hack/fix/workaround?
HTML:
<div id="share-links">
<a class="share-twitter" href="#">a</a>
<a class="share-facebook"href="#">a</a>
<a class="share-linkedin" href="#">a</a>
</div>
CSS:
#share-links{
left:0;
top:5em;
position:fixed;
}
#share-links a{
display:block;
height:2em;
width:2em;
color:white;
background-color:#a16159;
}
#share-links a:hover{
background-color:#8a392e;
}
Fiddle: https://jsfiddle.net/u6vzq192/26/
I discovered this problem in a slightly different situation. I have pagination dots in a fixed div using links like you have set up. I am adding a class to the links with Javascript which in turn changes the background color. Every time this happens the background colors of all the other links go crazy. I believe that it is a rendering bug in Safari inverting the background of the links when one changes.
After much experimentation with your example I discovered that it stops if either the links themselves are much larger or the container is much larger. Since setting the links to be giant buttons affects design, it seems the best solution is to set the container to be larger. Since your example is a vertical set of links you would set the height of the container to be something much larger than the links. I used height: 100%; but a large px should work too. If you had links laid out horizontally you might need to make that width: 100%; instead.
CSS:
#share-links{
left:0;
top:5em;
position:fixed;
height: 100%;
}
#share-links a{
display:block;
height:2em;
width:2em;
color:white;
background-color:#a16159;
}
#share-links a:hover{
background-color:#8a392e;
}
I encountered a similar problem. As well as being fixed, one of the inside elements had transform:rotate 90 deg and had a hover effect that changed its position slightly (pulled out from the side of the screen). The background color of this element and its sibling were the same, and both would flicker randomly when elements on the page were changed / rendered.
I finally found a combination of styles that stopped the background colour flickering altogether.
I added the following to the parent element from here: https://stackoverflow.com/a/27863860/6260201
-webkit-transform:translate3d(0,0,0);
-webkit-transform-style: preserve-3d;
That stopped the flickering of the transformed/sliding element.
And I added the following to the remaining element from here: https://stackoverflow.com/a/19817217/6260201
-webkit-backface-visibility: hidden;
This then stopped the flickering of the background colour for the sibling element.

How to add body background which sticks to container div?

I have a container in the center of window. And my logo goes out from container to the left. I split my logo in 2 pieces. Right piece i added in my container with no-repeat. And left piece i have to add in my body background and somehow stick it to containers div.
i have drawn my issue:
how to manage that issue ?
I would do it somehow different. You can always set background of #logoimage div to your logo with gradient, or simply put an image inside. One image is enough with full logo object.
style:
#container{
display:block;
width:400px;
height:800px;
margin:auto;
background:#abc;
position:relative;
}
#logoimage{
display:block;
width:170px;
height:80px;
margin:auto;
background:#aaa;
position:absolute;
left:-70px;
top:30px;
}
html:
<div id="container"><div id="logoimage"></div></div>
live example here
What's the most important of this is:
position:relative style of container element
position:absolute style of logo element
The idea generally is that in position absolute, you can set x,y relatively to element with position relative.

Jssor slider responsive caption, unwanted text resize

Using JSSOR slider the function ScaleSlider() calls $ScaleWidth to resize the slider according to the viewport. This is achieved by applying a transform style to the #slider1_container element.
transform: scale(0.756364);
However, this also causes any text in the caption to be resized, rendering it illegible.
<div id="slider1_container">
<div u="slides">
<div u="caption" class="myCaption">
<p>Text goes here</p>
</div>
<img u="image" src="myImage.jpg" />
</div>
</div>
How can I prevent the caption text (.myCaption) to be affected by the transform style?
This was a very irritating issue, our designer kept complaining about the automatic resizing.
What i did to deal with this was:
1.Created a function to scale the div that holds my captions back to its original size. The div its originally hidden and after applying the transformation is shown. The original size of my slider is 1920 px width, so i am using that to calculate the percentage of the browser resizing in order to scale the captions back
function ScaleCaptions(){
bodyWidth = document.body.clientWidth;
widthChange=1920/bodyWidth;
if(bodyWidth<992){widthChange=widthChange/1.5;}
$(".captionHolder").css("transform","scale("+widthChange+")");
$(".captionHolder").show();
}
I call this function for the following 3 events, after the ScaleSlider function is called:
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
$(window).bind("load", ScaleCaptions);
$(window).bind("resize", ScaleCaptions);
$(window).bind("orientationchange", ScaleCaptions);
If you want to resize the captions at some point, css rules wont work, so you have to do it with jquery. In my case i wanted to resize the captions below 992px, so i added this line of code in my function
if(bodyWidth<992){widthChange=widthChange/1.5;}
i would disagree with the above approach, sorry for writing another answer but i could not comment. Even when adding css rules for well established breakpoints(768,992,1200, so on), the text continues to resize along the slider, with the difference of starting from the text size declared in the css rules. So for example if i wanted for 768px the font size to be 16px, although it would start from 16px at 768px, it would continue to resize along the slider, which is not what i want. Also 16px font size at 1200px resolution, and 16px font size at 768px resolution have a huge difference, with the second case the text being very tiny
I have similar automated function which works for my solution:
function ScaleSliderCaptions(id,obj){
//var parentWidth = jQuery('#'+id).parent().width();
var bodyWidth = document.body.clientWidth;
var widthChange=obj.$GetOriginalWidth()/bodyWidth;
if(bodyWidth<(obj.$GetOriginalWidth()/2)){widthChange=widthChange/1.5;}
jQuery(".slider-content").css("transform","scale("+widthChange+")").show();
}
obj - slider object created before,
id - slider_container
Caption should always scale along with slider. There is no option to stop caption from scaling.
Css trick below may meet your needs,
#media only screen and (max-width: 480px) {
.myCaption{
...;
font-size: 24px;
...;
}
}
#media only screen and (max-width: 768px) {
.myCaption{
...;
font-size: 16px;
...;
}
}
#media only screen and (min-width: 769px) {
.myCaption{
...;
font-size: 12px;
...;
}
}

Controlling rotation axis with webkit 3d transform

I'm creating a card-flip effect using webkit transformations. I have it working as I like in one section, where I have a DIV that rotates around its center axis giving the look of a card that is flipping over.
I now want to add this same effect to a page transition. I'm using the same CSS and HTML structure, but in this case I'm not getting an effect that rotates around a center axis.
Instead, it looks like the transformation is rotating along the y axis anchored to the left of the object rather than the center (so it looks like a door opening, rather than a card flipping).
I've been reading through the spec's but can't figure out which property controls the rotation axis' position. What do I need to add or change with this to get the flip working?
html structure:
<div id="frontbackwrapper">
<div id="front"></div>
<div id="back"></div>
</div>
and the css (.flip is being added via jQuery to start the effect)
#frontbackwrapper {
position: absolute;
-webkit-perspective: 1000;
-webkit-transition-duration: 1s;
-webkit-transform-style: preserve-3d;
-webkit-transition: 1s;
}
#frontbackwrapper.flip {
-webkit-transform: rotateY(180deg);
}
#frontbackwrapper.flip #front,
#frontbackwrapper.flip #back {
-webkit-transform: rotateY(180deg);
-webkit-transition: 1s;
}
#front, #back {
position: absolute;
-webkit-backface-visibility: hidden;
}
#back {
-webkit-transform: rotateY(180deg);
}
Try this on your wrapper
-webkit-transform-origin: 50% 0 0;
Though you may or may not have to have its width explicitly set.

background-position question

On this page I"ve been working on forever, I have this column headed "Bid x Ask": http://www.sellmycalls.com/so-bg-pos.png
in each of whose cell backgrounds there is supposed to be a bar chart that conveys the ratio of the numbers in the cell to each other.
So in each cell I have a background-color: gray; and a background-image:all-white;. I can't properly position the (plenty big enough) image on the gray background. In fact, in its current incarnation, the image doesn't show up at all.
How can I properly set the background-position of the image? The top <td> in the column is styled this way:
<td class="main_td bxa bxa_val"
style="background-color: #ecf1ef;
background-image:url('http://www.sellmycalls.com/pics/cell/bxa-white.png');
background-repeat:repeat-x repeat-y;
background-origin: 0px 0px;
background-attachment:fixed;
background-position:53px 0px;
-moz-background-position:53px 0px;
-webkit-background-position:53px 0px;
-khtml-background-position:53px 0px;
-o-user-background-position:53px 0px;">
<div> 543 x 470</div></td>
Thanks so much for your help!
Your image is 49x1px which I think is showing, however, with Firebug your TD shows a style of background-repeat:repeat-x; X not Y as you show in your example code snippet above.
UPDATE:
Try
style="background-color:#ecf1ef;
background-image:url('http://www.sellmycalls.com/pics/cell/bxa-white.png');
background-position:50px 0px;
background-repeat:repeat-y;"
you cannot adjust the dimensions of the image so (1) always make the image at least as wide as the TD itself (i.e. wider than 49px) and always use the background-image as the right hand side bar and the background-color for the left side bar. I hope this is all clear
It seems your image's path is incorrect. However the div child of each cell has a background-color rule, so this color cover any background of <td>