December 12, 201213 yr I'm trying to use this navbar on another site I'm building but when I reduce (control - ) the page view in my browser/s, the last box is displaced and pushes under the nav bar. Is there a reason why this is happening and can I do something with the code to prevent it? This is a template site I was given at college, so none of it is my own work. I know it doesn't look pretty. http://www.basicandnasty.tk Thanks
December 12, 201213 yr Author Thanks kree8or. I've played around with the width. Reducing it to 153px meant it stayed in line regardless of how much I zoomed out. The only downside is there are a few spare pixels sticking out on the far right of the bar. Is there any way I could centre the buttons in the bar to balance it out? I've tried 'float' but only float left is any good. Anything else and they stack one below the other. Update: http://www.basicandnasty.tk/ Cheers Edited December 12, 201213 yr by Bowman
December 13, 201213 yr Author Hi Oheyam, I've put padding-left: 1px; into the elements, which does take the boxes out but then the old problem returns; when I do maximum zoom out, the end box is dropped below the nav bar. Is this something I'll have to live with? Updated: http://www.basicandnasty.tk/ Cheers
December 13, 201213 yr is it going to be a fixed site or will the menu be generated dynamically with a CMS (eg wordpress)? If its just a static site then adding the following code to your nav div should do the trick: margin-left:auto; margin-right:auto;
December 13, 201213 yr If you use percentages as the width you should be ok. Bear in mind that means you can't use a single fixed pixel value on the same plane as the percentages. Unrelated: +1 for Robin of Sherwood.
December 13, 201213 yr Author is it going to be a fixed site or will the menu be generated dynamically with a CMS (eg wordpress)? If its just a static site then adding the following code to your nav div should do the trick: margin-left:auto; margin-right:auto; Hi kree8or, Thanks for the code. I popped into place in the CSS file but I may have missed something as it seems to have made no difference??? Still got spare pixels at the end and wrap round when I zoom out... http://www.basicandnasty.tk/ cheers Edited December 13, 201213 yr by Bowman
December 13, 201213 yr Author If you use percentages as the width you should be ok. Bear in mind that means you can't use a single fixed pixel value on the same plane as the percentages. Unrelated: +1 for Robin of Sherwood. Sounds promising Renaissance-Design. The navbar elements currently sit in a panel which is 800px wide and 20px deep. Their specified size is (each) 153px wide 16px deep. How could I translate that to percentages and keep it looking the same? I've also got a fixed layout, header & footer. Re + 1 - the only Robin IMHO, especially with Clannad providing the backing track. Edited December 13, 201213 yr by Bowman
December 14, 201213 yr I suppose you could set the containing div to 100%, then as you have 5 nav elements, you could set each one to 20%? So your code would be: .navbar { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #6699FF; display: block; height: 20px; width: 100%; background-color: #333333; text-align: center; vertical-align: bottom; } .navbar a { color: #6699FF; text-decoration: none; display: block; width: 20%; clear: right; height: 16px; float: left; margin-left:auto; margin-right:auto; text-align: center; vertical-align: middle; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #666666; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #666666; background: #1e5799; /* Old browsers */ /* IE9 SVG, needs conditional override of 'filter' to 'none' */ background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzFlNTc5OSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iIzI5ODlkOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iIzIwN2NjYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3ZGI5ZTgiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background: -moz-linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* IE10+ */ background: linear-gradient(to bottom, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-8 */ } This also does away with using the image as a background to your buttons. Hope this helps! Edited December 14, 201213 yr by kree8or
December 14, 201213 yr Author Thanks for the code kree8or. I've put it in place but for some reason the last box now drops below the navbar at all magnifications. To try and resolve it I made the a hover/visited etc 20% instead of 153px, as you mentioned. I also removed the margin and padding (1px each) to see if that would help but it didn't. Perhaps I've missed something? http://www.basicandnasty.tk/ Thanks
December 14, 201213 yr Author Thanks kree8or. I've got as close as can get with: width: 19.7%; padding: .5px; There's no wrap under at any size, which is nice, but there's still a few niggling pixels left spare on the far right of the bar... As I'm a perfectionist, I'd prefer not to have them there. It does seem as if there needs to be some spare pixels in order for it not to wrap at lower magnifications. Will tampering with the navbar box itself help? http://www.basicandnasty.tk/ Cheers Edited December 14, 201213 yr by Bowman
December 14, 201213 yr Still wraps for me; I don't think you're not taking the borders on each link into consideration.
December 14, 201213 yr Author Thanks heyden. I'll delve into that when I get a minute and let you know how I get on.
Create an account or sign in to comment