The behavior of a fixed position in Flexbox varies when comparing Chrome to Safari and Firefox

In Chrome, the following code works as expected, with the list element positioning itself at the very left of the .PageContainer when scrolling down. However, in Safari and Firefox, the list element positions itself just after the logo. Are there any CSS rules that I might be missing?

var stickyEl = $("#top-navigation"),
    elTop = 0;
 
$(window).on('load', function () {
    elTop = stickyEl.offset().top;
});

$(window).on("scroll", function() {
  stickyEl.toggleClass('sticky', $(window).scrollTop() > elTop);
});
.PageContainer {
border:1px solid green;
margin-top:5px;
margin-right: auto;
margin-left: auto;
width: 80%;
height: 1200px;
  }
 
  .nav-wrapper {
width: 100%;
background-color: whitesmoke;
display: inline-flex;
border:1px solid red;
vertical-align: middle; /*this is to remove white space between divs */
  }
  
  .myLogo {
width: 20%;
float: left;
padding-bottom: 0;
margin-top: 0;
margin-bottom: 0;
border:1px solid blue;
  }
  
  .top-navigation{
    border:1px solid red;
    margin-left: 1em;
    position: relative;
    margin-top: auto;
margin-bottom: auto;
  }
  
  .topnav {
list-style-type: none;
padding: 0;
margin: 0;
  }

  .topnav li {
display:inline-block;
  }

  .topnav li a {
display: inline-block;
color: black;
text-align: center;
text-decoration: none;
font-size: 17px;
transition: 1s;
padding: 16px 16px;
  }
  
  ul.topnav li a:hover{background-color: #555;}
  
  .sticky {
    position: fixed;
    top: 0;
    margin-left: 0;
    -webkit-transform: translateZ(0);
  }
  
<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

</head>

<body>

  <div class="PageContainer">
  
     <div class="nav-wrapper">
    
  <div class="myLogo">
  
<svg viewBox="0 0 200 200" style="display: block;">
 <circle cx="100" cy="100" r="100" fill="red"/>
 <line x1="0" y1="100" x2="200" y2="100" stroke="white"/>
 <text x="100" y="100" text-anchor="middle" dy="0.35em" font-size="300%">my logo</text>
</svg>

  </div>
  
  <div class="top-navigation" id="top-navigation"> 
    
  <ul class="topnav" id="myTopnav">
<li><a  href="#home">Home</a></li
><li><a href="#news">News</a></li
><li><a href="#contact">Contact</a></li
  </ul>
  
      </div>
  
  
    </div>
  </div>

</body>

Answer №1

Dear @SpyTh, if you are facing challenges with cross browser support as mentioned in the post, I suggest utilizing Autoprefixer. Just input your CSS code and it will generate CSS that is compatible with various browsers. You can access Autoprefixer here.

I trust this information proves beneficial to you!

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

Switch up the color of checkboxes with a dropdown menu option

I have an HTML dropdown code and I am trying to trigger a click event when a specific value is selected. Once this value is clicked, I want some checkboxes to change color. <select> <option value="calculate">calculate</option> ...

Utilizing a custom function declared within the component to handle changes in Angular's ngOnChanges

Although it may seem like a simple question, I'm struggling to find a solution. Here's the issue at hand: In my Angular Component, there's a function that I need help with. export class RolesListComponent implements OnInit, OnChanges { ...

Conceal All Other Divs upon Clicking on a New Div Bearing the Identical Class

I'm having trouble implementing the feature that closes other divs when I click on a new div with the same class. It seems like it should be straightforward, but for some reason, it's not working for me. Here is the link to the fiddle where I&apo ...

Guide to making a sidebar navigation menu on the left using Bootstrap

How can I create a left navbar using Bootstrap? I managed to do it. <nav class="btn-group-vertical float-left navbar"> <button routerLink="product/home" routerLinkActive="is-active" class="btn btn-outline-dark">Home</button> ...

Implementing Pagination for JSON-list items in AngularJS

On my webpage, I have a large list of Json data that is organized with paging. The issue arises when selecting categories from the listbox as the data does not display properly. When "All" is selected, each page shows the correct pageSize(4). However ...

"Enhance your website with a dual-column layout using jQuery for

Hello, I am currently utilizing a fiddle link to move one div upward and another div downward simultaneously. While the left column is behaving as expected, I would like to achieve the same functionality for the right column as well. The link being used ...

Display the chosen alternative in a Bootstrap dropdown menu

I am currently facing an issue with the dropdown list in my bootstrap menu. <li class="dropdown"> <a aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown" class="dropdown-toggle" href="#">Chose option<span class="c ...

Positioning the box in the middle of pages

I have a website page at the following link: However, the content is not centered on the screen. Here are the codes I'm using: <div class="section_inner"> <div class="container"> <div class="row"> <?ph ...

Altering the ASP DropDownList's background color solely with CSS modifications

Is there a way to change the background colors of dropdownlists in my C# web app using CSS instead of specifying each one individually? In simpler terms, I'm trying to avoid having to write out code like this for multiple dropdowns: private void For ...

Display the current count of selected radio buttons in real-time

I am working with radio buttons that are generated dynamically using a 2D array within a while loop. I want to display the number of radio buttons checked when one is clicked. Here are my radio buttons: $n=0; while($row=mysqli_fetch_row($rs)){?> <f ...

PHP: implementing several forms on a single webpage

In my current situation, I need to display forms that resemble an Excel sheet with a submit button next to each row. When the submit button is clicked, the data is saved for that specific row, the row is disabled, and the focus automatically moves to the n ...

How to stop the overflow scrollbar in a grandchild element with CSS grid

Encountered an unusual issue while using a combination of CSS grid and overflow auto. In the scenario where there are 3 elements, the outermost element has display: grid, the middle element has height: 100%, and the innermost element has both height: 100% ...

React-select: issue with maintaining selected option on input

Hello everyone, I am new to React and seeking some assistance in reviewing my code. I have a component called Bucket that contains multiple challenges as separate components. Here is a simplified version of the code: class CLL_Bucket extends Component { ...

React - Why does React fail to update the state when expected? (not retaining)

Hello there, I'm currently working on fetching JSON data from an API and populating it into a table. It seems pretty straightforward but here's where things get tricky – I can see that the "tableData" state is getting updated as new rows are ad ...

Generate an automatic "proxy" for ASP.NET MVC Controller to communicate with AngularJs service

Whenever I utilize an ASP.NET MVC controller with AngularJS, the majority of my controller functions consist of JSON results. When creating my AngularJS service, I find myself repeatedly writing similar code to handle GET or POST calls to my ASP.NET contro ...

Troubleshooting issues with Bootstrap Accordion functionality within a React environment

After copying and pasting the Accordion code directly from Bootstrap, I'm facing an issue where the style is not consistent and the functionality isn't working as expected. Snippet from About.js: import React, { useState } from 'react' ...

"Stylish hover effect for list items using CSS arrows

I'm struggling with creating a list menu that has a 1px border and spans the entire width. Here is what I have so far (image 1): https://i.stack.imgur.com/y3EDP.png The tricky part is making it so that when the mouse hovers over a menu item, someth ...

Vue and Vuex retrieve state data from the server in a single request

When loading the History view, data is fetched from the backend server using a Vuex action called in the created() lifecycle hook. This data is then passed to the history table through a computed function named history(), which accesses the history module ...

What's the issue with this HTML button not functioning properly?

I'm having an issue with a button in my code that is supposed to change the text from 'hello' to 'Goodbye', but for some reason, it's not working. I have ensured that my code is properly indented in my coding program. Below i ...

Clicking on multiple external links will open them in separate tabs simultaneously

My attempts to find a solution on Google have been fruitless. I am in the process of creating a content aggregator, which is essentially a list of links to external websites. I want each link clicked to open in a new tab. Currently, I am using target="bl ...