CSS dropline menu

I am working on customizing a CSS dropdown menu for my website. My goal is to have the homepage aligned to the left side of the page instead of the center. Below is the style sheet and the div tags I am using for the dropdown navigation bar:

ul, li, html, a
{
  margin:0; padding: 0;

}

body
{
  text-align: center; 
  margin: 0 auto;
  padding: 0;
  font: 65% arial, sans-serif;
}

li
{
  list-style-type: none;
}

a
{
  text-decoration: none;
  color: #034af3;
}

ul#nav
{
  width: 22.5em;
  height:2.5em;
  margin: 2em auto 0;
  font-size: 1.5em;
}

ul#nav li
{
  position: relative;
  float: left;
  width: 5em;
  height: 2em;
  line-height: 2em;
  background-color:  #465c71;
  display: block;
  padding: 4px 0px;
  border-right: 1px #4e667d solid;
  color: #dde4ec;
}

ul#nav li.noBorder
{
  border-right: none;
}

ul#nav li:hover
{
  background-color: silver;
}

ul#nav li a
{
  display: block;
  float: left;
  width: 100%;
}

ul#nav li ul
{
  display: none;
}

ul#nav li:hover ul
{
  display: inline;
  float: left;
  width: 10em;
  height: auto;
  margin: 0; padding: 0.27em;
  font-size: 1em;
  text-align: left;
}

ul#nav li:hover ul li
{
  width: 100%;
  height: 2em;
  background-color: Yellow;
  border: none;
  border-bottom: 1px solid silver;
  overflow: hidden;
}

ul#nav li:hover ul li a
{
  display: block;
  margin: 0; padding: 0 0 0 .3em;
  height: 100%;
  line-height:2em;  
  color: #465c71;
}

ul#nav li:hover ul li a:hover
{
  background-color: white;
}
<div style="background:#3a4f63;">
  <ul id="nav">
    <li><a href="#">Home</a></li>
    <li><a href="#">Abour</a>
      <ul>
        <li><a href="#">About 1</a></li>
        <li><a href="#">About 2</a></li>
        <li><a href="#">About 3</a></li>
        <li class="noBorder"><a href="#">About 4</a></li>
      </ul>
    </li>
    <li><a href="#">Blog</a>
      <ul>
        <li><a href="#">About 1</a></li>
        <li><a href="#">About 2</a></li>
        <li><a href="#">About 3</a></li>
        <li class="noBorder"><a href="#">About 4</a></li>
      </ul>
    </li>
    <li class="noBorder"><a href="#">Contact</a></li>
  </ul>
</div>

Answer №1

Consider the following:

body { text-align: left; }
ul#nav { margin: 2em 0 0; }

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

SASS causing conflicts with CSS breakpoints selector overrides

