Formatting for categories of list items

When working with an unordered list, I encountered a challenge where each list item needed to be a specified width. Due to varying text lengths in the list items and the limitations of editing the HTML directly (as I am modifying a template), I turned to adjusting the CSS instead. By using Inspect Element in my browser, I discovered that the HTML for the list item had the following structure:

<li class="w-menu-item wsite-nav-3" style="position: relative;">

After some experimentation, I attempted to control the width of the list element on the screen by adding the following CSS code:

#navigation .w-menu-item wsite-nav-3 {
width: 5%;
}

However, this approach did not yield the desired result. (#navigation refers to the containing div.) Could it be a syntax error, or is there another issue at play? If this method isn't effective, what would be the correct way to specify the width of the list and its elements?

Answer №1

It seems you overlooked a period ., denoting that wsite-nav-3 is a class identifier:

#navigation .w-menu-item.wsite-nav-3 {
/*                      ^            */
    width: 5%;
}

Answer №2

the desired outcome is

#navbar .menu-item.navigation-3 {
size: 5%;
}

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 modal in Angular15 will automatically show the date decremented by 1 day whenever it is displayed

Every time I open the date field in a modal, it decrements by one day. Here is the associated typescript file: dob!: DatePipe; rescueDate!: string; dateAdded!: string; openEditPetMenu(template: TemplateRef<any>, petId: number, name: string, ...

Learn how to toggle the visibility of three div elements arranged horizontally

$(document).ready(function () { $("#toggle").click(function () { if ($(this).data('name') == 'show') { $("#sidebar").animate({ width: '10%' }).hide() $("#map").an ...

Arrange, Explore (Refine), Segment HTML Chart

Is there a way to efficiently sort, paginate, and search (based on a specific column) data in an HTML table? I've explored several JQuery plugins such as DataTable, TableSorter, Picnet Table Filter, but none seem to offer all three functionalities (se ...

Unable to launch Google Maps in modal box

I want to implement loading the Google Maps .js API within a Bootstrap 3 modal box upon clicking a link, and then opening the modal box using the Google Maps initialize method. Here is an example of how this should work: HTML: <a data-toggle="modal" h ...

Guide on how to prevent Paste (Ctrl+V) and Copy (Ctrl+C) functionalities in a TextField within MaterialUI

Is there a way to restrict the Paste (Ctrl+V) and Copy (Ctrl+C) functions in a specific TextField within MaterialUI? I am currently working with ReactJs ...

JavaScript - task - collection of arrays

var x = new Array(); var y = new Array(); var z = [x,y]; var words = 'hello,world,nice,day'; for(var j = 0; j < z.length; j++){ z[j] = words.split(','); } Once executed, the desired outcome is: c = [x, y]; x = ['hello' ...

Tips on how to connect with ngFor

I have been working on an application to display various events, but I am encountering an issue. Whenever I load the webpage, it appears empty and the console throws an error saying 'Can't bind to 'ngForEvent' since it isn't a know ...

a guide on dynamically determining the value within a text input field

Does anyone know how to use jQuery to calculate values in a textbox for an invoice? I am not very familiar with jQuery and would appreciate any help in solving this issue. Within my invoice, there is a quantity textbox. If a user enters a quantity, th ...

Attempting to extract only the text content from a specific div using XPath

I am currently facing a challenge in writing a script to extract the title element from a poorly coded webpage. The developer who created this website did not use any classes, only div elements. Below is a snippet of the source code I am trying to scrape: ...

Displaying a progress bar while fetching data in Vue: A step-by-step guide

I am working on developing a progress bar using vue js and bootstrap for my desktop application. Within the template, I have the code that will generate the necessary markup: <div class="container-fluid p-0 vh-100" v-if="isLoading&quo ...

Best practices for hiding table rows in PHP when cells are empty

I am working with htmltopdf code provided by developers that includes a table with 'Question' and 'Answer' sections. My task is to hide any rows where the answer field is empty. Below is an excerpt from the code snippet: $pdfHTML = &a ...

The transformation of my Activity Class into an XML document

Last night, I finished working on my app for a school project before going to bed. However, I didn't build it because I planned on making some changes in the morning. When my classmates asked for help with their project, I opened Android Studio only t ...

Do not decode HTML content within an iframe; instead, extract the data directly from the HTML source

To expedite execution time, we have made the decision to not display the table in the iframe as it is invisible to the client. However, we still need to update the main page table by copying its contents. The approach we are taking is that the iframe shou ...

Preventing Cross-Site Scripting (XSS) vulnerabilities during the

When my site stores user-generated HTML to be rendered on a web page, what are the best practices to avoid XSS attacks? Is simply stripping <script> and <iframe> tags sufficient protection? Will this safeguard work across all browsers? I have h ...

the background image fails to appear in the div elements when using mobile jQuery

After setting a background image for a mobile page using mobile.jquery, I encountered an issue. When linking to the cdn version of the jquery css file: <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" /& ...

Encountering an issue with Masonry's container.append that is causing an Uncaught TypeError: Object does not possess the filter method

I have implemented infinite scroll on my website to display images. The images are arranged using a tool called masonry. Initially, I only load 10 images into the #container div when the page loads. These images are aligned perfectly with no errors in the ...

Challenges with fading images using jQuery

I am currently working on animating a 5 image slideshow by creating a fading effect between the images rather than just switching abruptly. Here is my HTML structure: <div id="slides"> <ul class="pics"> <li><img src="imag ...

Revise hyperlinks to correspond to specific page anchors based on current location

Not quite the same as the Adding custom anchor links and page links in WordPress menu clash, I have a similar issue. I am currently working on a Wordpress website with a main menu that has links to anchors for different sections of the homepage (example.c ...

Create a header for an HTML table

I need to style the header table with color based on a specific HTML structure. However, my CSS code doesn't seem to be working: <table class="dgrid" rules="all" id="Gridview2" style="border-collapse: collapse;" cellspacing="0" border="1"> ...

Enhancing User Input with jQuery Appending

My goal is to develop a user-friendly To-Do List with checkboxes for tasks listed under each checklist item. The plan is to compile the entire list and then send it to the server for database storage upon submission. I envision having input boxes structu ...