4
15 Comments

How to make a fixed header on Carrd?

So I saw Martin doing something like this, got very inspired and even tough im a little bit early in my css course I decide to give it a shot. It seems to kinda work but the widht isnt covering the full page and the container isnt taking a space in the page (it is floating). I suspect that it has something to do with HTML but cant figure out what.

this is the page

https://dwellhouse.carrd.co/

and here is the code

position: fixed;
padding-top: 8%;
background-color: #FFF;
z-index: +1;
width: 100%;

Any ideas? 🤔

posted to Icon for group Carrd
Carrd
on September 4, 2020
  1. 1

    Very cool to see how you built on top of the https://arestaurant.carrd.co template! :D

    The navbar looks good, but there's still a bit of a hack in the beginning when you scroll down. I had this problem for a long time also, but asked my developer friend to fix the code a bit, you can see the result here in a Carrd template that I made:
    https://getclockwise.carrd.co/

  2. 1

    It work very well in my phone, but only in landscape! Did you figured out or it’s the same css as the example?

  3. 1

    Looks like you got it working. What did the trick?

    1. 2

      Judging by the code there is this custom css that overrides the card css with the !important property for the header

      dwelhouse css

      #header.sticky {
      position: fixed !important;
      top: 0;
      width: 100% !important;
      background: #806DE8;
      z-index: 9999;
      margin-left: 0 !important;
      left: 0 !important;
      }

      clockwise

      #header.sticky {
      position: fixed !important;
      top: 0rem;
      width: 100% !important;
      background: #fff;
      z-index: 9999;
      margin-left: 0 !important;
      left: 0 !important;
      }

      @rustyy if you still have issues let me know I'll give it a shot

      1. 1

        Hi! I've been trying to do this too and it's also not filling the width, despite using 100% !important;

        any ideas?

        1. 1

          is your code somewhere where I can look at it?

          1. 1

            Hi, I've also tried this code and it doesn't fill the width. Any ideas? I used this code

            position: fixed !important;
            top: 0;
            width: 100% !important;
            background: #806DE8;
            z-index: 9999;
            margin-left: 0 !important;
            left: 0 !important;

            position: fixed !important;
            top: 0rem;
            width: 100% !important;
            background: #fff;
            z-index: 9999;
            margin-left: 0 !important;
            left: 0 !important;

            thanks!

            1. 1

              I'm sorry, but I can't say from that snippet I would need to see the entire site.

                1. 1

                  the position of the code seems to be at the wrong place.

                  Wrapper

                  Try to put the code further up, so that it is within the main div wrapper.

                  1. 2

                    Thanks! It works great now.

                    1. 1

                      Nice to hear that 👏🏽

                  2. 1

                    the only thing I'd add is that when it loads you see the header in the middle and not full width, and then a few seconds, and then it displays nicely full width. I don't know if anything can stop that jump happening?

                    1. 1

                      It has to do with the animation.

                      The animation for some reason blocks the header from stretching.

                      try to

                      1. take out the animation from the whole page see if it works

                      2. try to add "is-ready" to the class of the header

  4. 1

    This comment was deleted 4 years ago.

Trending on Indie Hackers
1 small portfolio change got me 10x more impressions User Avatar 29 comments AI Is Destroying the Traditional Music Business and Here’s Why. User Avatar 26 comments Fixing my sleep using public humiliation and giving away a Kindle User Avatar 23 comments A Tiny Side Project That Just Crossed 100 Users — And Somehow Feels Even More Real Now User Avatar 15 comments From 1k to 12k visits: all it took was one move. User Avatar 11 comments Tell me what your business does, I’ll show you the growth loops you’re probably missing. User Avatar 10 comments