What is the easiest way to make the following page header a fixed header? http://presentationtube.com/header.php
Should I move the Menu elements in the header?
#templatemo_header_wrapper {
top: 0px; position: fixed
}
fixed at top 0
the easiest way:
#templatemeo_header_wrapper {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 9999;
height: 70px;
}
CSS:
#templatemo_header_wrapper {
position:fixed;
}
If that is not correct you will need to elaborate on your question.
EDIT
I would like to expand on this. There is extra markup that is not needed.
The current css looks like this:
#templatemo_header_wrapper {
width: 100%;
height: 65px;
margin: 0 auto;
background: #19446a url(images/templatemo_header_bg_65_ora.jpg) repeat-x;
}
As the body is already set at margin:0 and padding:0 you do not need to specify top and left coordinates for the #templatemo_header_wrapper. So to avoid writing additional css you can change the element to this:
#templatemo_header_wrapper {
width: 100%;
height: 65px;
background: #19446a url(images/templatemo_header_bg_65_ora.jpg) repeat-x;
position: fixed;
}
I've removed the margin property as this does not apply here. You can also dispense with the height property. Sometimes it is useful to set height for a fixed position element. But as you have child elements that also have height specified (and/or padding margins) this will naturally add height to the parent container as needed.
So the final markup could look like this:
#templatemo_header_wrapper {
position: fixed;
width: 100%;
background: #19446a url(images/templatemo_header_bg_65_ora.jpg) repeat-x;
}
Related
Dont know what to call it but I want a border that doesnt follow the divs height:100%; but is centered between top and bottom of the parent div.
What is the best solution? creating another div that contains the border? or is there any options in css that I dont know off?
heres a codepen to my current footer with the divs im using:
http://codepen.io/Volcan3/pen/yVoNZB
You could use pseudo classes to mimic a border that doesn't cover "100%"...
http://codepen.io/anon/pen/yVoORm
.footer-item::after {
content: '';
display: block;
height: 80px;
width: 1px;
background-color: red;
position: absolute;
right: 0;
top: 50%;
margin-top: -40px;
}
and then don't forget to make the parent item relative and a block:
.footer-item {
display:block;
height: 100%;
position: relative;
}
This is the website I am modifying: sb460training.org
Here is the code snippet:
#apdiv1 {
position: absolute;
width: 2815px;
height: 276px;
z-index: 1;
top: 1px;
left: 0px;
background-color: #000;
}
#apdiv2 {
position: absolute;
width: 3150px;
height: 115px;
z-index: 2;
left: 0px;
top: 230px;
}
#apdiv3 {
position: absolute;
width: 221px;
height: 411px;
z-index: 3;
left: 0px;
top: 259px;
background-color: #FFF;
}
#apdiv4{
position: absolute;
width: 2853px;
height: 115px;
z-index: 4;
left: 219px;
top: 401px;
}
Do you know what the width dimensions should be so I can get rid of the annoyingly extra space that shows up to the right of the web page?
Thanks
Like the other answers, I agree that your CSS should change the fixed widths to 100%.
However, in your HTML you have img elements with explicit widths, to substitute background colours. For example, in the "apDiv2" DIV element, you have an in-line image containing white, "SB460_Pic/Secondary title2.jpg". This image is set to 2128px wide, causing the page to extend horizontally.
I would recommend removing the images that are being used to pad the right of each DIV, and instead set background colours in CSS.
UPDATE
Quick and dirty example:
http://pastebin.com/4PmZN1r4
change all your container widths to 100%.
give your html a width:100%; margin:0;
give your body a fixed width:1200px or so.
set your body with a margin: 0 auto if you want it centered.
I've heard the same similar issue.
all you need to do is try working with margin set to 0 and auto.
in most cases, try eliminating the use of 'position absolute' and work more with margin, padding and position relative.
Hi guys, I use position:fixed for my header. After that, I tried to use a container, but I not sure why it is inside the header (Stacked). I tried use margin-top to separate container from the header, but its not working because the header also used the margin-top..
Here is my demo
In your .header class you have to add top: 0px:
.header {
position: fixed;
left: 0;
right: 0;
height: 120px;
background: #232323;
z-index: 10;
top: 0px;
}
How to set footer stick bottom if .content is absolute?
I tried this and also another use same method adding padding bottom.... but it is not work if .content is set position absolute and top
p.s I don't want to set footer fixed...
Thanks.
.head{
position: absolute;
left: 0;
top: 40px;
height: 160px;
}
.content{
position: absolute;
top: 200px;
}
.footer{
position: absolute;
bottom: 0;
}
<body>
<div class="head"></div>
<div class="content"></div>
<div class="footer"></div>
</body>
Assuming you want to use the solution presented in the answer you linked to, you have to stop using position: absolute. You can use margins to replace top:
.head {
margin: 40px 0;
height: 160px;
}
However, trying to use the sticky footer trick with this triggers an unfortunate property of CSS: if you have a margin on the first child element, that margin will propagate to the parent element. This causes problems with the sticky footer trick.
The solution to that is to use padding on the wrapper rather than margin-top on the header. Your code might then look like this:
.wrap {
padding-top: 40px;
}
.head {
margin-bottom: 40px;
height: 160px;
}
Having made those changes, the method described in the answer you linked to should work.
I am trying to make height auto. Whatever i tried did not work until now.
I am using masterpage, asp.net 4.0 ,css
Here the config
Here the css classes
*
{
margin: 0;
padding: 0;
}
.logo
{
height: 100px;
width: 1000px;
position: absolute;
top: 0px;
}
body, html
{
height: auto;
height: 100%;
}
.footer
{
visibility: hidden;
}
.MenuBarMasterPage
{
position: absolute;
top: 202px;
margin-left: auto;
margin-right: auto;
width: 1000px;
height: 40px;
}
body
{
background: #0C0C0C url(http://static.monstermmorpg.com/images/backgrounds/animus-mix.gif) repeat;
margin-right: auto;
margin-left: auto;
width: 1000px;
background-position: top center;
}
.main
{
position: absolute;
top: 242px;
width: 1000px;
background: #D1D1D1 url(http://static.monstermmorpg.com/images/backgrounds/content.png) repeat;
z-index: 2;
height: auto;
}
According to the firebug the computed style height of main is 0px this is the problem
To avoid having to manually set a different fixed height on each page (which is a terrible solution), you have two options:
Use JavaScript to calculate the height.
Don't use absolute positioning.
There is no reason to use absolute positioning for your layout. You should remove position: absolute from almost everything, and write new CSS.
You're going to need a lot of float: left and float: right.
If you're using Bootstrap 4 (Flex)
If your <img> is direct children of a div with display:flex, you might want to set display:block on parent div instead, so height:auto will work.