I am working on creating a menu bar that will be displayed at the top of my page. Each section of the menu will be a link to a different part of the page.
$(document).ready(function() {
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
$("#divone").css("width", (parseInt(w) / 6)px);
$("#divone").css("left", 0px);
$("#divtwo").css("width", (parseInt(w) / 6)px);
$("#divtwo").css("left", (parseInt(w) / 6)px);
$("#divthree").css("width", (parseInt(w) / 6)px);
$("#divthree").css("left", ((2 * parseInt(w)) / 6)px);
$("#divfour").css("width", (parseInt(w) / 6)px);
$("#divfour").css("left", ((3 * parseInt(w)) / 6)px);
$("#news").css("width", (parseInt(w) / 6)px);
$("#news").css("left", ((4 * parseInt(w)) / 6)px);
$("#sen").css("width", (parseInt(w) / 6)px);
$("#sen").css("left", ((5 * parseInt(w)) / 6)px);
});
I am trying to position each div at a specific distance from the left edge of the browser window to evenly spread out the menu items. My goal is to create a tab-like interface where users can click on different tabs to navigate through pages.
However, when I implement the code, the divs end up overlapping each other instead of being positioned as intended. I want some divs to appear further to the right than others, but it's not working as expected.
What could be causing this issue?
All the div elements are enclosed within a parent div. The parent div has its position set to relative, while the child divs have absolute positioning.
I also tried setting the display property to inline-block without success.