User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 391,690 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,205 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 565 | Replies: 4 | Solved
Reply
Join Date: Feb 2008
Posts: 30
Reputation: Metalsiege is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Metalsiege Metalsiege is offline Offline
Light Poster

CSS Centering Image Navigation Bar

  #1  
Jun 24th, 2008
I've been trying to figure out the best way to fix this problem for the past half day. I fixed some other issues with the image, but now I can't get it to be centered like the header image above it with the words on the gray line. I want to have the navigation image bar, which is the tabsLeft, tabsCenter, tabsRight, etc. to center just like it's image place holder above it. Any ideas? I've included the css, html, and an screenshot of the site for reference.


CSS File -> Style.css
  1. /********************************************
  2.   HTML ELEMENTS
  3. ********************************************/
  4.  
  5. /* top elements */
  6. * { padding: 0; margin: 0; }
  7.  
  8. body {
  9. margin: 0; padding: 0;
  10. font: normal .72em/1.5em 'Trebuchet MS', sans-serif;
  11. color: #ffffff;
  12. background: #000000 url(bg2.jpg) repeat-x;
  13. text-align: center;
  14. height: 100%;
  15. }
  16.  
  17. /* links */
  18. a { background: inherit; color: #fa8d00; }
  19. a:hover { background: inherit; color: #006699; }
  20.  
  21. /* headers */
  22. h1, h2, h3 {
  23. font: bold 1em 'Trebuchet MS', Tahoma, Sans-serif;
  24. color: #fa8d00;
  25. }
  26. h1 { font-size: 1.4em; }
  27. h2 { font-size: 1.2em; text-transform: uppercase;}
  28. h3 { font-size: 1.2em; }
  29.  
  30. p, h1, h2, h3 {
  31. margin: 10px 15px;
  32. }
  33. ul, ol {
  34. margin: 10px 30px;
  35. padding: 0 15px;
  36. color: #fa8d00;
  37. }
  38. ul span, ol span {
  39. color: #fff;
  40. }
  41.  
  42. /* images */
  43. img {
  44. border: 2px solid #fa8d00;
  45. }
  46. img.float-right {
  47. margin: 5px 0px 5px 15px;
  48. }
  49. img.float-left {
  50. margin: 5px 15px 5px 0px;
  51. }
  52. a img {
  53. border: 2px solid #fa8d00; /* #32CD32; */
  54. }
  55. a:hover img {
  56. border: 2px solid #806B4D !important; /* IE fix*/
  57. border: 2px solid #72A545; /* #32CD32; */
  58. }
  59.  
  60. code {
  61. margin: 5px 0;
  62. padding: 10px;
  63. text-align: left;
  64. display: block;
  65. overflow: auto;
  66. font: 500 1em/1.5em 'Lucida Console', 'courier new', monospace;
  67. /* white-space: pre; */
  68. background: #7c7c7c;
  69. border: 1px solid #fa8d00;
  70. }
  71. acronym {
  72. cursor: help;
  73. border-bottom: 1px solid #777;
  74. }
  75. blockquote {
  76. margin: 15px; padding: 0 0 0 20px;
  77. background-color: #7c7c7c;
  78. background-position: 8px 10px;
  79. border: 1px solid #fa8d00;
  80. font: bold 1.2em/1.5em "Trebuchet MS", Tahoma, sans-serif;
  81. color: #fff;
  82. }
  83.  
  84. /* form elements */
  85. form {
  86. margin:10px; padding: 0;
  87. border: 1px solid #fa8d00;
  88. background-color: #b4b4b4;
  89. }
  90. label {
  91. display:block;
  92. font-weight:bold;
  93. margin:5px 0;
  94. }
  95. input {
  96. padding: 2px;
  97. border:1px solid #eee;
  98. font: normal 1em "Trebuchet MS", Tahoma, sans-serif;
  99. color:#777;
  100. }
  101. textarea {
  102. width:400px;
  103. padding:2px;
  104. font: normal 1em "Trebuchet MS", Tahoma, sans-serif;
  105. border:1px solid #fa8d00;
  106. height:100px;
  107. display:block;
  108. color:#fff;
  109. }
  110. input.button {
  111. margin: 0;
  112. font: bold 1em Arial, Sans-serif;
  113. border: 1px solid #fa8d00;
  114. background: #7c7c7c;
  115. padding: 2px 3px;
  116. color: #333;
  117. }
  118.  
  119. /* search form */
  120. .searchform {
  121. background-color: transparent;
  122. border: none; margin: 0; padding: 0;
  123. }
  124. .searchform p { margin: 10px; padding: 0; }
  125. .searchform input.textbox {
  126. width: 130px;
  127. color: #333;
  128. height: 20px;
  129. padding: 2px;
  130. vertical-align: top;
  131. }
  132. .searchform input.button {
  133. font: bold 12px Arial, Sans-serif;
  134. color: #fa8d00;
  135. width: 60px;
  136. height: 26px;
  137. border: none;
  138. padding: 3px 5px;
  139. vertical-align: top;
  140. }
  141.  
  142. /***********************
  143. LAYOUT
  144. ************************/
  145.  
  146. #header-content, #content, #footer-content {
  147. width: 760px;
  148. }
  149.  
  150. /* header */
  151. #header {
  152. height: 100px;
  153. text-align: left;
  154. }
  155. #header-content {
  156. position: relative;
  157. margin: 0 auto; padding: 0;
  158. }
  159. #header-content #logo {
  160. position: absolute;
  161. font: bold 4em 'Trebuchet Ms', Sans-serif;
  162. letter-spacing: -2px;
  163. color: #000;
  164. margin: 0; padding: 0;
  165.  
  166. /* change the values of left and top to adjust the position of the logo */
  167. top: 0; left: 0px;
  168. }
  169. #header-content #slogan {
  170. position: absolute;
  171. font: bold 1.1em 'Trebuchet Ms', Sans-serif;
  172. text-transform: none;
  173. color: #FFF;
  174. margin: 0; padding: 0;
  175.  
  176. /* change the values of left and top to adjust the position of the slogan */
  177. top: 55px; left: 40px;
  178. }
  179.  
  180. /* header menu */
  181. #header-content ul {
  182. position: absolute;
  183. right: -5px; top: 15px;
  184. font: bolder 1.3em 'Trebuchet MS', sans-serif;
  185. color: #FFF;
  186. list-style: none;
  187. margin: 0; padding: 0;
  188. }
  189. #header-content li {
  190. display: inline;
  191. }
  192. #header-content li a {
  193. float: left;
  194. display: block;
  195. padding: 3px 12px;
  196. color: #FFF;
  197. background-color: #333;
  198. text-decoration: none;
  199. border-right: 1px solid #272727;
  200. }
  201. #header-content li a:hover {
  202. background: #65944A;
  203. color: #FFF;
  204. }
  205. #header-content li a#current {
  206. background: #65944A;
  207. color: #FFF;
  208. }
  209.  
  210. /* header photo */
  211. .headerphoto {
  212. margin: 0 auto;
  213. width: 900px;
  214. height: 127px;
  215. padding: 0px 0px 0px 0px;
  216. background: #FFF url(gigaheader.jpg) no-repeat center;
  217. }
  218.  
  219. #overall {
  220. text-align: center;
  221. margin: 0 auto;
  222. padding: 0;
  223. }
  224.  
  225. /* content */
  226. #content-wrap {
  227. clear: both;
  228. float: left;
  229. width: 100%;
  230. }
  231. #content {
  232. text-align: left;
  233. padding: 0;
  234. margin: 0 auto;
  235. }
  236.  
  237. /* sidebar */
  238. #sidebar {
  239. float: right;
  240. width: 30%;
  241. margin: 0 0 10px 0; padding: 0;
  242. }
  243. #sidebar h1 {
  244. padding: 10px 0px 5px 10px;
  245. margin: 0;
  246. }
  247. .sidebox {
  248. background: #7c7c7c;
  249. border: 1px solid #fa8d00;
  250. margin-bottom: 10px;
  251. }
  252.  
  253. /* sidebar menu */
  254. #sidebar ul.sidemenu {
  255. list-style:none;
  256. margin: 10px 0;
  257. padding: 0;
  258. background: #7c7c7c;
  259. }
  260. #sidebar ul.sidemenu li {
  261. padding: 0px 10px;
  262. }
  263. #sidebar ul.sidemenu a {
  264. display:block;
  265. font-weight:normal;
  266. color: #fa8d00;
  267. height: 1.5em;
  268. padding:.3em 0 .3em 15px;
  269. line-height: 1.5em;
  270. border-bottom: 1px dashed #CCC;
  271. text-decoration:none;
  272. }
  273. #sidebar ul.sidemenu a.top{
  274. border-top: 1px dashed #CCC;
  275. }
  276. #sidebar ul.sidemenu a:hover {
  277. padding: .3em 0 .3em 10px;
  278. border-left: 5px solid #fa8d00;
  279. color: #006699;
  280. }
  281.  
  282. /* main */
  283. #main {
  284. float: left;
  285. width: 68%;
  286. margin: 0 0 10px 0; padding: 0;
  287. }
  288. #main h1 {
  289. padding: 10px 0 5px 5px;
  290. margin: 0 0 0 10px;
  291. border-bottom: 1px solid #7c7c7c;
  292. }
  293.  
  294. .post {
  295. margin: 0; padding: 0;
  296. background: #7c7c7c;
  297. border: 1px solid #fa8d00;
  298. }
  299. .post .post-footer {
  300. background-color: #7c7c7c;
  301. border: 1px solid #7c7c7c;
  302. padding: 5px; margin-top: 20px;
  303. font-size: 95%;
  304. }
  305. .post .post-footer .date {
  306. background: url('clock.gif') no-repeat 0 center;
  307. padding-left: 20px; margin: 0 10px 0 5px;
  308. }
  309. .post .post-footer .comments {
  310. background: url('comment.gif') no-repeat 0 center;
  311. padding-left: 20px; margin: 0 10px 0 5px;
  312. }
  313. .post .post-footer .readmore {
  314. background: url('page.gif') no-repeat 0 center;
  315. padding-left: 20px; margin: 0 10px 0 5px;
  316. }
  317.  
  318. /* footer */
  319. #footer {
  320. clear: both;
  321. margin: 0; padding: 0;
  322. font: normal .95em/1.5em 'Trebuchet MS', Tahoma, Arial, sans-serif;
  323. text-align: left;
  324. }
  325. #footer h3, #footer p {
  326. margin-left: 0;
  327. }
  328. #footer-content {
  329. border-top: 1px solid #EAEAEA;
  330. margin: 0 auto;
  331. padding-left: 15px;
  332. }
  333. #footer-content a {
  334. text-decoration: none;
  335. color: #777;
  336. }
  337. #footer-content a:hover {
  338. text-decoration: underline;
  339. color: #333;
  340. }
  341. #footer-content ul {
  342. list-style: none;
  343. margin: 0; padding: 0;
  344. }
  345. #footer-content .col {
  346. width: 32%;
  347. padding: 0 5px 30px 0;
  348. }
  349. #footer-content .col2 {
  350. width: 33%;
  351. padding: 0 0 30px 0;
  352. }
  353.  
  354. /* alignment classes */
  355. .float-left { float: left; }
  356. .float-right { float: right; }
  357. .align-left { text-align: left; }
  358. .align-right { text-align: right; }
  359.  
  360. /* additional classes */
  361. .clear { clear: both; }
  362. .gray { color: #BFBFBF; }
  363.  
  364. /* Navigation tabs*/
  365. /*- Menu Tabs Left--------------------------- */
  366.  
  367. #tabsLeft {
  368. float:left;
  369. width:300;
  370. background:#000000 url(Spacer.jpg) repeat-x;;
  371. font-size:93%;
  372. text-align: center;
  373. line-height:normal;
  374. border-bottom:1px solid #000000;
  375. }
  376. #tabsLeft ul {
  377. margin:0 auto;
  378. padding:0px 0px 0px 80px;
  379. list-style:none;
  380. }
  381. #tabsLeft li {
  382. display:inline;
  383. margin:0 auto;
  384. padding:0;
  385. }
  386. #tabsLeft a {
  387. float:left;
  388. background:url("TabSide.jpg") no-repeat left top;
  389. margin:0 auto;
  390. padding:0 0 0 9px;
  391. text-decoration:none;
  392. }
  393. #tabsLeft a span {
  394. float:left;
  395. display:block;
  396. background:url("TabSide.jpg") no-repeat right top;
  397. padding:5px 15px 0px 6px;
  398. color:#FFF;
  399. }
  400. /* Commented Backslash Hack hides rule from IE5-Mac \*/
  401. #tabsLeft a span {float:none;}
  402. /* End IE5-Mac hack */
  403. #tabsLeft a:hover span {
  404. color:#000;
  405. }
  406. #tabsLeft a:hover {
  407. background-position:0% -22px;
  408. }
  409. #tabsLeft a:hover span {
  410. background-position:100% -22px;
  411. }
  412.  
  413.  
  414. /*- Menu Tabs Left 2--------------------------- */
  415.  
  416. #tabsLeft2 {
  417. float:left;
  418. width:300;
  419. background:#000000 url(Spacer.jpg) repeat-x;;
  420. font-size:93%;
  421. text-align: center;
  422. line-height:normal;
  423. border-bottom:1px solid #000000;
  424. }
  425. #tabsLeft2 ul {
  426. margin:0 auto;
  427. padding:0px 0px 0px 0px;
  428. list-style:none;
  429. }
  430. #tabsLeft2 li {
  431. display:inline;
  432. margin:0 auto;
  433. padding:0;
  434. }
  435. #tabsLeft2 a {
  436. float:left;
  437. background:url("TabSpan.jpg") no-repeat left top;
  438. margin:0 auto;
  439. padding:0 0 0 9px;
  440. text-decoration:none;
  441. }
  442. #tabsLeft2 a span {
  443. float:left;
  444. display:block;
  445. background:url("TabSpan.jpg") no-repeat right top;
  446. padding:5px 15px 0px 6px;
  447. color:#FFF;
  448. }
  449. /* Commented Backslash Hack hides rule from IE5-Mac \*/
  450. #tabsLeft2 a span {float:none;}
  451. /* End IE5-Mac hack */
  452. #tabsLeft2 a:hover span {
  453. color:#000;
  454. }
  455. #tabsLeft2 a:hover {
  456. background-position:0% -22px;
  457. }
  458. #tabsLeft2 a:hover span {
  459. background-position:100% -22px;
  460. }
  461.  
  462. /*- Menu Tabs Center--------------------------- */
  463.  
  464. #tabsCenter {
  465. float:left;
  466. width:300;
  467. background:#000000 url(Spacer.jpg) repeat-x;;
  468. font-size:93%;
  469. text-align: center;
  470. line-height:normal;
  471. border-bottom:1px solid #000000;
  472. }
  473. #tabsCenter ul {
  474. margin:0 auto;
  475. padding:0px 0px 0px 80px;
  476. list-style:none;
  477. }
  478. #tabsCenter li {
  479. display:inline;
  480. margin:0 auto;
  481. padding:0;
  482. }
  483. #tabsCenter a {
  484. float:left;
  485. background:url("TabSide.jpg") no-repeat left top;
  486. margin:0 auto;
  487. padding:0 0 0 9px;
  488. text-decoration:none;
  489. }
  490. #tabsCenter a span {
  491. float:left;
  492. display:block;
  493. background:url("TabSide.jpg") no-repeat right top;
  494. padding:5px 15px 0px 6px;
  495. color:#FFF;
  496. }
  497. /* Commented Backslash Hack hides rule from IE5-Mac \*/
  498. #tabsCenter a span {float:none;}
  499. /* End IE5-Mac hack */
  500. #tabsCenter a:hover span {
  501. color:#000;
  502. }
  503. #tabsCenter a:hover {
  504. background-position:0% -22px;
  505. }
  506. #tabsCenter a:hover span {
  507. background-position:100% -22px;
  508. }
  509.  
  510.  
  511. /*- Menu Tabs Center 2--------------------------- */
  512.  
  513. #tabsCenter2 {
  514. float:left;
  515. width:300;
  516. background:#000000 url(Spacer.jpg) repeat-x;;
  517. font-size:93%;
  518. text-align: center;
  519. line-height:normal;
  520. border-bottom:1px solid #000000;
  521. }
  522. #tabsCenter2 ul {
  523. margin:0 auto;
  524. padding:0px 80px 0px 0px;
  525. list-style:none;
  526. }
  527. #tabsCenter2 li {
  528. display:inline;
  529. margin:0 auto;
  530. padding:0;
  531. }
  532. #tabsCenter2 a {
  533. float:left;
  534. background:url("TabSpan.jpg") no-repeat left top;
  535. margin:0 auto;
  536. padding:0 0 0 9px;
  537. text-decoration:none;
  538. }
  539. #tabsCenter2 a span {
  540. float:left;
  541. display:block;
  542. background:url("TabSpan.jpg") no-repeat right top;
  543. padding:5px 15px 0px 6px;
  544. color:#FFF;
  545. }
  546. /* Commented Backslash Hack hides rule from IE5-Mac \*/
  547. #tabsCenter2 a span {float:none;}
  548. /* End IE5-Mac hack */
  549. #tabsCenter2 a:hover span {
  550. color:#000;
  551. }
  552. #tabsCenter2 a:hover {
  553. background-position:0% -22px;
  554. }
  555. #tabsCenter2 a:hover span {
  556. background-position:100% -22px;
  557. }
  558.  
  559.  
  560. /*- Menu Tabs Right--------------------------- */
  561.  
  562. #tabsRight {
  563. float:left;
  564. width:300;
  565. background:#000000 url(Spacer.jpg) repeat-x;;
  566. font-size:93%;
  567. text-align: center;
  568. line-height:normal;
  569. border-bottom:1px solid #000000;
  570. }
  571. #tabsRight ul {
  572. margin:0 auto;
  573. padding:0px 0px 0px 80px;
  574. list-style:none;
  575. }
  576. #tabsRight li {
  577. display:inline;
  578. margin:0 auto;
  579. padding:0;
  580. }
  581. #tabsRight a {
  582. float:left;
  583. background:url("TabSide.jpg") no-repeat left top;
  584. margin:0 auto;
  585. padding:0 0 0 9px;
  586. text-decoration:none;
  587. }
  588. #tabsRight a span {
  589. float:left;
  590. display:block;
  591. background:url("TabSide.jpg") no-repeat right top;
  592. padding:5px 15px 0px 6px;
  593. color:#FFF;
  594. }
  595. /* Commented Backslash Hack hides rule from IE5-Mac \*/
  596. #tabsRight a span {float:none;}
  597. /* End IE5-Mac hack */
  598. #tabsRight a:hover span {
  599. color:#000;
  600. }
  601. #tabsRight a:hover {
  602. background-position:0% -22px;
  603. }
  604. #tabsRight a:hover span {
  605. background-position:100% -22px;
  606. }
  607.  
  608.  
  609. /*- Menu Tabs Right2--------------------------- */
  610.  
  611. #tabsRight2 {
  612. float:left;
  613. width:300;
  614. background:#000000 url(Spacer.jpg) repeat-x;;
  615. font-size:93%;
  616. text-align: center;
  617. line-height:normal;
  618. border-bottom:1px solid #000000;
  619. }
  620. #tabsRight2 ul {
  621. margin:0 auto;
  622. padding:0px 120px 0px 0px;
  623. list-style:none;
  624. }
  625. #tabsRight2 li {
  626. display:inline;
  627. margin:0 auto;
  628. padding:0;
  629. }
  630. #tabsRight2 a {
  631. float:left;
  632. background:url("TabSpan.jpg") no-repeat left top;
  633. margin:0 auto;
  634. padding:0 0 0 9px;
  635. text-decoration:none;
  636. }
  637. #tabsRight2 a span {
  638. float:left;
  639. display:block;
  640. background:url("TabSpan.jpg") no-repeat right top;
  641. padding:5px 15px 0px 6px;
  642. color:#FFF;
  643. }
  644. /* Commented Backslash Hack hides rule from IE5-Mac \*/
  645. #tabsRight2 a span {float:none;}
  646. /* End IE5-Mac hack */
  647. #tabsRight2 a:hover span {
  648. color:#000;
  649. }
  650. #tabsRight2 a:hover {
  651. background-position:0% -22px;
  652. }
  653. #tabsRight2 a:hover span {
  654. background-position:100% -22px;
  655. }


