CSS styling that ensures a responsive design, where an inline unordered list is breaking into two lines, appearing to have adequate space

Currently working on a responsive website with navigation in the header using a UL set to display: inline. On desktop, there will be a logo on the left and navigation on the right. As the screen size decreases, the navigation will slide under the logo, both centered between 768 to 400 pixels wide and to the right below 400 pixels.

The UL is nested inside a container div, and the issue arises when resizing the browser within the 460-420 pixel range (exact values may vary across browsers). The navigation UL breaks into two lines instead of staying on one line within its container div, even though there is enough space for it to remain on a single line.

https://i.sstatic.net/aGviZ.png

For code examples, check out:

http://codepen.io/anon/pen/LRqbAO

Snippet of HTML code:


    <header>
        <div class="hamburger">
            <a href="javascript:void(0);" onclick="myFunction()"><i class="fa fa-bars"></i></a>
        </div>
        <div class="logo">
            <img src='design/testlogo.png' style='width:100%;max-width:338px;'>
        </div>

        <div class="shopping_nav">
            <ul>
                <li class='fasize'><i class="fa fa-location-arrow"></i></li>
                <li>Ireland<br>(Change)</li>
                <li class='pipe_char'>|</li>
                <li class='fasize'><i class="fa fa-globe"></i></li>
                <li>Shipped<br>Globally</li>
                <li class='pipe_char'>|</li>
                <li class='fasize'><i class="fa fa-shopping-basket"></i></li>
                <li>2 items<br>&euro;21.45</li>
                <li class='pipe_char'>|</li>
                <li class='fasize'><i class="fa fa-search"></i></li>
            </ul>
        </div>
    </header>

Snippet of CSS code:


/* CSS styles go here */

Answer №2

To optimize the mobile view, make sure to apply "text-align: center" instead of "text-align: right" in the current setting.

Check out the code beautifier tool here:

If you want to see the output, you can paste the code in this web viewer:

https://i.sstatic.net/4AQEZ.jpg

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 dynamically conceal an HTML element when another element is devoid of content

How can I dynamically hide the heading above a div if that div is empty? The content of the div will change based on user input. I would like the heading1 to appear immediately after a button click event. I am inclined towards a CSS solution, although the ...

Arrange elements with Material-UI's Grid system

Check out my codesandbox example (here) showcasing how I have set up my current app with Material-UI grid. I have 5 components that need to be positioned in a specific way for different screen sizes. For screens sized lg and above, I want the components t ...

enclosing a fixed or absolute div within a relative div

I am trying to ensure that the text on my website remains below an absolute positioned menu. The menu is overlaying a div with text, and I want the layout to appear as if the menu was relatively positioned. HTML <nav id="s-nav-wrap"> <di ...

When a table's row is clicked, it will expand to reveal a secondary table

I am facing an issue with rendering a table using v-for in Vue. I want to display a subtable or more information section below a specific row when it is clicked on. My attempts to add a new tr within the existing tr have resulted in errors or the new row ...

Floating text around an image inside a div with floated IE7

Struggling with positioning text around an image in IE7, it's not floating correctly as expected. The text appears below the image instead of beside it. After researching, I discovered that the issue might be related to placing both the image and tex ...

Struggling with integrating HTML Canvas within Vue.js

Currently, I am attempting to upload an image by utilizing HTML canvas. My decision to use canvas stems from the fact that I will be superimposing additional images based on the data received from the API, and this process seems more straightforward when u ...

Error encountered while attempting to save HTML table data as text in MySQL due to SQL syntax

Query for adding text to the database: INSERT INTO uri VALUES('') I encountered the following syntax error: 'MySql.Data.MySqlClient.MySqlException' was found in MySql.Data.dll You have an error in your SQL syntax; please refer to t ...

Icon Vanishes When Drop-down is Chosen (and the label value is loaded dynamically)

I am facing an issue with adding an icon to a text value in HTML. The problem arises when the icon is added to a Bootstrap button. Upon selecting a value from an external source, the button label changes accordingly. However, this change in text causes the ...

Printing doesn't display CSS styling

I am currently working on creating a function to change the font color, however, I am facing issues with the CSS when it comes to printing. Here is the code I have: $('#draw').on('click', 'p', function () { if($(this).ha ...

Leveraging node and node-phantom for scraping an AngularJS Application

I've successfully configured a node script to scrape pages from an AngularJS application and generate testing code. The only issue I'm facing is with ng-if. As ng-if removes elements from the DOM, my script doesn't capture these blocks of co ...

Struggling with Bootstrap 4 Navigation - Placement of Icons Challenge

I'm struggling with aligning the search and shopping cart "icons" on mobile. On desktop, the icons should be positioned to the right of the menu as they currently are. However, I want to move the icons to the left side of the hamburger icon in respon ...

Struggling to perfect your CSS menu design?

For some time now, I have been experimenting with CSS menus that have three levels, but unfortunately, I am struggling to get the layout exactly how I want it. The menu structure itself is simply a series of nested unordered lists within the HTML: <ul ...

Having trouble loading CSS in an express view with a router

I am encountering an issue where I am unable to load my CSS into a view that is being rendered from a Router. The CSS loads perfectly fine for a view rendered from app.js at the root of the project directory. Below is my current directory structure, node_ ...

Ways to resolve an unhandled promise in audio issues

A scenario where a piece of JavaScript is used to manage multiple audio elements is demonstrated below. var audio = []; audio["blue"] = new Audio("piano-blue.wav.mp3"); audio["red"] = new Audio("piano-red.wav.mp3"); ...

Split the pane into divisions with a minimum width restriction

Is there a way to have two divs at 50% width, even if the content of the first div has a minimum size? <div class="col-xs-6"> <div style="min-width:1000px"> <label>The value here...</label> </div> </d ...

Is it possible to create an HTML dropdown menu with integer values?

What is the best way to create a dropdown menu in HTML with integer values ranging from 1 to 12? How can I ensure that when a value is selected, it gets saved into a variable? All I need is a simple select field in HTML that displays options from 1 to 12 ...

The angular-block-ui feature fails to run my HTML code as a personalized message

I'm looking to enhance my UI by implementing a blocking feature with a spinner display. My attempt involved the following code: blockUI.start("<div class='dots-loader'>Minions are Working!</div>"); // code for fetching data ...

Responsive navigation bar elements adjust to the width of the content

Currently, I am in the process of upgrading to bootstrap 4 but have encountered some challenges. One issue I am facing is with my navbar. It currently appears like this: https://i.sstatic.net/5a4Et.png The problem lies in the fact that the right navbar-c ...

Removing a jQuery class while simultaneously adding it to different elements

I am currently working on a webpage where I have a row of 6 images. The first image, when the page loads, undergoes transformations using CSS3 due to a specific class applied to it. When the user hovers over the other images in the line, the same class is ...

Tips for making a bootstrap card that matches the container's height and includes a scrollable body

I am currently working on a Bootstrap card that needs to match the height of its container. Specifically, I want the card header to be at the top, the footer at the bottom, and the body to fill the remaining space. The body should also be scrollable to acc ...