Having difficulty moving the menu buttons to the right

Take a look at the code snippet below:

https://jsfiddle.net/fcx0wkq3/1/

When you expand the result window, you'll notice the menu buttons on the left. I am trying to adjust the position of these menu buttons to bring them towards the center or the right side of the screen. However, when I modify the <ul> tag as shown below:

<ul style="left:30%">

the result appears like this:

https://jsfiddle.net/70fbsL75/

As you can see, the buttons are now skewed. How can I fix this issue?

Answer №1

To properly position your navigation menu, you should remove the #cssmenu ul class from the grouped classes and instead add the following CSS:

#cssmenu ul {
margin: 0 0 0 30%; //Adjust margins as needed
}

Make sure to target both the #cssmenu and ul elements in your CSS to ensure proper rendering by JavaScript.

In addition, be sure to remove margins and padding in your media query CSS (usually around line 196 in your code) to reset the view on mobile devices:

#cssmenu ul {
width: 100%;
display: none;
margin-left: 0;
padding-left: 0;       
}

Remember to also remove any inline styling when using this method, such as:

<ul style="left:30%"> 

Instead, simply use:

<ul>

Answer №2

Boost the percentage up higher. Attempt:

<ul style="left:75%">

This action will shift it 75% away from the left side.

Answer №3

To adjust the layout, consider adding a padding-left to the list elements.

    padding-left:40px;

https://example.com/1

Alternatively, you can modify the text alignment using

  text-align: right;

https://example.com/2

Answer №4

To enhance the styling of your CSS menu, enclose your

<div id="cssmenu"></div>
within a new div element with a class called container. Then, add the following CSS rules to your stylesheet:

.container {
    background: #323232;
    text-align: center;
}
#cssmenu {
    display: inline-block;
    margin: 0 auto;
}

Answer №5

To adjust the spacing, you have two options: adjust the padding of your anchor or li element (as seen in the first row of the example)

padding-left: 120px;

Alternatively, you can center the text within your li element

text-align: center

Answer №6

To easily center it, adjust the li elements by setting display: inline-block, and then apply text-align: center to the parent container.

To eliminate any small gaps, set font-size: 0 on the parent element (learn more about the inline-block issue here).

Simply include this code:

#cssmenu ul {
    text-align: center;
    font-size: 0;
}

Make these adjustments:

#cssmenu > ul > li {
    display: inline-block; /* previously floated */
}

These changes will center the content, check out the demo here.

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

The addition of the woocommerce_add_to_cart action is causing issues with the website's native add to cart