HTML Code -> index.html
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4.  
  5. <meta name="Description" content="Information architecture, Web Design, Web Standards." />
  6.  
  7. <meta name="Keywords" content="your, keywords" />
  8.  
  9. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  10.  
  11. <meta name="Distribution" content="Global" />
  12.  
  13. <meta name="Author" content="Erwin Aligam - ealigam@gmail.com" />
  14.  
  15. <meta name="Robots" content="index,follow" />
  16.  
  17. <link rel="stylesheet" href="images/Style.css" type="text/css" />
  18. <title>Blank</title>
  19.  
  20.  
  21. </head>
  22.  
  23.  
  24.  
  25.  
  26. <body>
  27.  
  28. <!-- wrap starts here -->
  29. <div class="headerphoto"></div>
  30. <div id="tabsLeft">
  31. <ul>
  32. <li><a href="index.html#" title="Home"><span>Home</span></a></li>
  33. <li><a href="index.html#" title="Forun"><span>Forum</span></a></li>
  34. <li><a href="index.html#" title="News"><span>News</span></a></li>
  35. </ul>
  36. </div>
  37.  
  38. <div id="tabsLeft2">
  39. <ul>
  40. <li><a href="index.html#" title="Blogs"><span>Blogs</span></a></li>
  41. </ul>
  42. </div>
  43.  
  44. <div id="tabsCenter">
  45. <ul>
  46. <li><a href="index.html#" title="Sign In"><span>Sign In</span></a></li>
  47. </ul>
  48. </div>
  49.  
  50. <div id="tabsCenter2">
  51. <ul>
  52. <li><a href="index.html#" title="Register"><span>Register</span></a></li>
  53. </ul>
  54. </div>
  55.  
  56. <div id="tabsRight">
  57. <ul>
  58. <li><a href="index.html#" title="Contact Us"><span>Contact Us</span></a></li>
  59. </ul>
  60. </div>
  61. <div id="tabsRight2">
  62. <ul>
  63. <li><a href="index.html#" title="Help"><span>Help</span></a></li>
  64. </ul>
  65. </div>
  66. <div id="wrap">
  67.  
  68.  
  69. <!-- content-wrap starts here -->
  70. <div id="content-wrap">
  71. <div id="content">
  72. <div id="sidebar">
  73. <div class="sidebox">
  74. <h1>Short About</h1>
  75.  
  76. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  77. Donec libero. Suspendisse bibendum. Cras id urna. Morbi tincidunt, orci
  78. ac convallis aliquam, lectus turpis varius lorem, eu posuere nunc justo
  79. tempus leo.</p>
  80.  
  81. </div>
  82.  
  83. <div class="sidebox">
  84. <h1 class="clear">Sidebar Menu</h1>
  85.  
  86. <ul class="sidemenu">
  87.  
  88. <li><a href="index.html" class="top">Home</a></li>
  89.  
  90. <li><a href="#TemplateInfo">Template Info</a></li>
  91.  
  92. <li><a href="#SampleTags">Sample Tags</a></li>
  93.  
  94. <li><a href="http://www.styleshout.com/">More
  95. Templates...</a></li>
  96.  
  97. <li><a href="http://www.4templates.com/?aff=ealigam"