How to Create a Sticky Header in the Free Version of Astra with CSS (NO PRO, NO PLUGIN)

Поделиться
HTML-код
  • Опубликовано: 25 авг 2024
  • The free version of the Astra WordPress theme doesn't have a sticky header available. In this video, I show how to use custom CSS to achieve the effect without having to purchase the pro version of Astra.
    You can view & copy the code snippet in my blog here - I keep it updated with the latest copies of the code as Astra releases updates - INCLUDING the new 3.0 update:
    cgscomputer.co...
    *****
    The following are affiliate links - if you purchase through the links I may earn a commission. It costs you nothing extra and helps me to fund this channel and my blog.
    Astra Pro current pricing: wpastra.com/pr...
    Elementor Pro current pricing: cgscomputer.co...
    Rank Math SEO Pro current pricing: rankmath.com/p...

Комментарии • 181

  • @cgswebdesigns
    @cgswebdesigns  3 года назад +6

    For those wondering - the blog post in the description contains the CSS code updated for Astra version 3.0.

  • @Injineerka2
    @Injineerka2 Месяц назад

    Why I am seeing this video after 3 years? Why?
    Thank you bro. Subscribed, liked and will will probably bookmark your channel.

  • @myrinaDM
    @myrinaDM 10 месяцев назад +1

    Thank you for helping us! Even with the current updates, one can assemble the code however they want, based on your instructions. 🤘

  • @ianharding3514
    @ianharding3514 9 месяцев назад

    Excellent tutorial. I had found the code on your website but it didn't work. Seeing this video showed me what to change (.site-header change to .main-header-bar) and it works beautifully, AND I now have the added advantage of seeing how it works. Thank you so much!

  • @MrFlamerFuel
    @MrFlamerFuel 3 года назад +1

    This works. CCS class for me is "main-header-bar-wrap" but the same for everything else. ty.

  • @reikodang5519
    @reikodang5519 4 года назад +3

    I'm super new to building website. This was so clear for someone like me. Thank you!

    • @cgswebdesigns
      @cgswebdesigns  4 года назад

      I'm glad you liked it. Thanks for watching!

  • @diariodiunpapàingiappone
    @diariodiunpapàingiappone 4 года назад +3

    Thank you for your precious video.
    I changed top 0 to 1.
    Perfect!
    Grazie!

  • @saramclaughlin7402
    @saramclaughlin7402 Год назад

    Thank you sooooo much, this is all I needed! And I especially appreciate you updating the blog too!

    • @cgswebdesigns
      @cgswebdesigns  Год назад

      Thanks so much for watching and commenting! I'm glad you got what you needed.

  • @sujithsukumaran4268
    @sujithsukumaran4268 4 года назад +2

    Thank you and you are awesome

  • @mauriziotocchioni4841
    @mauriziotocchioni4841 2 года назад +2

    Coincise and perfectly understandable, thank you for sharing your knowledge!

    • @cgswebdesigns
      @cgswebdesigns  2 года назад +1

      Thanks! I'm glad it was useful for you!

  • @mansbestfriend9632
    @mansbestfriend9632 4 года назад +1

    Thank you. Been looking for this for a while

    • @cgswebdesigns
      @cgswebdesigns  4 года назад

      Thanks for watching, glad it provided some value to you!

  • @TooMuchIntensity
    @TooMuchIntensity 8 месяцев назад

    YOU'RE A LIFESAVER ILY

  • @SinhalaMathsGuide
    @SinhalaMathsGuide 3 года назад

    Thank you very much for this. Actually I am lucky to see this. Please do more videos. It is very clear and easily understandable without any long unnecessary contents.

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      Thanks for watching, I'm glad it was helpful!

  • @m1lhau777x
    @m1lhau777x 6 месяцев назад

    Great tutorial, does anyone know how to make header shrink on scroll down?

  • @HafizRahmanBD
    @HafizRahmanBD 4 года назад +1

    You are a life saver brother. Thank you so much.

    • @cgswebdesigns
      @cgswebdesigns  4 года назад

      Thanks for watching! I’m glad you got what you needed from it.

  • @user-ug2ke7ig5b
    @user-ug2ke7ig5b Год назад

    The best solution ever
    Thanks man!

  • @wingsluxe
    @wingsluxe Год назад

    YOU ARE AMAZING. Thank you

    • @cgswebdesigns
      @cgswebdesigns  Год назад

      Thank you for such a nice comment! It's highly appreciated :-)

  • @free2idol1
    @free2idol1 3 года назад

    thank you and have a nice day!!! will remember to buy via your affiliate link when I need a pro version...

  • @Aticap
    @Aticap 4 года назад +2

    thank you for saving me a ton of time!

    • @cgswebdesigns
      @cgswebdesigns  4 года назад

      You're welcome, I'm glad you got something of value from the video :-)

  • @BishwajitChakrabortyy
    @BishwajitChakrabortyy 3 года назад +1

    This works fine in the desktop version. In case of mobile the menu doesn't scroll down. When I press the toggle button the menu still comes at the top of the page only. Help please.

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      Thank you for commenting. The code is set for Astra as it is on the default installation, I just checked again on my test site and the code is still valid on a fresh Astra free installation. However, if you're using other Astra features such as the Custom Headers or you've installed one of their starter templates, you may need to inspect your header elements in the html code to see what CSS selectors to target.

  • @CarlosAstudillo
    @CarlosAstudillo 11 месяцев назад

    Working in 2023. Thanks a lot

  • @nini851
    @nini851 Год назад

    Thank you, the tutorial is easy to understand, I tried and it works perfectly !

  • @kjarra
    @kjarra 4 месяца назад

    Really helpful and clear thank you !

  • @johnsonliu9851
    @johnsonliu9851 3 года назад

    Hi, thank you for making the tutorial and sharing the codes, it works perfectly in 3 different devices. Great Job!

  • @emirk8064
    @emirk8064 2 года назад

    Thank you!!! It works, and I'm very grateful to you!

  • @tomito78600
    @tomito78600 3 года назад +1

    you made my day man! Thanxs a lot!

  • @UDOY999
    @UDOY999 20 часов назад

    Thanks ❤

  • @reneedocktor
    @reneedocktor 8 месяцев назад

    Thank you so much; you've been a great help

  • @dr.mathiasbabel8120
    @dr.mathiasbabel8120 4 года назад +1

    Great job!
    Thank you very much.

  • @delphiniummarketing5712
    @delphiniummarketing5712 Год назад

    Thank you!

  • @1fighisimo
    @1fighisimo 4 года назад +1

    thank you so much for this insight!

  • @birgitwest143
    @birgitwest143 2 года назад

    Thank you! That was so helpful, and so quick!

  • @micheledekormicomsolutions3604
    @micheledekormicomsolutions3604 3 года назад

    Thank you so much !
    Your video was amazing clear. XXxx from France

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      Thanks for watching, I'm glad you got some value out of it!

  • @terrawattco
    @terrawattco 9 месяцев назад

    Hi, this is great! But it is for a post right? It is not working for me as mine is a page. Is there any way to do for that too?

  • @marioraetzel
    @marioraetzel 10 месяцев назад

    Thank you very much for the code. One question: did you put your mic right on the table? Because you can hear every move of your mouse

  • @VictoriaAlfredSmythe
    @VictoriaAlfredSmythe Год назад +1

    thank you

  • @vikaskushwah6813
    @vikaskushwah6813 3 года назад +1

    Great job!
    Thank you so much :)

  • @jjmovingsolutions
    @jjmovingsolutions Год назад

    howdy, any idea why this wouldnt work? I followed the instructions and the header is not sticky

  • @esteticasemprebella201
    @esteticasemprebella201 3 года назад

    Thank you!!!!!!! This video is gold!

  • @reynaldolunaroblero1057
    @reynaldolunaroblero1057 4 года назад +1

    Excelente Vídeo. Me funciono muchas gracias por tu aporte. Saludos desde México!

  • @agatafratczak3416
    @agatafratczak3416 4 года назад +1

    That`s very usefull. Good job! Thank you so much!

  • @ronnhogann6246
    @ronnhogann6246 3 года назад +1

    Thanks! ; )

  • @fayounguhie3378
    @fayounguhie3378 2 года назад

    Thank you, man. So helpful

  • @kashaffarooq8207
    @kashaffarooq8207 2 года назад

    It's working! Thank you.

  • @titusisrael3554
    @titusisrael3554 4 года назад +1

    keep up the good work. Nice

  • @BenchBear225
    @BenchBear225 Год назад

    Wow, super helpful!

  • @katharina2669
    @katharina2669 3 года назад

    thank you so much!! even i as a wordpress beginner could handle this:)

  • @jenithajeyakumar105
    @jenithajeyakumar105 2 года назад

    Superrrrr thanks very muchhhhhh

  • @gilataph2848
    @gilataph2848 Год назад

    Great tutorial and it works for me. what I need to do is, I have a above header and when you scroll down, only the main header will remain sticky and the above header will be pushed above?
    I hope you'll help me with this. Thanks!

    • @cgswebdesigns
      @cgswebdesigns  Год назад

      You would need some Javascript code in order to detect the scrolling. Unfortunately, I don't know how to do that just yet. :(

  • @ronstopchycki8086
    @ronstopchycki8086 Год назад

    Thank you for this great info!
    Is it possible to have only the "primary menu" of the header sticky and not the "below menu?"

  • @brakwameh6264
    @brakwameh6264 Год назад

    Fantastic! Can you please make a video showing how I make it fully transparent then when i scroll its semi or not transparent anymore after a length of scroll?

    • @cgswebdesigns
      @cgswebdesigns  Год назад

      Hi, thanks for checking out the article! In order to make the style change on scroll, you would need to write some Javascript code. Unfortunately, I'm not very good with that :/ Sorry!

  • @DSPplug
    @DSPplug 3 года назад +1

    Thanks, useful

  • @herypangestu6976
    @herypangestu6976 4 года назад +1

    Thank thank you so much

  • @aldeonyazlm1809
    @aldeonyazlm1809 3 года назад

    Thank you bro its really help

  • @satpalsinghrathore2665
    @satpalsinghrathore2665 3 года назад +1

    How to keep sticky header only for desktop? I don't want the sticky header for smaller screens.

    • @cgswebdesigns
      @cgswebdesigns  2 года назад

      You can use media queries in your CSS code the same way we adjust the padding for different screen sizes.

  • @anomthomas1781
    @anomthomas1781 2 года назад

    very nice video you deserve like dear

  •  3 года назад

    Great video!! Thank you a lot! ;)

  • @daysofimalka
    @daysofimalka 3 года назад

    Thankyou! I did it.❤️

  • @MrAlbashiri
    @MrAlbashiri 3 года назад

    Thank you so much.

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      You're welcome! Glad it was of use to you :-)

  • @onlineclub.
    @onlineclub. 3 года назад +1

    Thanks bro

  • @satpalsinghrathore2665
    @satpalsinghrathore2665 3 года назад

    Anchor links are not working nicely with the new transparent sticky header of Astra theme. It hides some of the text due to the header. Can you provide the code to solve this problem?
    I am using Astra free version and used your code to make it sticky.

    • @cgswebdesigns
      @cgswebdesigns  2 года назад

      Hey thanks for watching, I'm not actually sure how to make that happen. Since this code is applied to the Astra free version, the container and .js adjustments that make it smooth in the premium version don't come in to play. You can check here for possible answers: stackoverflow.com/questions/10732690/offsetting-an-html-anchor-to-adjust-for-fixed-header

  • @gquadoffice8123
    @gquadoffice8123 3 года назад

    thank you so much!!!!!

  • @basantsingh7943
    @basantsingh7943 3 года назад

    Thanks dude 😎

  • @vetmedicinae887
    @vetmedicinae887 4 года назад

    Work, thank you :O

  • @drjimbarnes
    @drjimbarnes 4 года назад +1

    I've tried your CSS code on the Astra Mountain template and the menu is sticky, but the background stays transparent no matter what colour or opacity I try in the last bit of your CSS code. It's a transparent header when inspect the style. Any way of making a sticky white background behind the sticky menu items?

    • @cgswebdesigns
      @cgswebdesigns  4 года назад +3

      Thanks for watching. When I originally made this video, transparent header was a premium feature but now they have it in the free version which means it has its own class - I've never used that template myself, but looking at the example from Astra's Starter Websites it looks like you can target their transparent header class with something like this:
      .ast-theme-transparent-header .main-header-bar, .ast-theme-transparent-header.ast-header-break-point .main-header-bar {
      border-bottom-width: 0;
      border-bottom-style: solid;
      border-bottom-color: rgba(0,0,0,0);
      background: #FFFFFF;
      position: fixed;
      width: 100%;
      }
      The last 3 lines are the ones I added in developer mode in Chrome and that made the header solid white, sticky, and stretched to the full width of the page.

    • @drjimbarnes
      @drjimbarnes 4 года назад

      CGS Investments LLC Thanks a lot! That’s great of you to go tot the trouble. 🤗

    • @elladitch9698
      @elladitch9698 3 года назад

      @@cgswebdesigns Thank you SO MUCH!! Really appreciate your help!!! You are the best!!!

  • @mynetwork3699
    @mynetwork3699 4 года назад

    great work

  • @nassoss1
    @nassoss1 4 года назад

    Thank you!!!

  • @nourchaer
    @nourchaer 3 года назад

    thank you so much

  • @HilalKhan-rq6bh
    @HilalKhan-rq6bh 3 года назад

    lovable gift for us, Thank you so much. big like and subscribe.

  • @AbdullahAshraff
    @AbdullahAshraff 3 года назад

    how can I do this for the blog site only ?

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      You could try using the blog selector... try using the same code but add .blog to the beginning of the CSS selector for the elements.

  • @rajon_kobir
    @rajon_kobir 4 года назад +1

    Grazie!

  • @Hipknotic_Designs
    @Hipknotic_Designs 3 года назад

    Hi, thanks so much for this tutorial, you explain things brilliantly. I'm not quite looking for a sticky header, i like the transparent look, but i want the header to shrink when people scroll, so the header remains at the top, with the menus still visible as they scroll. Does this make sense? I think it's on scroll effect.

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      Thanks for watching!

    • @SoftwareBasics
      @SoftwareBasics 3 года назад

      I think this is what you're looking for: ruclips.net/video/uIZz3ZpU7gU/видео.html
      It'll make your header sticky and shrink while scrolling.

  • @myrainys
    @myrainys 4 года назад

    Great. Tak!

  • @muhammedgad1536
    @muhammedgad1536 3 года назад

    Hi, could you please help
    what if i want it transparent on top but when i scroll it becomes opaque.
    or how to make the very top post come in front of the header, i tried changing z-index of top post but couldn't reach header z index
    Thank you

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      Thanks for watching and visiting my channel. Unfortunately as I have dug into the theme code for Free Astra, it doesn’t appear there is separate selector built-in for changing the color of the header after scroll. Even the Pro version of Astra doesn’t apply a scroll property - the Pro theme accomplishes the task using two separate headers, one of which is hidden based on the current scroll position.

    • @satpalsinghrathore2665
      @satpalsinghrathore2665 3 года назад

      @@cgswebdesigns In the latest Astra free version, the header by default is transparent. When I used your code to create sticky header it didn't worked well with "Table of Content" links. The transparent header cause the position to move below where it should be.
      Example: Visit this link: financevidhya.com/ppf-nps/
      Click on "Table of Content links " or the "Subscribe" button in the header.
      Can you suggest the code to remove transparent header? I want a solid header. I tried disabling it using Astra options but it didn't worked. May be your code overrides it. Thanks.

  • @majdapazman845
    @majdapazman845 2 года назад

    Hi, Sharif, this was awesome thank you!
    One question tho - I have a free version of Astra and am currently building my website. I cannot find where to change the look of the drop down Menu that comes from the main navigational menu. for example: when I hover over 'services' the drop down menu looks horrible - it is some kind of a bubble and i want to change it but don't know where. (I googled as well, still couldn't find it). Anyway, I would really appreciate if you could help :)

    • @cgswebdesigns
      @cgswebdesigns  2 года назад +1

      Hi, sorry I missed this question or I would have gotten a reply to you sooner. In Astra free it's pretty limited, but you should be able to find settings in the Header Builder section of the Customizer. Drop the Primary Menu widget into the Header Builder and then select the widget and click the DESIGN tab. That will give you the configurable options that are available. If you know CSS, you can also target the .sub-menu CSS class for your own customizations.

  • @ishized88
    @ishized88 4 года назад

    Try to click the link on the description above but I was denid access. can you help! Thanks

    • @cgswebdesigns
      @cgswebdesigns  4 года назад

      What country are you accessing the site from?

  • @karankrash9033
    @karankrash9033 3 года назад +1

    not working bro

    • @cgswebdesigns
      @cgswebdesigns  3 года назад +1

      I've tested this today with a fresh installation of the latest Astra theme, with no additional plugins, and the code still works. If you have additional configuration or plugins overriding the CSS then you may have different results.

  • @leonkambarami8091
    @leonkambarami8091 Год назад

    Where is the CSS code?

    • @cgswebdesigns
      @cgswebdesigns  Год назад

      The link is in the description of the video - I keep the code updated on the link since I sometimes have to adjust it after Astra updates. The latest working version will always be at the link in the description.

  • @violeta4558
    @violeta4558 4 года назад

    How to increase the font of the main menu in the header with an Astra theme for free?

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      You may just be able to add: font-size: 24px; to the same CSS IDs I used in the video.

  • @estebanrodriguez5820
    @estebanrodriguez5820 4 года назад

    I can´t enter to the site to see the code. Can you send me please.... Thanks

    • @cgswebdesigns
      @cgswebdesigns  4 года назад

      I changed up my Cloudflare settings, you should be able to get to it now.

  • @ricardoaguiar2522
    @ricardoaguiar2522 4 года назад

    Olá. Você pode liberar o código css do Sticky Menu Astra? Por favor. Parece-me que seu blog está fora do ar. Obrigado!!! I am fron Brazil.

    • @cgswebdesigns
      @cgswebdesigns  4 года назад +1

      I'm sorry, I have Brazil blocked via Cloudflare due to the amount of malicious traffic hitting my blog from there. The code is visible in the video. Please check out this code on PasteBin: pastebin.com/A7nbA6jj it is set to expire so I don't have to keep changing it there when Astra changes theme code.

    • @ricardoaguiar2522
      @ricardoaguiar2522 4 года назад

      @@cgswebdesigns
      It's all right. I teased the code of the video. thanks for sending the code link.

    • @estebanrodriguez5820
      @estebanrodriguez5820 4 года назад

      @@ricardoaguiar2522 Nao consigo ver o codigo. tem como me passar por favro

  • @callumyaw1203
    @callumyaw1203 3 года назад

    Hi there, thanks for making this video. I've copy and pasted the code for the Astra 3.0 Header Builder into the Additional CSS section of my site, but the sticky header is not working. All that happens is adding a frustrating 1px line underneath my header without it being sticky. Also the page is private and not published.
    Do you have any suggestions for where I may be going wrong?

    • @callumyaw1203
      @callumyaw1203 3 года назад

      I just used the beginning of the code and it worked but there's still issues with it sticking on responsive sizes, mobile in particular
      /*Make Header Sticky - for Astra 3.0 and later*/
      .site-header {
      position: fixed;
      width: 100%;
      }

    • @euliziliskawafune7096
      @euliziliskawafune7096 3 года назад +2

      @@callumyaw1203 Hi Friend, I had the same problem. I resolved with this code:
      .main-header-bar {
      position: fixed;
      top: 100;
      width: 100%;
      }
      .ast-mobile-header-content
      {
      position: fixed;
      top: 0;
      padding-top: 100px;
      width: 100%;
      }
      You will need to adjust the padding-top to the size of your menu. I hope it helps you

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      Thank you for commenting. The code is set for Astra as it is on the default installation, I just checked again on my test site and the code is still valid on a fresh Astra free installation. However, if you're using other Astra features such as the Custom Headers or you've installed one of their starter templates, you may need to inspect your header elements in the html code to see what CSS selectors to target.

    •  3 года назад +1

      @@euliziliskawafune7096 You, yes, you... You are a lifesaver. You... yes, you have to know that. The second line helps me a lot with my page. I had a problem with the submenu that didn't appear in the mobile. but with your second line of code, it works!!! Thanks so much and May the Force be with you...

    • @euliziliskawafune7096
      @euliziliskawafune7096 3 года назад +1

      @ Your welcome and also May the Force be with you... 😁

  • @ambayagya
    @ambayagya 3 года назад

    please do it in astra 3.0 free also please

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      I tested this today with the latest version of Astra and it still works.

  • @heyitsblissful1158
    @heyitsblissful1158 3 года назад

    Can i use this for free elementor version? Does it apply to all website?

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      I haven't tested it on a site running Elementor, it might work though.

  • @iamdaudkhan
    @iamdaudkhan 4 года назад +1

    helpfull

  • @wasimmomin8409
    @wasimmomin8409 3 года назад

    your website as for spam verification and nothing happens just the same thing again and agani

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      I apologize for that. I have a security verification provided by Cloudflare which challenges traffic coming from countries that generate the most attacks on websites, these countries include Brazil, Russa, China, & India. If you're in one of these countries you'll need to pass the verification to see the site. If you can't pass the verification, you'll need to try a different web browser that's up to date and secure.

  • @lajisjourney3241
    @lajisjourney3241 4 года назад

    Not working after latest update of astra theme. please help.

    • @cgswebdesigns
      @cgswebdesigns  4 года назад +1

      I checked it again on the latest version today and it still works. Exactly the same code on a fresh Astra theme. If you have installed an Astra site template, this may not be the case as their templates include other header functions that may override this.

    • @lajisjourney3241
      @lajisjourney3241 4 года назад +1

      It is working now...thanks a lot.
      Just one more question. Will this code work in ocean wp theme also or do we need different codes for different themes?

    • @cgswebdesigns
      @cgswebdesigns  4 года назад

      @@lajisjourney3241 You'll probably need different code. in Google Chrome, if you right click the header in OceanWP and choose "inspect" you can search out the CSS IDs of the header and try the code with that replaced to see if it works.

  • @unknownman1
    @unknownman1 Год назад

    not working anymore

    • @cgswebdesigns
      @cgswebdesigns  Год назад

      I just tested the current code on my test site and it's still accurate. You may need to double check you're using the code I posted in my blog - that's where I keep the code updated when Astra makes changes that require me to make adjustments. Also, if you're using an Astra site template from their collection of pre-built sites, some of them use different header options that negate the base code and you'll have to adjust it.

  • @Sankalpabuddhi
    @Sankalpabuddhi 3 года назад +1

    *copy paste this*
    /*Make Header Sticky*/
    .main-header-bar {
    position: fixed;
    top: 0;
    width: 100%;
    }

    • @cgswebdesigns
      @cgswebdesigns  3 года назад

      Thanks for watching :-) I didn't post the actual code here because as theme versions change, the code required is likely to change. My blog post has the latest version.

  • @vidya__bhushan
    @vidya__bhushan 4 года назад

    Your blog taking too long to open.

    • @vidya__bhushan
      @vidya__bhushan 4 года назад

      Btw it helped a lot. Thankyou from INDIA!

    • @cgswebdesigns
      @cgswebdesigns  4 года назад

      @@vidya__bhushan Thanks for hanging in there! I have some firewall rules applied to traffic from India because I get a lot of bots from there. I'm sorry that it slowed down your experience but I very much appreciate your feedback. :-)