html - How to stop an element that is position:fixed from overlapping static positioned elements -
i beginner when comes css positioning.
my problem: attempting create element contains links social networking sites. want element "position:fixed;" not scroll, want have margin between #social div (the element trying this) , #bodycontainer div (which contains rest of website) - not want margin referencing off browser window (but based off of #bodycontainer div.
basically want to:
- disallow #social div overlapping #bodycontainer (rest of website), yet keeping #social 's position: fixed.
- keep margin between #social , #bodycontainer. not want base margin off browser window, want based off #bodycontainer div. how do this? (i want #social 5px left of #bodycontainer.
my code (shortened):
<body> <div id="social"> <div id="socialimages"> <a href="http://facebook.com/connor.lydon" target="_blank"> <img src="fblogo.gif"> </a> <a href="http://instagram.com/connorlydon" target="_blank"> <img src="instalogo.gif"> </a> </div> </div> <div id="bodycontainer"> <img src="lydon_websiteanimation.gif" id="header"> </div> </body> #social { position: fixed; float: left; width: 200px; height: 100px; margin-left: 10px; background-image: url(socialtalk.png); background-repeat: no-repeat; background-position: top-left; } #socialimages { width: 45px; height: 100px; margin-left: 200px; margin-top: 60px; } #bodycontainer { margin-left: auto; margin-right: auto; width: 726px; } i guessing quite simple question, , apologize. have looked @ many guides , have been having trouble figuring out on own.
if rephrase part of question can better understand please - gladly will!
i appreciate receive.
thank you.
try this:
<body> <div id="social"> <div id="socialimages"> <a href="http://facebook.com/connor.lydon" target="_blank"> <img src="fblogo.gif"> </a> <a href="http://instagram.com/connorlydon" target="_blank"> <img src="instalogo.gif"> </a> </div> </div> <div id="bodycontainer"> <img src="lydon_websiteanimation.gif" id="header"> </div> </body> #social { position: fixed; float: left; width: 200px; height: 100px; margin-left: 10px; background-image: url(socialtalk.png); background-repeat: no-repeat; background-position: top-left; } #socialimages { width: 45px; height: 100px; margin-left: 200px; margin-top: 60px; } #bodycontainer { width: 726px; position: absolute; left: 50%; margin-left: -363px; z-index: 1; }
Comments
Post a Comment