I'm looking for a way to use CSS3 Transition to create a s开发者_开发知识库mooth page scrolling. I know how to do it using javascript but if there's a way to do it with CSS3, i will prefer it for performance purpose.
You cannot control the scroll behavior with css. CSS3 transitions enable you to specify the way an element will go from an state to another, scrolling is a browser function not accessible to CSS.
You can use transform: translate(x,y)
to simulate "scrolling", and this can be animated using transitions via transition-property: all
; Note, you will have to add the appropriate vendor prefix, as with much of CSS3 at the moment.
References: Mozilla Dev Center: transform, Mozilla Dev Center: CSS Transitions
P.S. use percentages carefully with transform: translate()
-- depending on how your element is wrapped, -100% can mean next 'display-height' section of content
精彩评论