Tips on resolving Toolbar and Sidebar issues without making adjustments to the top value

My design includes a fixed Top Toolbar and a fixed Sidebar. I am trying to position the Sidebar just under the Toolbar without using any top value or margin-top. This was achieved with Bootstrap-4 by setting a top value. Is there a way to accomplish this without the top value?

<!-- Sidebar  -->
 <nav id="sidebar" class="sticky-top sticky-offset">
    -----------------
 </nav>

<nav class="navbar fixed-top">
   -------------
</nav>

<style>
.sticky-offset {
    top: 56px!important;
}
</style>

I am looking for an alternative solution that does not involve using top

Answer №1

Can you provide more insight into why you are hesitant to add any top properties to your containers? Achieving your desired layout is quite simple if you nest your Sidebar container within the Toolbar container. By doing so, you can have the Toolbar set with position: fixed; and the Sidebar set with position: absolute;:

HTML

<div class="navbar">
  <span>Toolbar</span>
  <div id="sidebar">
    <span>Sidebar</span>
  </div>
</div>

CSS

.navbar {
  height: 50px;
  width: 100%;
  position: fixed;
  left: 0;
}

#sidebar {
  width: 50px;
  height: 190px;
  position: absolute;
  right: 0;
  top: 100%;
}

Take a look at this Fiddle demo for a visual representation: https://jsfiddle.net/giiintas/xLjvg17e/12/

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

CSS based on conditions for 2 specific divs

Hello, I am working on an HTML page where I need to apply CSS only if certain conditions are met. The div with the id "flipbook-page3-front" will always be present on this HTML page. Sometimes, another div with the id "pagesFlipbook" may also appear on t ...

What is the best way to customize a video in Bootstrap 5 so that it remains at the bottom of the screen with centrally aligned text

When using Bootstrap 5, I am facing a challenge with a video on the index page that plays beneath the navigation. I want to maintain the 16x9 aspect ratio and have centered text overlayed on the video. However, I encounter an issue when attempting to set a ...

Mobile site experiencing owl.carousel responsiveness issues after refreshing the page

I am currently working on a website located at . On the homepage, right after the slider, there is a carousel of three info boxes. However, in mobile view (developer mode), after a hard refresh or viewing the link on an actual mobile device, it displays a ...

Pass a JavaScript variable to a PHP script using AJAX when a button is clicked, with a dynamically set href attribute

This is the current situation: There is a checkbox on each row of a table that represents some information An initially disabled button becomes enabled when any checkbox is checked The button is enclosed by an <a></a> tag as shown: <a>&l ...

Experimenting with javascript through jasmine testing

I am new to Jasmine testing and would appreciate any help. I have an array of data that needs to be checked for existence. //result is an array of data. var availableTags = new Array(); function show(result) { var items = new Array(); ...

Removing the gridlines in a Linechart using Apexcharts

I am experiencing issues with the grid and Nodata options on my Apexchart line chart. noData: { text: none , align: 'center', verticalAlign: 'middle', offsetX: 0, offsetY: 0, style: { color: undefined, fontSize: &apo ...

Struggling to create a CSS dropdown menu where the dropdown items refuse to align to the left

I am currently working on creating a dropdown menu to reveal hidden elements on mobile devices such as smartphones. However, I am facing an issue where the child elements of the dropdown menu are appearing to the right of the parent element instead of the ...

What is the best way to create a toggle button that can show more or show less of a text snippet with animation?

Is it possible for someone to assist me with showing a long text partially and providing a "show more" button to reveal the rest, along with a "show less" option, all with some CSS animation? I was thinking of using a font awesome arrow down icon for expan ...

instructions on how to eliminate slideUp using jquery

I am trying to eliminate the slide-up function from my code $( document ).ready(function() { $("#tabBar ul.buttons > li > a").on("click", function(e){ //if submenu is hidden, does not have active class if(!$(this).hasClass("activ ...

What is the best way to make my input tags move downwards when resizing the screen?

I need help with a grid layout. My goal is to have the input tags (marked in blue) shift below when resizing the browser or viewing on a mobile or tablet device, while keeping the other three tags on the same line. I attempted to position the small box to ...

Dropdown menu utilizing processing API and interacting with AJAX and DOM manipulation

My API data is not showing up in the dropdown menu. If I use ?act=showprovince, I can see the result. example.html <head> <link rel="stylesheet" type="text/css" href="css/normalize.css"> <link rel="stylesheet" type="text/css" hr ...

Utilizing jQuery to receive a JSON response in an AJAX call and returning it as a

When passing JSON data to a generic handler page named GenericHandler.ashx.cs using a jQuery AJAX request with JSON as the data type, I aim to return an HTML table in string format from my handler code. context.Response.ContentType = "text/plain"; c ...

Determine the overall cost based on varying percentage increases for each step

I am currently working on developing a price estimation calculator. Here is the breakdown: For 1000 MTU, the price will be 0.035, resulting in a total of 35. For 2000 MTU, the price will be 0.034, making the total 67. For 3000 MTU, the price will be 0.03 ...

Tips on preventing the entire HTML structure from being displayed on my <div> element after an Ajax success(response) call

I have successfully implemented a user logon system on my website with flawless code execution. Check out the reset password Ajax request below. html <div id="forgotPass"></div> <script type="text/javascript"> ...

Troubles with Flex wrap in CSS3 on iOS 10.3.2 browsers (Chrome and Safari)

Before sending me to other similar questions, keep in mind that I have already gone through them, attempted the solutions, and they are not resolving my issue. The problem I am encountering involves the flexbox layout. I am using the flexbox layout for ce ...

The border length of the unordered list is equal to half of the length

I would like the blue borders of these "ul" elements to be centered beneath the black "li" elements, with a width that is 50% of the child width. However, I'm unsure about how to achieve this. I attempted using ":before", but it only seems to work for ...

"Is there a virtual keyboard available that supports multiple inputs and automatically switches to the next input when the maximum length

Looking to build a virtual keyboard with multiple inputs that automatically switch to the next input field after reaching the maximum length. Currently having an issue where I can only fill the first input and not the second one. Any assistance in resolvin ...

What is the best way to eliminate the extra space above a span when the parent element's font size is very large?

Dealing with a situation where the parent DOM-element has a large em-value which results in all inline child elements having a significant margin above them despite their smaller font-size: Here is the source (http://jsfiddle.net/rapik/w87m7/2/): <div ...

What is the best way to ensure that the item beneath two images is always centered in HTML5?

When designing a webpage with text and images, it's important to consider the layout on different screen sizes. To avoid text wrapping under images, adjusting the spacing around the image is sometimes necessary. Similarly, when embedding a video, cen ...

Tips for executing an href action within an iframe (using colorbox) following the completion of a PHP script

I am currently trying to figure out the best way to make a link open in an iframe (using colorbox) after a php script has finished processing. The reason behind this necessity is that within the php script, I generate a png image from a canvas element on t ...