Home:ALL Converter>Top menu bar and padding-top when resized?

Top menu bar and padding-top when resized?

Ask Time:2012-09-05T02:45:24         Author:David19801

Json Formatter

I have a top menu bar that is in position fixed and contains some text. When the screen is resized smaller it compresses and it's height increases to fit the text.

I have a div below the top menu bar that contains my website content, moved down using padding-top.

When the top menu bar resizes the top of the article gets covered by the height change of the top menu bar.

#topmenubar{position:fixed;width:100%;text-align:center;word-wrap:normal;}

#content {padding-top:40px;}

What is the best way around this so the resized top menu bar does not cover my content?

The Top menu bar has to always be visible at the top of the screen, so I guess how can I make the padding-top get bigger with the screen width getting smaller or another solution?

Author:David19801,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12269552/top-menu-bar-and-padding-top-when-resized
Chris :

Pure JavaScript solution (no jQuery required):\n\nwindow.onresize = function() {\n document.getElementById(\"content\").style.paddingTop = document.getElementById(\"topmenubar\").offsetHeight;\n};\n",
2012-09-04T18:57:40
Dariush Jafari :

jquery\n$(window).resize(function(){\n var h = $("#topmenubar").height();\n $("#content").css("padding-top",h+"px");\n});\n",
2012-09-04T18:51:14
yy