- This topic is empty.
-
AuthorPosts
-
August 13, 2013 at 4:19 am #146619
helpls
ParticipantHello!
I’ve got a problem when trying to use position: fixed; for my website.
Here is my design: zd.se/newdesign/
At the moment all content added to the red div box get hidden behind the menu. How do I push down the red div box to display beneath the menu?
I’d really appreciate your help on this as I’ve got no idea what to do and if I just got this working I think I’d be on a good way on getting a real nice design together.
John
August 13, 2013 at 5:02 am #146631Paulie_D
MemberYou just need to add
padding-top: 35px;
to your #toppers divThe 35 px is the same height as your fixed header
August 13, 2013 at 5:04 am #146632helpls
ParticipantKind of figured it out. Had to put position: relative on #wrapper and .box and then z-index: 1; on the #header.
August 13, 2013 at 5:04 am #146633helpls
ParticipantJust noticed your answer Paulie, gonna try that out as well.
August 13, 2013 at 5:08 am #146635helpls
ParticipantAlright, both solutions seem to work. I’ve really never tried working with position: relative; etc as I’ve never really needed to and always tended to position my divs with margins and it worked for what I have wanted to achieve so far.
One downside I found with your solution is that the div tag is still hidden underneath the header, which means I can’t really leave some space between the header and #toppers as I intended to for visual design reasons.
Which solution do you think is best?
Edit: woops, sorry about the triple posting, didn’t notice the edit button until now.
August 13, 2013 at 5:12 am #146636Paulie_D
MemberThe z-index solution doesn’t show your ‘test’ text does it?
Hence the need for the padding-top. :)
August 13, 2013 at 5:19 am #146638Paulie_D
MemberOne downside I found with your solution is that the div tag is still hidden underneath the header, which means I can’t really leave some space between the header and #toppers as I intended to for visual design reasons.
The #toppers div is now the top element because of the fixed positioning of the header.
If you need ‘visual space’ between the header and #toppers there are a couple of things we could do.
It all depends on what the design is supposed to look like.
August 13, 2013 at 5:31 am #146642helpls
ParticipantFor it to display the test message I had to put top: 45px; in #toppers. Then it was pushed down below the header as I wanted.
I’m a bit frightened to use position: relative etc because I’ve never done it before so yeah, if there’s a good solution using your method instead to add some space like shown on the image below below the header that would be awesome.
August 13, 2013 at 7:10 am #146674Paulie_D
MemberOK…we need to cheat here a little.
Ideally we could just add a margin-top to #toppers and that would just drop everything down by the specified amount.
However, if you do just that then the margin technically has nothing to push against and the whole thing drops down.
I know, it’s stupid but that’s the way things are.
There is a fix where you add an invisible border-top which gives the margin something to push against and it seems to work.
So…try this on #toppers.
margin: 45px auto; border-top: 1px solid transparent;
August 13, 2013 at 8:05 am #146686helpls
ParticipantThanks. But that wouldn’t work and I kinda understand why.
I should need to create a new empty div above #toppers as for a margin to work it need to have something to push away from as you explained.
To test I tried creating this div in index.html:
Ok, I can’t figure out how to add code to this message, but basically I just added a new div tag to the html document with div style width=1px and height=1px
Sure it works, but it’s not so clean. Any better solution than creating an empty div?
August 13, 2013 at 8:08 am #146688Paulie_D
MemberThanks. But that wouldn’t work and I kinda understand why.
Worked when I tried it on your site before…I’ll try it again.
Oops.
The border-top should be on the #wrapper not on #toppers.
August 13, 2013 at 9:47 am #146712helpls
ParticipantAlright, that worked better!
However, I noticed when scrolling down that there was now a small line (the transparent border which we added) over the fixed menu. As a result of this I decided to go with my div style option instead. It shouldn’t have any impact on the website anyways other than some CSS nerd might find it and think it’s ugly which isn’t that big of a chance or deal. :)
Thanks for all your help! Really awesome.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.