Skip to content

Instantly share code, notes, and snippets.

@minitech
Created September 18, 2012 02:35
Show Gist options
  • Save minitech/3740941 to your computer and use it in GitHub Desktop.
Save minitech/3740941 to your computer and use it in GitHub Desktop.
Fixed elements that have a right margin relative to a content element
/**
* Fixed elements that have a right margin relative to a content element
* http://stackoverflow.com/q/12469476/707111
*/
html, body {
height: 100%;
margin: 0;
}
#button-wrapper {
bottom: 40px;
left: 50%;
margin-left: 350px;
position: fixed;
}
#button {
background-color: red;
padding: 5px;
position: absolute;
right: 10px;
white-space: nowrap;
}
#content {
margin: 0 auto;
width: 700px;
min-height: 100%;
background-color: #eee;
}​
<div id="content">this is my page</div>
<div id="button-wrapper">
<div id="button">magic button</div>
</div>
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment