I have created a simple navigation bar using html and css. The issue with it is when zoomed in, the structure changes as not all the links can fit in one line. Here is the jsfiddle: http://jsfiddle.net/HamishT/b3Lw4/
Here is the code in case you are unable to access jsfiddle:
<div id="navBar">
<ul>
<li class="nav">HOME</li>
<li class="nav">PRODUCTS</li>
<li class="nav">SERVICES</li>
<li class="nav">CONTACT US</li>
<li class="nav" id="order">ORDER</li>
</ul>
</div>
#navBar {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color:#5a5a5a;
font-size:12px;
font-weight:bold;
background-color:#eeeeee;
padding:0.1em;
box-shadow: 5px 5px 5px #888888;
}
.nav {
list-style:none;
display:inline;
border-left:3px solid;
}
.nav a {
text-decoration:none;
color:inherit;
padding: 0 20px 5px 20px;
}
.nav a:hover{
border-bottom:3px solid;
}
#order {
float:right;
color:#E65C00;
}
I have tried various ways, none to any success. One way I am wondering about is if I can edit it so that it will flow off the page if it doesn't fit (so only part of the width of the navbar is seen at one time), but I can't seem to work my head around it. Another way I think would be to detect the screen width/zoom and change the structure completely if the available space is too small, but I am unsure if this is possible (I've looked into it, but have not found any that seem to work the way I've described.
Just in case it helps: one thing I have spotted is the floats may be preventing me from being able to fix this.
Are there any ways to fix this and if so, how? I don't mind how it works (eg. flows off the screen or zooms the whole navbar out) so long as it does work. I've been stuck on this for three days now (I'm still new to it all) so any help whatsoever would be greatly appreciated.
The problem is caused because float is considering a 100% width for the navbar. Add a width in pixels to fix the size of the navbar, like this
#navBar {
width: 550px;
}
Although this will cause elements to flow out of current window (and hence bringing the scrollbar). Your best bet in such a case is make stuff responsive and create different styles for different widths.
When you zoom into the page, the size of the viewport is decreasing.
That means you can use media queries to create proper breakpoints:
#media screen and (max-width:600px) {
#navBar {
font-size:5px;
}
}
The 600px mark works well in my test case. But you can't reproduce it via jsfiddle. 5px aren't too small since you're zoomed in. The best approach however would be using em values instead of px since they allow to change the reference font-size: body { font-size:0.9em; }. This will be inherited by any other element.
I have found a solution (it may not be of use to everyone who sees this, but is one alternative solution to the issue). I put the li element that floats right in a separate div so that when zoomed in it will not drop below the others or overlap. Instead the other li elements will drop down before they overlap, whilst still working properly.
From the HTML, the #order element (float right) is in a div before the other li elements put into a new div.
<div id="navBar">
<div>
<ul>
<li class="nav" id="order">ORDER</li>
</ul>
</div>
<div>
<ul>
<li class="nav">HOME</li>
<li class="nav">PRODUCTS</li>
<li class="nav">SERVICES</li>
<li class="nav">CONTACT US</li>
</ul>
</div>
</div>
Here's a working jsfiddle to show what I mean: http://jsfiddle.net/HamishT/3pd5Z/#base
Related
I've almost got my website finished but am growing incredibly frustrated and not being able to get the vertical-align to work. Everywhere else, my content is where it should be, but for reasons unknown, these lists are appearing in the middle... meaning when the iframe is set to the desired size, my lists move to the middle of their td?
I've tried adding the vertical align option to the css of the links, created a div option for the entire area, adding it html etc, no luck anywhere? What am I doing wrong? :(
A.class2 {text-decoration: none; text-transform: uppercase; font-weight: bold; text-align: left; font-size: 16px;}
A.class2:link, A.class2:visited {color: #0fa616;}
A.class2:hover, A.class2:active {color: #0fa616;}
#sub li {list-style-type: square;}
Please bear in mind that I have a main ul menu above that I do not want affected in any code anyone manages to fix for me.
<center><h2>Amber w/Inclusions</h2></center><ul id="sub">
<li>Baltic</li>
<li>Copal</li>
</ul>
<center><h2>Dinosaurs/Reptiles</h2></center>
<ul id="sub">
<li>Pterosaur</li>
<li>Raptor</li>
<li>Spinosaurus</li>
</ul>
<center><h2>Trilobites</h2></center>
<ul id="sub">
<li>Cambrian age</li>
<li>Devonian age</li>
<li>Ordovician age</li>
</ul>
You can see what I mean on the page http://www.dinodeals.co.uk/fossils.html
The table itself is only for aid during design, it won't be visible on the complete design. I would love a little divider also, say a green line to the right of the entire sub category menu I'm trying to set to the top. But had no luck implimenting that either after reading up how. I'm not sure the border-right css is usable anymore?
you can try this, I just inspected the page and found you are running some type of padding on your td element (most likely caused by it aligning to the middle).
Try this little snippet:
td{
padding-top: 0px;
vertical-align: top;
}
This aligned the table to the top on my screen.
EDIT:
As per your request for border on the right of it (I didn't see that far into the question).
td{
vertical-align: top;
border-right: 3px solid rgb(15, 166, 22);
padding: 10px 0;
}
I have been attempting to make my menu responsive. www.treytrumble.com
It seems that because it is fixed, it will not scale properly when viewed on a device smaller than a laptop. What can I do to make the menu appear like this one when the screen is scaled to smaller than 1,150px wide? http://www.adtile.me
HTML
<div class="contactcontainer">
<div class="contactmenu">Trey Trumble<br /><br/>804-513-7704 <br/><br/>
trey#treytrumble.com<br/><br/>Resume
</div><!-- end .contactmenu -->
</div><!-- end .contactcontainer -->
<div class="container">
<div class="sidebar1">
<table width="120" height="104" border="0">
<tr>
<th scope="col"></th>
</tr>
</table>
<ul class="nav">
<li><img src="images/logo.jpg" width="180"/></li>
<li><a id="webbutton" class="nav">WEB DESIGN</a></li>
<li><a id="printbutton" class="nav">PRINT DESIGN</a></li>
<li><a span class="contactbutton">CONTACT & RESUME</span></a></li></ul>
</div><!-- end .sidebar1 -->
CSS
.content ul, .content ol {
padding: 0 15px 15px 40px;
}
ul.nav {
list-style: none;
border-top: 1px solid #666;
margin-bottom: 15px;
position:fixed;
}
ul.nav li {
border-bottom: 1px solid #666;
letter-spacing: 2px;
font-family: "Helvetica", Arial, sans-serif;
cursor: pointer;
}
ul.nav a, ul.nav a:visited {
padding: 5px 5px 5px 15px;
display: block;
width: 160px;
text-decoration: none;
background: #fff;
inline-box-align:initial;
color:#F60;
}
ul.nav a:hover, ul.nav a:active, ul.nav a:focus {
background:#F60;
color: #FFF;
font-family: "Helvetica", Arial, sans-serif;
letter-spacing: 2px;
font-size: 9px;
}
This is quite simple to accomplish, but it's quite a bit hard to explain. You have to use media queries to accomplish this, maybe even JavaScript.
Media Queries
Chris Coyier has a very interesting article in CSS-TRICKS that explains various concepts of responsive menus here: http://css-tricks.com/responsive-menu-concepts/
As for the main question, you can definitely make that menu responsive, though, I wouldn't suggest you put the exact same layout you have for desktop for mobile, because that would be a problem since the screen is too small, I would suggest making it go all the way to the top like a normal menu, being responsive, you can also fix it to the top and adding a padding-top to the remaining elements so that they don't go below the menu.
If you decide that the menu should be always on top, make sure you add a z-index property to the nav or div element so that no other goes across it too.
FlexBox
There is another approach you can take as well, but depending on what support you're giving to certain browsers I would suggest or not using Flexbox. If you display your navigation as display: flex and you tweak it CSS wise, you can achieve beautiful combinations, but again, remember this is a slightly new CSS3 property, and mainly Internet Explorer has just recently began supporting it.
More about Flexbox can be found here: http://css-tricks.com/snippets/css/a-guide-to-flexbox/
Responsive Design
If you're new to responsive/adaptive design, then sir you have a lot of work to do, but, luckily for you, there are today tons of free and/or paid resources that will give you a pretty good idea of what to do.
I found this article on Team Tree House very useful: http://blog.teamtreehouse.com/beginners-guide-to-responsive-web-design
You can go on from there and start looking for other resources, some of them mentioned on this answer:
Media Queries
Flexbox
Other Tips
If you want to make your menu responsive, you also need to make your site responsive, make sure you have all these:
Responsive viewport tag
HTML5 doctype
A plan (grid system, media queries, flexbox, etc)
Fallbacks for unsupported content
Of course yes,
use media queries to choose the resolution you want it to snap to.
Define your classes within the query and apply it around the menu.
I have read a lot of answers regarding this but it does not solve my problem. On the main page when I scrolled to the bottom, the footer has an extra space but it seems like the extra space below it is the background of my page. In other pages, the footer is okay. I think this happened because my main page has a short content. I actually cheated on its sidebar by adding margin bottom. Any help which applies to all browsers and any screen sizes that will fix this? Thanks!
This is the CSS of my footer:
#footerArea{
height:108px;
width:100%;
z-index:5;
background:url('../images/footerArea.jpg') #404042;
}
#footerPart{
height:48px;
width:988px;
margin:0 auto;
padding:0px;
background:url('../images/footerbg.jpg') no-repeat #404042;
}
#footerPart a {
text-decoration:none;
}
#footerLink{
margin:0 auto;
padding:15px 0px 0px 0px;
width:960px;
}
#footerLink ul{
list-style-type:none;
float:left;
}
#footerLink ul li{
display:inline;
margin:0px 5px 0px 0px;
}
#footerLink ul li a{
background:url('../images/footerbtn.jpg') no-repeat;
font-size:10px;
text-decoration:none;
padding:0px 0px 0px 15px;
}
EDITED:
This is from footer.php
<div id="footerArea">
<div id="footerPart">
<div id="footerLink">
<ul>
<li>xxx</li>
<li> | </li>
<li><li>yyyy</li>
<li> | </li>
<li>zzzzz</li>
<li> | </li>
<li>aaaaaa</li>
</ul>
<p class="fR">SOME TEXT ggggg</p>
</div>
</div>
</div>
</body>
</html>
I have tested it in Chrome, Firefox and IE but it has the same output.
Check if you have some kind of web tracking code or any other javascript (in javascript tags) at end of your document. Though it must be a few lines of javascript code, it sometimes takes-up space beneath footer in some browsers, especially in IE. If you can provide a codepen reference, we can review
In your HTML you have a <li> tag embedded within another <li> which is invalidating your code, as it doesn't have a closing tag.
Short of that, it's hard to debug such a vague problem as "Has extra space". To provide further insight it would be great if you could provide a jsfiddle or something similar.
If you can't provide that or don't know how, I can offer some debugging tips. If you're using google chrome to debug, you can go into your webkit inspector, or firebug if using firefox (Right click, "inspect element") and look at the CSS and boxing for paticular elements.
If that fails and you still can't figure out what's causing the extra space, you can right click elements and begin deleting the ones that you think may be the root of the problem. Once an element is deleted it will no longer appear in your browser, so if you delete one and the problem persists, you can be comfortable knowing it wasn't that element (or is multiple elements, but lets not get that complex.)
I have a list that resembles:
<ol>
<li class="node">1</li>
<li class="node">2</li>
<li class="node">3</li>
<li class="node">4</li>
<li class="node_end">5</li>
</ol>
I am using images to replace their default bullet points in CSS. Separate images are used for the end node as well as another image for all other bullet points. The images display, however as soon as I add these images a 4 pixel padding is somehow added to the top and bottom of each list item. This extra spacing changes the height from 26 pixels high to 34 pixels high. This gap provides about an 8 pixel separation between the different bullet point images which were meant to have a 0px separation as per my design.
The CSS I made:
li {
margin: 0;
padding: 0;
border: 0;
}
li.node {
list-style-image: url('../imgs/nodes/udr.png');
}
li.node_end {
list-style-image: url('../imgs/nodes/ur.png');
}
Is there any way to remove this spacing? I have tried removing all things padding/spacing/border related to all li's, but nothing so far.
EDIT:
I do not think I am making my question clear enough, so I am posting the image of what it looks like on my end.
The joining bars as you see in the image above are supposed to be connected (as if one continuous image). Removing the special CSS images for bullet points reduces the height of each item to the height of the CSS bullet point image (as I have tested using Google Chrome's element inspecting tool).
EDIT 2:
A close example to show my problem can be found here: http://jsfiddle.net/EyVRF/1/
Garry Cairns might be onto something. I tested your code and borrowed a list style image from a website that was a good size and i see no padding that would be an issue, or at least not the type you're seeing.
http://jsfiddle.net/BYQQV/
list-style-image: url('http://www.globalindustrial.com/site/img/bullet_homecat.gif');
You may also want to consider not having to create a whole new class for the last list item. Try instead
li:last-child { list-style-image:.... }
Althouth IE is not happy with that. But for future reference.
lack of .css and html unable me to answer you.
About : Is there any way to remove this spacing? YES there is.
try this :
ol, li{list-style-position:outside;margin:0;padding:0}
or
ol, li{list-style-position:inside;margin:0;padding:0}
Let me guess ? You didn't reset your .css ?? (margin:0;padding:0)
Ok, i can see what you want .. and sadly, you wont be able to achieve what you want this way becose the 'padding in between the bullet and first character is 'browser-specific' and unmanagable through css.
You will have to use another technique : background image.
<ul>
<li class="node">1</li>
<li class="node">2</li>
<li class="node">3</li>
<li class="node">4</li>
<li class="node_end">5</li>
</ul>
ul, li {
margin: 0;
padding: 0;
}
li {
font-size:16px;
line-height:16px;
list-style-type:none;
background:red url('http://placehold.it/16x16') no-repeat scroll 0 0;
padding-left:16px;
border-bottom:1px solid blue;
}
li.node_end {
background:blue url('http://placehold.it/16x16') no-repeat scroll 0 0;
}
http://jsfiddle.net/2RtB7/1/
Carry on
PS, try to search a little more before asking for help --> CSS: Control space between bullet and <li>
I'm building out this landing page and after the second paragraph I have a list of points to which I have applied a list-style-image to the li.actionItem, however I'm getting the default disc instead of my images. I know the url is working because a) I wrote it in absolute form, b) if you enter that absolute url you get the image (see here) and c) I tried applying the icon instead as a background image with some padding for the text and that works.
I can just do that in the end if I have to (the background image with padding version) but I would prefer to write it as a list-style-image. Plus it's just driving me crazy why it won't show up that way and I'd like to know.
Any thoughts or tips?? Thank you!
Here's the relevant markup at a glance...
<ul id="introPoints">
<li class="actionItem">performed more than <strong>500</strong> surgeries</li>
<li class="actionItem">set more than <strong>3,000</strong> fractured bones</li>
<li class="actionItem">mobilized more than <strong>90</strong> volunteers to Haiti</li>
<li class="actionItem">sent pastors from our DR hospital to minister to the victims</li>
</ul>
ul#introPoints {
list-style-image:url (http://blog.helpcurenow.org/images/campaigns/jan2010/haiticrisis/arrow-green-distress.gif);
list-style-type:disc;
}
li.actionItem {
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
color:#6e5e4c;
font-size:14px;
text-align:justify;
width:580px;
font-style:italic;
margin:10px 0px 10px 20px;
text-indent:15px;
}
li.actionItem strong {
color:#dd7439;
}
Try using a background image. list-style-image never lines up properly anyway.
background-image:url(...);
background-repeat:no-repeat;
background-position:0px 0px
This may or may not be the problem, but according to the css grammar you can't have a space between the url and the left parenthesis..
So do this:
url(/someurl)
Not this:
url (/someurl)