I am working with a partial file named _display.scss. It includes various @mixin and styling classes related to the display CSS property. _display.scss @mixin d-block{ display: block; } @mixin d-none{ display: none; } .d-block{ @include d- ...

What is the best way to position an image in the center for mobile screens?

Struggling to center an image for mobile devices, I have successfully done so for tablets and regular desktop devices. However, I am facing challenges in editing the code to ensure full responsiveness for mobile devices. Additionally, there is excess white ...

Conflict between Angular's ng-repeat directive and Sass styling

Currently, I am working on a project and encountering an issue that is causing some difficulty: In order to create a navigation bar with equally distributed list elements based on the number of items, I am utilizing ng-repeat for data binding and Sass for ...

What is the reason AJAX does not prevent page from refreshing?

Can anyone offer some guidance on using AJAX in Django? I'm attempting to create a basic form with two inputs and send the data to my Python backend without refreshing the page. Below is the AJAX code I am using: <script type="text/javascript& ...

Ways to extract certain characters from each element in an array

I'm attempting to make the first four characters of each element in an array (specifically a list) bold, but I am only able to select entire strings: $("li").slice(0).css("font-weight", "Bold"); Is there a way for me to indicate which characters wit ...

JSP staying away from servlets

On my website, I have a .jsp page with a form like this: <form name="myForm" method="post" action="LoginServlet"> <div class="form-group"> <label for="exampleXPID">userid</label> <div class="input-gr ...

Text Box Driven Date Selection using Asp.Net's Date Picker Control

I have 2 text boxes that accept dates from a calendar control. One is for the "From" date and the other is for the "To" date. Here's how I would like the dates to be handled: For the first text box (From), it should only allow today's date or an ...

Is it possible to display a pdf.js page as actual HTML elements rather than as canvas or SVG?

I am in the process of creating a user-friendly mobile interface for pdf reading. However, I want to incorporate more advanced features by developing my own pdf reader instead of relying on the pdf.js team's viewer. Is there a method available to rend ...

Utilizing cheerio to set outerHTML in HTML

Could someone kindly assist me with setting the outerHTML of an element using cheerio? I seem to be encountering some issues with this process. For example, let's consider the following HTML structure: <div class="page-info"> <s ...

Is it possible to input a value into the "data-" field from the code behind of an ASP.Net WebForm?

My goal is to update the "data-pagecount" attribute of a span tag with an ID of "searchResultPager" using code behind. Here is what my current HTML looks like: <span id="searchResultPager" runat="server" data-pagecount="2"> I am unsure on how to m ...

Struggling to align list-items in a horizontal manner

I'm having trouble aligning the list-items in my horizontal navbar. Can anyone assist me in identifying the error? Below is the HTML code, which has a complex structure due to the use of the Wordpress thesis theme and Cufon for font replacement: < ...

Encountering difficulties linking to a stylesheet or a script in an HTML file delivered by Express server

Currently, I'm facing the challenge of breaking down my Express app code into multiple files. Unfortunately, I am unable to utilize <link href> or <script src> for linking stylesheets or scripts. Below is the relevant snippet from my inde ...

The CalendarExtender feature allows users to easily add years by simply clicking

<asp:CalendarExtender ID="ceBirthday" runat="server" TargetControlID="txtBirthday" CssClass="MyCalendar" Format="dd.MM.yyyy"> </asp:CalendarExtender> Is there a way to include years in the Calendar header for faster navigation? Currently, I ha ...

How can I make Material UI's grid spacing function properly in React?

I've been utilizing Material UI's Grid for my layout design. While the columns and rows are functioning properly, I've encountered an issue with the spacing attribute not working as expected. To import Grid, I have used the following code: ...

It is not possible to simultaneously utilize the properties `display: inline-block` and `width: 100%`

As someone with limited CSS knowledge, I have encountered a challenge. My goal is to ensure that my website's body has a width of 100%, while also preventing the content from wrapping when the browser window is resized. To achieve this, I attempted a ...

Arrangement of Divs in Mobile Design - Utilizing Bootstrap 4 Rows and Columns

I've been grappling with a layout issue while using Bootstrap 4, specifically concerning the positioning of elements on mobile devices. I was wondering if anyone could lend me a hand with this challenge. Let me illustrate the desired layout: Link to ...

After the rendering of the HTML, the value of the jQuery input does not change

Here we have a function that loads HTML onto the form class in a file. The quest[q] locates the appropriate HTML template to load from an array of templates. The HTML being loaded contains an input with an id of "p". I am attempting to set the value of th ...

Implementing a Tri-state Checkbox in AngularJS

I've come across various discussions on implementing a 3-state checkbox with a directive or using CSS tricks (such as setting 'indeterminate=true' which doesn't seem to work). However, I'm curious if there's another method to ...

Creating CSS styles for mobile devices, such as smartphones and tablets

Hey there! I've been using CSS for developing desktop websites for quite some time now, and I'm eager to expand my skills to build websites that cater to a variety of devices like phones, smartphones, tablets, and even consoles with web browsers. ...

How to emphasize a portion of an expression in AngularJS using bold formatting

I have a specific goal in mind: to emphasize part of an angular expression by making it bold. To achieve this, I am working with an object obj which needs to be converted into a string str. obj = $scope.gridOptions1.api.getFilterModel(); for (var pr ...