Challenges with shifting the header navigation from top to bottom on a responsive website

As I was revamping my portfolio website to make it more responsive, I encountered a challenge. I have a navigation menu at the top of the screen, but I wanted to position it at the bottom when viewed on a smartphone.

Typically, I would use a media query for iPhones to change the positioning from top to none and add bottom: 0 instead of top: 0 in the CSS rule for the navigation menu.

However, despite my efforts, I couldn't seem to get it to work properly.

Here is a snippet of the CSS code:

    /* this is inside @media all */
header {
    position:fixed;
    top:0;
    left:0;
    display:block;
    width:100%;
    height:60px;
    border-bottom:1px solid #108ac2;
    box-shadow:1px 1px 1px 1px rgba(16,138,194,0.76);
    background:#fff;
    opacity:.9;
}

header nav {
    width:960px;
    margin:0 auto;
}
    /* this is inside @media screen and (max-width: 480px)  */
header {
    position:fixed;
    bottom:0!important;
    left:0!important;
}

header nav {
    width:90%;
    margin:0;
    height:80px;
}

You can check out my test site where I'm working on this here.

Your assistance would be greatly appreciated. I have searched but couldn't find a solution to this issue. Thank you!

Answer №1

After applying the css for @media screen, it also carried on and applied the css for @media all. This was causing an issue, so I made some adjustments by adding css for the top of the header and margin on the body, which seemed to solve the problem.

    /* Custom styling within @media all */
header {
    position:fixed;
    top:0;
    left:0;
    display:block;
    width:100%;
    height:60px;
    border-bottom:1px solid #108ac2;
    box-shadow:1px 1px 1px 1px rgba(16,138,194,0.76);
    background:#fff;
    opacity:.9;
}

header nav {
    width:960px;
    margin:0 auto;
}
    /* Additional styling within @media screen and (max-width: 480px) */
header {
    position:fixed;
    bottom:0!important;
    left:0!important;
    top: initial;
}

header nav {
    width:90%;
    margin:0;
    height:80px;
}
body {
    margin:0 0 100px 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

Using conditional CSS values in Angular 8

I am currently working on a parent component and child component setup, where I am utilizing the child component's selector to display it within the parent component. Here is my child component's HTML: <div class="main-container" [n ...

Is there a way to detect if JavaScript is disabled using a unique CSS selector?

Does anyone know of a CSS selector that can be used when JavaScript is disabled? I'm not referring to the noscript tag, but specifically in CSS. ...

AngularJS search box functionality allows users to easily search through a

1 I am looking to develop a search box using AngularJS similar to the one shown in the image. While I am familiar with creating a normal text box, I am unsure of how to incorporate the search icon. Any guidance on how to achieve this would be greatly appr ...

Is there a clash between flexbox and Google PageSpeed Insights when it comes to optimizing images?

I attempted to optimize the images on the page using Page Speed Insights. Currently, there are 3 images that need to be optimized, but Google is providing some odd results. The images change their appearance after optimization, even when setting image wid ...

Is it possible for an animation to complete even if it is stopped midway?

I am currently working on a media player project where I have implemented a scrolling marquee effect for the song meta information using JavaScript and CSS. The scrolling effect only occurs when the track is playing, and I achieve this by adding/removing ...

Finding a solution to use webpack style loader to allow the importing of css directly into my components

I am currently experimenting with the GitHub repository at https://github.com/sahat/megaboilerplate with a goal of importing CSS from within my components. Below is the configuration I am working with: const path = require('path'); const webpac ...

Unable to properly connect my CSS file to the header partial

I am struggling to include my CSS file in the header partial Here is the link I am using: <link rel="stylesheet" href="stylesheets/app.css"> This is what my directory structure looks like: project models node_modules public stylesh ...

Adjust the text placement following its entry on the screen

I'm currently facing an issue with my code that involves text sliding in and then moving to the left after the slide completes. How can I ensure that the text remains in place once the slide is finished? <style> div.slide-left { width: ...

The navbar background spans the full width of the screen, with all content contained within minimum and maximum width parameters

Currently, I am working on a fluid website design where I have set specific min-width and max-width values. However, I want the navigation bar background to extend across the entire screen width without being limited by the max width parameter, while still ...

Is the item positioned above another item instead of being positioned to the left of it?

Looking for help with my mobile navigation setup. I want to add text that says ' ...

Fluidity of Containers on Mobile Devices

I currently have a list structured like this: https://i.sstatic.net/ei4Xt.png In order to display more details about each list item, I've added a hidden div that can be toggled open like so: https://i.sstatic.net/61k5Z.png While this works fine on ...

Create space between two table-cell div elements by adjusting the margin

Two buttons need to be displayed in one line with vertically aligned text, so I used display: table-cell. However, the two divs are sticking together and margin is not working. Is there a way to separate them? Check out the code here: http://jsfiddle.net/ ...

When the mouse is moved to the UL LI list, the border color of the Top Hover is reverted back to default

Can you assist me with this issue? I need to modify the code below so that the border color remains blue while a user selects an item from the UL LI list. Here is an image showing the current problem: https://i.sstatic.net/DS7hO.png And here is a pictu ...

Create a div that can grow in size without the need to set a specific height for it

Here is an example of my HTML code: <div id="wrapper" class='common'> <div id="left" class='common'>Menu I Menu II Menu III Menu IV</div> <div id="right" class='common'>hello world..hello world ...

Changing the stylesheet on a single-page application

Our angular-built single page app features a drag-and-drop interface for code snippets, each with its own unique styles separate from the main Bootstrap-themed admin panel. However, due to the differences in styling, navigating to the drag-and-drop sectio ...

Modifying the color of a non-active tab - Material UI Tabs

Is there a way to customize the color of inactive tabs in Material UI tabs? I have noticed that they currently appear black, as shown in the screenshot here: screenshot Thank you! ...

The website is experiencing display issues when viewed on Internet Explorer 10 and above

I am currently managing a few websites running on aspx with an older version of DNN 4.x. While these sites display properly on Google Chrome, Fire Fox, Opera, etc., I have noticed that there are rendering issues specifically on IE 10 and above for the navi ...

The sticky navigation bar allows for the overlapping of additional div elements

Here is the HTML AND SCSS(SASS) code for a NAVBAR: <div id="navbar"> <ul> <li><a href="#home">Home</a></li> <li><a href="#main">Main</a></li> ...

Columns in Bootstrap4 housing elements positioned absolutely

Recently, I've been developing a game that involves using absolute positioning for certain elements. This is necessary for creating moving animations where elements need to slide around and overlap to achieve a specific effect. As I focus on optimizi ...

Utilizing CSS to position elements on a webpage

Currently, I am immersed in a CSS and HTML project aimed at honing my skills. The main challenge I face involves positioning a Google Maps image to the right of a paragraph. Despite several attempts, I have been unable to achieve the desired layout. Can an ...