Navigation links can become stacked when the page is zoomed out

Currently working on a website using html and css. I have managed to create a navigation bar with links, but the issue arises when I zoom out - the links stack on top of each other rather than staying in line. Any guidance or tips would be greatly appreciated. Thanks!

<html>
<head>
<link rel="stylesheet" href="style/style.css" />
</head>
<body>
<div class="wrap">
<div class="logo"><img src="img/logo.png"></div>
<div class="nav">
<ul>
<li><a href="">HOME</a></li>
<li><a href="">PRODUCTS</a></li>
<li><a href="">SHOPS</a></li>
<li><a href="">FAQ</a></li>
<li><a href="">ABOUT US</a></li>
</ul>
</div>
<div class="main">

</div>
</div>
</body>
</html>


     body {
    padding: 0;
    margin: 0;
    background: #1b1b1b url('../img/bg.jpg') no-repeat fixed top center;
}

.logo {
    margin-bottom: 10px;
    margin: auto;
    width: 524px;
}

.wrap {
    width: 960px;
    margin: auto;
}

.nav {
    height: 37px;
    background-color: rgba(26,26,26,0.8);
    border: 1px solid black;
    margin-bottom: 10px;

}

ul {
    margin: 0;
    padding: 0;
    text-align: center;
    line-height: 38px;
}

ul li {
    display: inline;
    color: #828282;
    padding: 2px 40px;
    background: #595959;
    border:1px solid #828282;
    margin: 0 10px;
}

ul li a {
    text-decoration: none;
    color: white;
    font-family: arial;
}

ul li a:hover {

}

.main {
    min-height: 300px;
    height: auto;
    background-color: rgba(26,26,26,0.8);
    border: 1px solid black;
}

Answer №1

"the links are stacking on top of each other instead of being in a row"

To resolve this issue, simply add the float: left; property to your li element as shown below:

ul li {
    display: inline-block;
    float: left;
    color: #555555;
    padding: 4px 30px;
    background: #777777;
    border:1px solid #555555;
    margin: 0 15px;
}

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

Ways to incorporate a scroll feature and display an iframe using JQuery

Is there a way to animate the appearance of hidden iframes one by one as the user scrolls down the website using jQuery? I have come across some solutions, but they all seem to make them appear all at once. I'm looking for a way to make the iframes s ...

Removing lines of text from the output of a JavaScript retrieval

Currently, I have a working script that retrieves a complete address block to be inserted into a selected field. However, I am now attempting to remove unnecessary parts of the generated text block for better display. This is the code snippet: <script ...

A pair of inline divs (personal computer) set with vertical alignment in the center on media sources

Struggling to create a topbar for a webpage with 2 inline divs and having difficulty centering them vertically on media screens. (Paint) example of what I am trying to achieve Currently using float: left; to keep the divs inline along with display: inlin ...

Alternative options in Javascript for event listeners

Apologies if it seems like I'm asking for opinions, I could use some clarification. I'm curious as to why it's necessary to replace attributes such as onclick with anonymous functions. What benefits does this provide? For instance, if I ha ...

Having trouble viewing the search field text in Firefox 3.6?

The customized search form in this version is inspired by the default twenty eleven Wordpress one. While the default text appears almost everywhere, it may not be displayed properly in older versions of Firefox and Internet Explorer. This could be due to ...

Error encountered - registration form

<?php $mysqli = mysqli_connect('localhost', 'test', 'test123', 'test'); if ($mysqli->connect_errno) { echo "<p>An error occurred while trying to connect: {$mysqli->connect_error}</p>"; ...

Image Not Displayed on Page

I am facing an issue where I have a div class 'breadcam_bg' with an image url, but the image is not being displayed on the page even though the console detects the div. html <div class="bradcam_area breadcam_bg"> This div! & ...

converting an entire HTML layout into a PDF using JavaScript

I am attempting to convert an HTML design to PDF using the following script: <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js"></script>. I have designed a table to my liking, here is how it looks in HTML: https://i. ...

Having difficulty highlighting text within a div using Three.js

After successfully creating a 3D interactive animation using Three.js, I added a Div element that hovers above the rendered objects in space. To ensure I can select text inside this Div, I adjusted the z-index property to a higher value. However, I encou ...

Issues with Jquery/AJAX function not responding to onChange Event

I am currently working on a project where I need to populate a dropdown menu based on the value selected from another dropdown. However, I am encountering an issue with the function that I am trying to call in the onChange event of the select tag. This is ...

Adding new fonts to an Angular 2 web page

I am working on an Angular 2 application and I want to incorporate wrapbootstrap. However, I am facing an issue with the fonts (bootstrap, font-awesome, google) and I am not sure how to include them. While using the css file for wrapbootstrap, I am gettin ...

I am attempting to update the background image pattern every time the page refreshes. Despite trying numerous codes, I have not been able to achieve the

Here is my code that I've been struggling with. I am trying to change the image on page refresh, but it's not working as expected. <SCRIPT LANGUAGE="JavaScript"> var theImages = new Array() theImages[0] = 'images/1.png' ...

What is the secret to achieving this distinctive title format?

Exploring a unique title style idea where the text breaks within the line. Unsure if this would be classified as a border or something else. Any suggestions? Still experimenting and brainstorming, unable to come up with a solution so far. ...

Fuzzy backdrop sets the scene for a sleek login modal box

I'm working on an application that requires a login box with a transparent background to display the body's background image, similar to LinkedIn: LinkedIn uses a blurry background for their login box. How can I achieve this effect using CSS? I ...

Show feedback on the webpage

I've encountered a challenge when trying to post comments on the page based on the posting ID. Controller: public function viewUserQuestion(Post $post) { $comment = Comment::where('post_id', $post->id)->get(); return view(& ...

The css cropping issue with sprite image is not being resolved

I'm currently working on creating a sprite image for the bottom links on our media page, but I seem to be having trouble getting the image to crop correctly. Can anyone point out where I may be making a mistake? CSS .footer{ position:absolute; ...

Place a fresh banner on top of the Ionicon icon

I recently started using Ionicons from and I am not too familiar with css. My question is, can a banner that says 'new' be overlaid on the top right corner of the Icon? Is there a simple or standard method to achieve this? (whether it's an ...

What is the reason for my HTML elements inheriting the opacity of their parent elements?

After inserting an image tag into my HTML document, I noticed that it was inheriting the opacity from the parent div element. Despite multiple attempts to adjust this, I have been unsuccessful. Here is an example: <div style="opacity: 0.7"> <img ...

Various colored backgrounds in a random arrangement on a grid post layout

I'm looking to implement this plugin for displaying blog posts, but instead of using an image as the background, my client wants different colored images. I have managed to figure out the code to achieve this based on a post I found here, but unfortun ...

What is the best way to align text on both the left and right sides of a mat-card-header in Angular

I'm struggling to align text content in the header on both left and right sides of the header tag. I've tried various approaches, but none seem to work for me. Can someone please help? <div style="width: 40%"> <mat-card> <m ...