Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Alignment of submenu points in horizontal menu

Alignment of submenu points in horizontal menu

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 25 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abc
    wrote on last edited by
    #1

    Hey there, I have a question regarding the menu alignment. I'd like to have the submenu horizontally centered on the page, not centered under its menu point.

    Here https://zurichdanceensemble.ch/ueber-uns/
    I solved it with a translate
    .sub-menu {
    position: absolute;
    left: 50%;
    transform: translateX(-4.6%);
    }

    It's not convenient when adding a submenu to another secondary menu point, because the translate doesn't center it anymore, obviously. What is a better solution to this?

    Second thing I didn't manage is to have a fixed distance between primary, secondary and submenus. I might drawing a blank here :)

    Thanks so much in advance!

    1 Reply Last reply
    0
    • arminunruhA Online
      arminunruhA Online
      arminunruh
      Global Moderator
      wrote on last edited by arminunruh
      #2

      Screenshot 2025-05-05 at 08.04.50.png

      Hey, when writing your own custom CSS, you need to take a look at your inspector to see if this CSS is applied correctly.

      Here you can see some parts of your CSS are strikethrough. That means they don't get applied. This means you either need to make your CSS selector more specific because there is some CSS applied with a more specific selector that overrides yours.

      Or more simply you just use important.

      So your CSS should be.

      .sub-menu {
          position: fixed !important;
          left: 50%!important;
          transform: translateX(-50%)!important;
      }
      
      1 Reply Last reply
      0
      • arminunruhA Online
        arminunruhA Online
        arminunruh
        Global Moderator
        wrote on last edited by arminunruh
        #3

        The reason why your submenu wasn't centered on your website is: position absolute elements are positioned relative to their position relative parent.

        In my CSS above, I chose position fixed. position fixed elements are relative to the document itself.

        You can read more about position's different values and how they work here:
        https://developer.mozilla.org/en-US/docs/Web/CSS/position

        And your other concern was you wanted the menus to have the same space between them?

        The submenu seems to have a bit of a bigger gap right? Maybe you can just play around with your CSS a little bit and for example add a negative top value to the submenu CSS to make this gap smaller.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        I also code custom websites or custom Lay features.
        šŸ’æ Email me here: šŸ’æ
        info@laytheme.com

        Before you post:
        1. When using a WordPress Cache plugin, disable it or clear your cache.
        2. Update Lay Theme and all Lay Theme Addons
        3. Disable all Plugins
        4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

        This often solves issues you might run into

        When you post:
        1. Post a link to where the problem is
        2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
        3. If the problem is difficult to explain, post screenshots / link to a video to explain it
        Online Users
        arminunruhA
        arminunruh
        F
        francesco
        L
        lurchifon
        Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
        laytheme.com
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Recent
        • Tags
        • Popular
        • Users
        • Search