html - How do I add a background color to a text div without it coloring everything? -
i have navigation div anchored @ top of page. div entirely text, , works fine, when scrolling on image or text, cannot seen clearly. tried remedy adding background color div tag, reason, background color changes color of entire page, covering everything.
is due div being anchored top? there way clear it?
apologies lack of code before. here doing:
<html> <head> <title>stack overflow</title> <style type="text/css"> #nav { position: fixed; left: 0px; top: 0px; right: 0px; bottom: 0px; background-color: #0000ff; } </style> <link href="yotb.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="nav"><center>header</center></div> <div id="container"> <div id="content"> page content </div> </div> </div> edit: karim's answer fixed it. thank help, everyone.
what you've done here set position:fixed; element , declare it's boundaries top:0 bottom:0 it's gonna spread top bottom, , left:0 right:0 it's gonna spread left right, remove right , bottom (you don't need bro).
check out fiddle.
Comments
Post a Comment