html - Making a position:static (or :relative) element span the width of the page -
i have top "tray" advertisement. can slide away beyond border of page, javascript script. "divider" below holds close icon, , cosmetic, gets fixed when page scrolled past point. (this prevent browser's theme screwing page design).
my problem before divider gets position:fixed
javascript, needs either position:relative
or position:static
, absolute positioning take out of flow of page. when set position:static
, width:100%
there margin shows background image through it. want cover entire top of page. i've searched solution, can't find on how remove border. easier explain using jsfiddle: @ top there part red border, , directly below divider fixes page when scroll down. cannot figure out how red border , divider (before becomes fixed) span width of page.
here's offending piece of html:
<div class = "adtray"> <div class = "ad"></div> <div class = "ad"></div> </div> <div class="topborder"></div>
and css:
.adtray{ border: 1px solid red; height:100px; width:100%; } #topborderscrolled{ position:fixed; z-index:100; } .topborder{ right:0; left:0; top:0; background: rgb(68,68,68); /* old browsers */ background: -moz-linear-gradient(top, rgba(68,68,68,1) 0%, rgba(51,51,51,1) 50%, rgba(38,38,38,1) 50%, rgba(20,20,20,1) 100%); /* ff3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(68,68,68,1)), color-stop(50%,rgba(51,51,51,1)), color-stop(50%,rgba(38,38,38,1)), color-stop(100%,rgba(20,20,20,1))); /* chrome,safari4+ */ background: -webkit-linear-gradient(top, rgba(68,68,68,1) 0%,rgba(51,51,51,1) 50%,rgba(38,38,38,1) 50%,rgba(20,20,20,1) 100%); /* chrome10+,safari5.1+ */ background: -o-linear-gradient(top, rgba(68,68,68,1) 0%,rgba(51,51,51,1) 50%,rgba(38,38,38,1) 50%,rgba(20,20,20,1) 100%); /* opera 11.10+ */ background: -ms-linear-gradient(top, rgba(68,68,68,1) 0%,rgba(51,51,51,1) 50%,rgba(38,38,38,1) 50%,rgba(20,20,20,1) 100%); /* ie10+ */ background: linear-gradient(to bottom, rgba(68,68,68,1) 0%,rgba(51,51,51,1) 50%,rgba(38,38,38,1) 50%,rgba(20,20,20,1) 100%); /* w3c */ filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#444444', endcolorstr='#141414',gradienttype=0 ); /* ie6-9 */ width:100%; height:15px; border:1px solid #111111; }
i hope made sense.
use reset.css normalise styles, read 1 of reset csss available here: http://meyerweb.com/eric/tools/css/reset/.
another quick way set margin on body zero, eg. body {margin: 0}
recommended way use reset.css.
Comments
Post a Comment