html - Block of text as a button bar -


http://jsfiddle.net/qewfp/

style.css

body {     background-color: #666666;     margin-left:500px;     margin-right:500px;     margin-top:10px;     margin-bottom:20px;     font-family:verdana, geneva, tahoma, sans-serif;     font-size:12px;      color:white; }  div.header {     background-color: #333333;   }  div.navigationbar {     border:0;     border-style:solid;     background-color:#112211;   }  div.navigationbutton {     border:1px;     border-color:#ffffff;     border-style:solid;     background-color:#112211;     padding:15px;     width:100px;     height:40px;     text-transform:uppercase;     overflow:hidden;     font-weight:bold;     text-align:center; }  .navigationbar ul {     list-style-type:none;        padding:1px; }  .navigationbar li {     display:inline;     float:left;  }  .navigationbutton {     text-decoration:none;     color:#eec600;     display:block; }   .navigationbutton a:link {     text-decoration:none; }   .navigationbutton a:hover {     color:#ffe811; } 

index.html

<!doctype html> <html> <head>   <meta charset="utf-8">   <meta content="pl" http-equiv="content-language">   <link rel="stylesheet" type="text/css" href="style.css"/>  </head> <body>   <div class="header" style="height:200px; width: 800px;"></div>   <div class="navigationbar" style= "height:73px; width: 800px;" > /* added unit height property */     <ul>       <li><div class="navigationbutton" ><a href="#link1">button1</a></div></li>       <li><div class="navigationbutton" ><a href="#link2">button2</a></div></li>       <li><div class="navigationbutton" ><a href="#link3">button3</a></div></li>     </ul>   </div> </body> </html> 

why there gap between header div , navigationbar? well-welcomed other comments , advices toward code.

the wretched gap occurs in web browsers image(why not in jsfiddle?), tried code in firefox , ie.

you have multiple mistakes going on here.

  • you shouldn't have div elements in list items
  • you have height without unit in html height:73;
  • your ul element needlessly encapsulated in div, links inside list items.
  • you mixing inline styles linked stylesheet.

can describe more of trying accomplish, or have examples?

i recreated think going in more cross browser compatibility way, let me know think.

additionally, here fiddle of same code, css split separate file: http://jsfiddle.net/fsvj3/

<!doctype html> <html lang="en"> <head>   <meta charset="utf-8">   <title>example</title>    <style type="text/css">     html {       padding: 0;       margin: 0;       background: #555;     }      body {       width: 800px;       margin: 0 auto;     }      #header {       width: 100%;       height: 200px;       background: #222;     }      #nav {       background: #0e1a0c;       width:100%;       float: left;       list-style-type: none;       margin: 0;       padding: 0;     }      #nav li {       float: left;       width: 100px;       height: 40px;       padding: 15px;       border: 1px solid white;     }      #nav li {       color: yellow;     }   </style>  </head> <body>   <div id="header"></div>    <ul id="nav">     <li><a href="#">button 1</a></li>     <li><a href="#">button 2</a></li>     <li><a href="#">button 3</a></li>   </ul> </body> </html> 

i'd add way trying center content in page (with margin on either side of body) produce pretty strange behavior. centered explicitly setting width, , using auto left , right margins.

ideally, i'd used container of sorts inside of body instead of giving these properties body element itself. simplicity sake applied styles directly.

i'd suggest not adding many elements have, purpose of div class navigationbar around list? can style list element instead.

it's important have markup need , try avoid markup used hook styles to.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -