Smooth scrolling with just pure css
You can do this with pure CSS but you will need to hard code the offset scroll amounts, which may not be ideal should you be changing page content- or should dimensions of your content change on say window resize.
You're likely best placed to use e.g. jQuery, specifically:
$('html, body').stop().animate({
scrollTop: element.offset().top
}, 1000);
A complete implementation may be:
$('#up, #down').on('click', function(e){
e.preventDefault();
var target= $(this).get(0).id == 'up' ? $('#down') : $('#up');
$('html, body').stop().animate({
scrollTop: target.offset().top
}, 1000);
});
Where element
is the target element to scroll to and 1000
is the delay in ms before completion.
Demo Fiddle
The benefit being, no matter what changes to your content dimensions, the function will not need to be altered.
Pure CSS scroll animation
You can do it with anchor tags using css3 :target
pseudo-selector, this selector is going to be triggered when the element with the same id as the hash of the current URL get an match. Example
Knowing this, we can combine this technique with the use of proximity selectors like "+" and "~" to select any other element through the target element who id get match with the hash of the current url. An example of this would be something like what you are asking.
smooth scroll transition upon click using CSS only (no JavaScript allowed)
You can use scroll-behavior: smooth;
html {
scroll-behavior: smooth;
}
p {
margin-bottom: 600px;
}
a {
text-decoration: none;
background-color: red;
color: white;
padding: 5px;
position: fixed;
bottom: 40px;
right: 40px;
transition: 1s all linear;
-webkit-transition: 1s all linear;
-moz-transition: 1s all linear;
-ms-transition: 1s all linear;
-o-transition: 1s all linear;
}
<a href="#one">Up</a>
<p id="one">One</p>
<p>Two</p>
<p>Three</p>
<p>Four</p>
Pure CSS Continuous Horizontal Text Scroll Without Break
You could try having two marquees and set one of them with a delayed animation of 2.5s which is half the time of the full animation (5s).
.marquee { margin: 0 auto; white-space: nowrap; overflow: hidden; position: absolute;}
.marquee span { display: inline-block; padding-left: 100%; animation: marquee 5s linear infinite;}
.marquee2 span { animation-delay: 2.5s;}
@keyframes marquee { 0% { transform: translate(0, 0); } 100% { transform: translate(-100%, 0); }}
<p class="marquee"> <span>This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - </span></p><p class="marquee marquee2"> <span>This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - </span></p>
Related Topics
Why Use * Selector in Combination with *::Before and *::After
Bootstrap 3 Navbar Active Li Not Changing Background-Color
Is There an Advantage in Grouping CSS Media Queries Together
Two HTML Tables Side by Side, Centered on the Page
Media Query for Vertical Scroll
(Css) Eliminating Browser's 'Selected' Lines Around a Hyperlinked Image
Styling of Select2 Dropdown Select Boxes
How to Override "-Moz-User-Select: None;" on a Child Element
CSS Conventions/Code Layout Models
Can You Style the Google Translate Plugin
Using Bootstrap and My Own CSS Together
How to Get a Floating-Div to Fill Available Space Within Its Parent Div
Side-By-Side List Items as Icons Within a Div (Css)