After creating a node express API that listens for post requests from the woocommerce_add_to_cart webhook, I noticed that the payload it receives is not very useful. body:{ action: 'woocommerce_add_to_cart', arg:'098uoijo098920sa489983jk&ap ...

Title: "Custom Captions for Buttons on Telerik MVC Scheduler Form"

How do I modify the label of the Save button in my custom Telerik Scheduler form? I want to change it to "Book" instead of "Save". These buttons are generated dynamically when the "onAdd" event is triggered. Below is the code for my Scheduler: @(Html.Ke ...

Extracting a floating picture from an Excel spreadsheet using ReactJS

Is it possible to extract an image from an Excel sheet that is not contained within a cell, but instead appears to be floating above the cells? The XLSX library only gathers cell information and does not provide a solution. Are there alternative methods su ...

Unable to process JSON array

One issue I'm facing is with an 'onload' handler for my web page. The javascript function 'handleLoad()' that it calls has suddenly stopped working, specifically not being invoked after attempting to pass the output of json_encode ...

retain the input data from the form by using the keyup event

Currently, I have a scenario where an input field is used to capture user input. Instead of displaying the entered value directly, I am looking to store it in a variable and subsequently use it to retrieve data from a database. Below is the code snippet I ...

Issues encountered with Angular POST requests

I have established a registration and login system using passport.js. Additionally, I am incorporating Angular.js in the front-end. However, when Angular is used, the user signup process does not work as expected. Below you can find the code snippets for b ...

Attempting to transmit information using Ajax to an object-oriented programming (OOP) class

Trying to send data with username, password, etc from an HTML form -> Ajax -> Instance -> OOP class file. Questioning the approach... Begins with the form on index.php <!-- Form for signing up --> <form method="post"> <div ...

Prioritizing the execution order of useEffect in Next.js

Here is the code snippet from my _app.tsx useEffect(() => { console.log(1) }, []); And this portion of code is from my index.tsx useEffect(() => { console.log(2) }, []); Currently, in the console it prints 21 However, I want it to print 12 ...

What is the best way to make ng-style append to a pre-existing style?

I am facing an issue with my custom popover directive and another custom directive that uses it. I am attempting to use ng-style to adjust the width of the popover. Below is a code snippet from the directive's html template: <div my-custom-popover ...

The "div width 100%" property functions flawlessly when tested locally, yet fails to operate on the live server

Hello, I recently launched my new website at www.leafletsdistributors.com. However, I'm encountering an issue with the Get in touch section (the light grey colored area). Despite setting the width to 100%, it's not fully extending across the scre ...

Using ng-repeat and selectize in AngularJS to populate a multi-select drop-down with values and set selected values

In this instance, I was able to achieve pure HTML select multiple functionality by using this example (JS Bin of pure html select tag). However, instead of sticking to just the pure HTML approach, I opted to use the Selectize plugin. The confusion arose w ...

What is the method for automatically scrolling down while hovering over an image?

How can I make it so that when an image is hovered over, it automatically scrolls to the bottom of the image? I have a couple of questions: How can I ensure the image scrolls to the end when hovered over? Currently, when I hover over the image, it doe ...

Getting json data through ajax in asp.net

I am facing an issue with the variable data in the function ShowFavorites as it is showing as undefined even though my ajax call is returning a json string. <script type="text/javascript"> $(document).ready(function () { ShowFavorites(); fu ...

Ways to modify the pre-defined value in a TextField

I encountered a situation where I have a form with pre-filled data from a specific country. The data is initially read-only, but the user can click on the edit button if they wish to make changes. The issue arises when trying to edit the value in the Text ...

The battle of line-height versus padding for achieving vertical centering with one-lined text

One-lined text can be vertically centered using either the line-height property or by adding padding-top and padding-bottom. What are the advantages and disadvantages of each method? body { font-size: 12px; font-family: ...

Verify the presence of a particular attribute in an HTML tag using Capybara and polling techniques

In my HTML code, the attributes of buttons (such as "AAAAA") will change based on external events. This real-time update is achieved through AJAX pooling. <div class="parent"> <div class="group"><button title="AAAAA"/></div> <di ...

Guide on connecting a URL with a generated ID to the <a href> element

I am currently working on building my own portfolio website using Django. The main idea behind this project is to create posts showcasing the websites that I have developed. These posts will be featured on a page titled "Projects," where viewers can click ...

React 17 Form not registering the final digit during onChange event

I am currently experiencing an issue with a form that includes an input field of type "number." When I enter a value, the last number seems to be skipped. For example: If I input 99 into the box, only 9 is saved. Similarly, when typing in 2523, only 252 ...

Every time I switch to a new Vue.js route, I find myself inexplicably redirected to the bottom of the page, leaving me scratching my head in confusion

I'm really struggling to understand why this issue is happening because there doesn't seem to be any code that would interfere with the scrolling. Every time I click on the link, it immediately takes me to the bottom of the view. I'm not sur ...

Need Root Directories in Browserify and Using NPM (eliminating the constant use of '../../../..' in both cases)

Despite my extensive search for a solution to this issue, I have been unsuccessful so far – even after referring to the amazing gist on improving local require paths and thoroughly reading the Browserify handbook section on Avoiding ../../../../... I am ...