Transform: Translate(-50%, -50%)

What is the CSS transform:translate() property ultimately for?

what exactly is transform:translate() for, according to the makers of CSS3's spec?

It says:

For backwards compatibility with existing SVG content, this specification supports all transform functions defined by The ‘transform’ attribute in [SVG11].

As for the other parts of your question, not sure if it's possible to give a general answer.

I think it's best to run some performance test for your particular situation. That shouldn't be hard to do if your app is well-designed. Also, such design may allow for per-device optimization, where translations and offsets are used respectively.

Jquery translate multiple times with button

You can try this:-

var count = 1;
$('button').click(function (event) {
event.preventDefault();
$('section').css({
'-webkit-transform': 'translateY(' + (100 * count) + '%) '
});
count += 1;
});
  • First time button is clicked count would be 1, so translateY would correspond to 100*1=100%
  • Second time count is incremented by 1, so translateY would be 100*2=200%
  • and so on...

CSS Transition: one transform property, not the other

Not an ideal solution (from a purist's point of view), but have you considered wrapping the element inside another and just applying the transform to that one?

Remove hover effect after the element has moved away from mouse pointer

Posting my comment as answer,

The workaround here can be tweaking the z-index on every transition event.

Updated Fiddle

Notice the below CSS changes

.hoverTweak{    //new class
z-index: 2 !important;
}

.dashboard-submenu-item {
display: inline-block;
position: absolute;
top: 33%;
left: 17%;
z-index: 0; //change
color: #e50654;
transform: translate(0%, 0%);
}

Creating a Simple Element Scroll Animation (javascript/css)

I found a solution with lerp. This works great, for my scenario. Using react-spring, interpolation, animate, and Spring, you can create this easily. The element starts at the far end of either side of the screen, and when you scroll, the element slowly moves inwards and stops at (0,0). I added the page width back to the interpolation function so it doesn't start it out at 0.

<Spring
native
from={{
x:
document.documentElement.scrollHeight -
document.documentElement.clientHeight,
}}
to={{
x: props.position.y,
}}
>
{({ x }) => (
<animated.p
style={{
transform: x.interpolate(
(x) =>
`translate(${
x +
document.documentElement.scrollHeight -
document.documentElement.clientHeight
}px,0)`
),
}}
>
ELEMENT
</animated.p>
)}
</Spring>;

CSS responsive design overlapping body

1) You shouldn't have HTML code outside of the <body> tag for elements that are meant to be displayed on the page. Your footer should be contained inside the <body> tag. You can create a <div> to contain the elements which you now have in the body of the document.

2) To avoid the overlapping (considering that you want to keep your existing code structure and CSS) you can set a margin-bottom equal to the height of your footer to the container of your main content. This approach will work if your footer always has the same height.

3) If your footer needs to change in height, another simple solution (but with drawbacks) is to let the footer stick to the normal page flow, instead of absolutely positioning it to the bottom of the document, and to set a min-height to the container of your main content. The min-height should be set to ensure that your footer won't be positioned in the middle of the user's screen on pages that are short (that don't have a lot of content in them). The min-height on the main content's container will in this case create whitespace below the main content that will push the footer down.



Related Topics



Leave a reply



Submit