The issue with line-height causing the sliding URL effect to malfunction

Having a sliding underline URL effect (viewable here: http://codepen.io/Dingerzat/pen/XNgKmR), I encountered an issue when combining it with a resizing header. The resizing header caused the sliding underline effect to stop working. After some troubleshooting, I identified the culprit as the line-height property in the "header nav" class within the resizing header CSS. However, this line-height is necessary for the resizing header links to adjust when scrolling.

Is there a way to make these two pieces of code work together harmoniously?

Here is my attempt at combining them: http://codepen.io/Dingerzat/pen/bBRejp

/* CSS */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
  background: transparent;
  border: 0;
  margin: 0;
  padding: 0;
  vertical-align: baseline; }

body {
  line-height: 1; }

h1, h2, h3, h4, h5, h6 {
  clear: both;
  font-weight: normal; }

ol, ul {
  list-style: none; }

blockquote {
  quotes: none; }

blockquote:before, blockquote:after {
  content: '';
  content: none; }

del {
  text-decoration: line-through; }

/* tables still need 'cellspacing="0"' in the markup */
table {
  border-collapse: collapse;
...

<!-- HTML -->

<!-- title and meta -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="description" content="" />
<title>Header Resize On Scroll with Animations</title>

<!-- css -->
<link href='http://fonts.googleapis.com/css?family=Ubuntu:300,400,700,400italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css" />

<!-- js -->
<script src="js/classie.js"></script>
<script>
    function init() {
        window.addEventListener('scroll', function(e){
            var distanceY = window.pageYOffset || document.documentElement.scrollTop,
                shrinkOn = 300,
                header = document.querySelector("header");
            if (distanceY > shrinkOn) {
                classie.add(header,"smaller");
            } else {
                if (classie.has(header,"smaller")) {
                    classie.remove(header,"smaller");
...

Answer №1

The issue at hand arises from the use of line-height, which causes all elements inside to have vertical spacing that extends beyond the header due to the application of overflow: hidden;. Unfortunately, this prevents these effects from being displayed.

To tackle this problem, one solution is to include top: 90px; on both .sliding-u-l-r-l:after and .sliding-u-l-r-l:before.

Alternatively, you can swap out line-height with margin-top in header nav a.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Redirecting the parent window in ASP.NET using an iFrame

Can a response.redirect be used within an iFrame to redirect the entire page, making the destination page viewable in full screen instead of confined within the iFrame? Here is the current code behind: public partial class ServerResult : System.Web.UI.Pa ...

Tips for adding spaces or tabs in text with HTML/CSS

Here are some options to consider: <pre> ... </pre> or you could also use style="white-space:pre" Are there any other possibilities we should explore? ...

Personalize the appearance of a component using React Bootstrap styling

I am looking to customize the default style of a react-bootstrap component. For instance, when using the Panel component, I would like to make the title bold. How can I accomplish this without losing the default styles of a "warning" panel when using bsCl ...

Bottom dynamic div

I have three divs: head, foot and textbox. The head and foot divs are fixed positions, and the third div is partly fixed (margin-top). My query is: How can I adjust the bottom of the textbox's div to accommodate different monitor sizes? Using 100% h ...

Javascript function encountering difficulty accessing the 'this' variable

I am embarking on a new HTML5 game project, my very first one. Right now, I am working on creating a function that holds variables. While I cannot recall its exact name, I remember the process from a tutorial. In my attempt to set up some of these variable ...

Having trouble getting the image source to function properly with the Bootstrap Carousel feature in Django

I am struggling to include an image in my bootstrap carousel but the image is not loading. {% extends 'base.html' %} {% block html %} {% load static %} <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> </head> ...

Can you explain the distinction between using a period in a class selector and not using one?

Could someone please clarify the meaning of the code snippet below? <div class="cls1 cls2">abcd <div class="cls2"> adfffff </div> </div> .cls1 { background-color: yellow; } /*sample1 .cls1.cls2 { color: red; } */ /* ...

What is the best way to link data from SQL Server to an HTML webpage?

Seeking assistance on how to display data from a SQL Server database in an HTML page using JavaScript, AJAX, and jQuery without the need for C#, PHP, VB.NET etc. Can someone please provide some reference links or share example code? ...

What goes on behind the scenes of Angular interpolation with scripts?

I set up a variable called test = '<script>alert()</script>'. I then inserted this variable into an Angular component using interpolation like so: <div>{{ this.test }}</div>. However, instead of rendering properly, it just ...

Seeking guidance on traversing a nested list with JQuery

I'm facing a rather simple issue, yet I've spent countless hours trying to resolve it without success. The goal is to show a nested list whenever a parent list item is clicked. Here's the jQuery code: <script type="text/javascript"> ...

Using the html5-canvas element to drag connected lines

Here is an example of creating four points and connecting them: sample. My goal is to make it possible to drag the entire line connection when clicking on it, but when clicking on a circle, only that specific circle should be extended (already implemented ...

Saving the form data of a user into the Django models database

I have successfully implemented the login, authentication, and logout system. The next step is to incorporate a post functionality that saves data in the Tweet model. views.py from .models import NameForm from django.shortcuts import render, redirect, get ...

Increase the padding at the top and bottom of the div border

I am facing a problem with CSS shrinkwrapping. Here is the simple code snippet... <!doctype html> <html lang="en-US"> <head> <title>Device Activation</title> <meta charset="utf-8"> <style ...

What is the best way to retrieve dynamic content from a .txt file and have it displayed on multiple HTML pages as they are loaded dynamically?

I have a file named 'm_data.txt' stored on the server that contains a continuous total of 77 (for instance). The total gets updated via a push.php page that writes to the .txt file. <!DOCTYPE html> <html> <head> <title> ...

Displaying information collected from a submission form

I am in the process of designing a cheerful birthday card and I need to transfer data from a form to the birthday card page. How can I take information from the first div (which contains the form) and display that data in the second div? <!DOCTYPE ...

Exploring the positioning, placement, and orientation of Bootstrap popovers

Is there a way to prevent the bootstrap popover from moving away from the triggering element when the window is resized? What CSS should be used to position the tip of the popover near the top corner instead of on the left? Despite setting the placement ...

Utilize a dynamic URL within the HTML audio element

Currently, I am working with the use of the audio tag in HTML and AngularJS. I need to specify the source of the audio file I want to play, as shown below. <audio src="http://localhost/audio/221122/play/212223.mp3" audio player controls p ...

Is the 3D cube spinning with a slight perspective glitch?

I've successfully created a spinning cube using html and css. However, I'm facing an issue where pressing the up and down arrow keys causes the cube to rotate in a larger space rather than around its center. I've attempted using margin: 0 a ...

Unable to compress or condense several items

Trying to figure out how to create an Expand/Collapse button using bootstrap. I have two items that can be expanded or collapsed individually, as well as a main button that should expand or collapse all items at once. The problem is that if one item is exp ...

PHP POST request with an additional value being sent

Greetings as this is my debut post! Currently, I am facing a challenge in my project. As seen in the screenshot provided, I have several names fetched from the database and displayed in the main menu. Upon clicking the "modal" button, a Bootstrap modal wi ...