You can’t add CSS in an HTML widget like that. Add CSS via the Customizer: https://codex.ww.wp.xz.cn/CSS#Custom_CSS_in_WordPress
Thread Starter
Daniel
(@davil2008)
Actually I discovered that the problem was that I didn’t add a <style> tag to the code. But I now have a problem with the scrolling, it stops a bit before the top of the page. Can you help me tell it to scroll a bit higher ?
If you use a fixed-height/sticky header, you have to account for an offset. It’s a pain in the you-know-what. https://www.caktusgroup.com/blog/2017/10/23/css-tip-fixed-headers-and-section-anchors/
Thread Starter
Daniel
(@davil2008)
My case is a bit different. The scrolling stops right before this header social icons, see screenshot: https://ibb.co/NFsgJ1H
Rather than add your own “top” button, use one of the many plugins for this. They worry about all this stuff so you don’t have to. https://ww.wp.xz.cn/plugins/search/top
Thread Starter
Daniel
(@davil2008)
I now having a plugin that does this, but I am now trying to delete unnecessary plugins, this is why I want to do this mannually.
Read the plugin’s code and see how they do it. But if you need the functionality, use the plugin. That’s what plugins are for.
Thread Starter
Daniel
(@davil2008)
I tried reading the plugin but I am a total beginner at this. eventually I found whats fixing the header, but it’s already based on other parts of the file. But I want to delete this plugin, because I can do this in five lines of codes, instead of over a 1,000. Anyway, when I delete this, it stops the smooth scroll and fixed scroll :
public function enqueue_js() {
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script( 'hash_link_scroll_offset', self::$url . "assets/js/hash-link-scroll-offset$min.js", array( 'jquery' ), self::VERSION, true );
wp_localize_script( 'hash_link_scroll_offset', 'hlso_offset', array( 'offset' => get_option( 'hash_link_scroll_offset', 0 ) ) );
}