Nav bar & content moving around after attempting to add drop down menu - html

I've started to add a drop down menu to my 2nd nav bar (the one in blue) but before I've really got started the main links are moving around and the content in separate divs underneath are also moving around but I've no idea why?
Here's a jsfiddle link http://jsfiddle.net/zDGHg/
I'm new to html and css so any help would be much appreciated.
Related code
HTML
<!--BOTTOM NAVIGATION BAR-->
<div id="botnavbar">
<nav id="botnavlinks">
<ul>
<li>Travel Boards</li>
<li>Destinations
<ul>
<li>sdfgsdfd</li>
<li>sdfgsdfd</li>
<li>sdfgsdfd</li>
<li>sdfgsdfd</li>
</ul>
</li>
<li>Activities</li>
<li>Thingstodo</li>
<li>Accomodation</li>
<li>Transport</li>
</ul>
</nav>
</div>
<!--CONTENT---->
<div id="content">
<div id="slidemenus">
<h1>Filter By</h1>
<!--Put content here-->
<ol>
<li>Price per Trip</li>
<li>Duration</li>
<li>Departure Date</li>
<li>Travel Styles</li>
<li>Activities</li>
<li>City</li>
<li>Country</li>
</ol>
</div>
<div id="featured">FEATURED CONTENT
<!--Put content here-->
<ol>
<li>product info</li>
</ol>
</div>
</div>
CSS
#botnavbar{
height:40px;
background: -webkit-linear-gradient(#6880af, #314a79); /* For Safari */
background: -o-linear-gradient(#6880af, #314a79); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#6880af, #314a79); /* For Firefox 3.6 to 15 */
background: linear-gradient(#6880af, #314a79); /* Standard syntax (must be last) */
}
#botnavlinks{
min-width:960px;
margin: 0 auto;
text-align:left;
padding-left:200px;
}
#botnavlinks ul{
list-style:none;
height:35px;
}
#botnavlinks li{
height:35px;
float:left;
padding-right: 60px;
}
#botnavlinks li a:link, a:visited{
display:block;
color:#fff;
font-family:Papyrus;
padding:8px;
text-decoration:none;
text-shadow:0 -1px 1px rgba(0,0,0,0.5); /*For embossed effect*/
text-align:center;
}
#botnavlinks li a:hover{
background-color:#1d3564;
}
#content{
height:500px;
background-color:#fff;
}
#slidemenus{
border:solid black 1px;
width:30%;
min-height:500px;
float:left;
}
#featured{
border:solid black 1px;
width:60%;
min-height:500px;
float:left;
}

In your jsfiddle, check the width of your #botnavlinks ul declaration... it's set to 150px. If you set it to a wider width or auto, then your links should look as they should.
Also, when you define something to 0 (e.g. margin: 0px), you don't need to specify the units; this will suffice: margin: 0;
Hope that helps.
Edit:
Also, I forgot to mention that other things affecting your menu bar is the padding left you have for your list items (200px); since you have a 'min-width: 960px' defined in your #botnavlinks declaration, and 6 list items (6 x 200 = 1200px wide), the elements will naturally wrap. ;)

Related

Background transparent image is making text ugly and hard to read - CSS

Using background cover image with some transparency making my top navigation menu links text ugly and harder to read. How can I make it correct?
HTML -
<div id="wrapper"> <!-- wrapper starts here -->
<div id="header"> <!-- header starts here -->
<h1>example.com</h1>
</div> <!-- header ends here -->
<div id="top_nav"> <!-- nav starts here -->
<ul>
<li>Menu 1</li>
<li>Menu 2</li>
<li>Menu 3</li>
<li>Menu 4</li>
<li>Menu 5</li>
</ul>
<div class="clr"></div>
</div> <!-- nav ends here -->
<div style="height:1000px;"></div>
</div>
CSS -
html
{
background:url(http://www.designmyprofile.com/images/graphics/backgrounds/background0172.jpg) no-repeat center center fixed;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
#wrapper
{
width:980px;
margin:0 auto;
background-color:#FFFFFF;
background-color:rgba(255, 255, 255, 0.7);
}
#top_nav
{
width:100%;
background-color:#3079ED;
position:relative;
}
#top_nav ul
{
margin:0;
padding:0;
list-style-type:none;
}
#top_nav ul li
{
float:left;
}
#top_nav ul li a
{
background-color:#3079ED;
display:block;
text-align:center;
text-decoration:none;
padding:8px 16px;
color:#FFFFFF;
font-size:14px;
border-right:1px solid #6199DF;
}
#top_nav ul li:last-child a
{
border-right:none;
}
#top_nav ul li a:hover
{
background-color:#6199DF;
}
So please tell me how can I make my menu link text clean and more readable as regular text while keeping the background image transparency.
Here is DEMO
Read back again and see your main problems are how you chose to do the background, and that the bar doesn't extend across as the CSS says it should. Try to make these modifications.
In #topnav {}
Below
width: 100%;
add
height: 32px;
The height being 0px is causing the short menu bar error. Also you can remove
position:relative;
It is assumed in this case already.
I would also change the background of wrapper from
background-color:rgba(255, 255, 255, 0.7);
to
background-color:rgba(75, 75, 75, 0.45);
and add
h1
{
color: #fff;
text-shadow: 2px 2px #000;
}
This tends to do better on backgrounds comprised at least half of darker tones.
Should fix your short nav bar problem and make everything easier to read. As well as show off your background better.
DEMO

CSS "absolutely" positioned border-image

I have a CSS design problem for a day and a halve now and it is driving me nuts. I have an horizontal navigation bar with a single unordered list inside. Each list item contains an anchor (or hyperlink) to a page within the website, the CSS is as follows:
nav#main{
background:#000;
width:100%;
overflow:auto;
}
nav#main ul{
list-style:none;
}
nav#main li{
float:left;
display: block;
overflow:auto;
}
nav#main a{
display:block;
padding:1em;
color:#FFF;
text-transform:uppercase;
font-size:1.6em;
}
nav#main a:hover{
background:#EF7E05;
background-clip:padding-box;
border-width:0 0 15px 0;
border-image:
url('../images/nav.png')
0
0
25
stretch;
}
And the HTML:
<nav id="main">
<ul>
<li>Link text</li>
<li>Link text</li>
<li>Link text</li>
</ul>
</nav>
<div id="contentArea">
<!-- DIFFERENT DIVS, COLUMS ARTICLES ETC. -->
</div>
This works all like it should work.
However what i am trying to accomplish is that the border image is displayed outside the nav bar and that it doesn't push the contentArea downwards a 25px. Any ideas?
I also tried to absolute position a block with a.hover::after. This works beautifully, however the width of the block cannot be set equal to a. Perhaps any ideas on this one too?
You need to clear your floated elements using a clear rather than overflow:visible
If you do this you can use your absolute positioning to create the border:
nav#main{
background:#000;
width:100%;
}
nav#main:after {
content:'';
display:block;
clear:both;
}
nav#main ul{
list-style:none;
}
nav#main li{
float:left;
display: block;
overflow:visible;
}
nav#main a{
display:block;
padding:1em;
color:#FFF;
text-transform:uppercase;
font-size:1.6em;
position:relative;
overflow:visible;
}
nav#main a:hover{
background:#EF7E05;
}
nav#main a:hover:after{
background-clip:padding-box;
content:'';
position:absolute;
top:100%;
left:0;
right:0;
border-width:0 0 15px 0;
border-image:
url('../images/nav.png')
0
0
25
stretch;
}
Example
I have noticed that the border image thing doesn't work in firefox or ie so this will give you the same effect and is more browser friendly:
nav#main a:hover:after{
background-clip:padding-box;
content:'';
position:absolute;
top:100%;
left:0;
right:0;
height:15px;
background: url('../images/nav.png') left top no-repeat;
background-size: 100% 15px;
}
Example

CSS: Make all <li> width from a list the same and take up 100% of available space

I am trying to make the horizontal navigation menu take up all available width from parent element.
I have tried using the display:table and display:table-cell but that did not work.
Other methods such as using overflow and width:auto doesn't work either.
The list is created by Joomla through a menu module.
html
<div id="DivN">
<jdoc:include type="modules" name="position-1" />
</div>
html (When viewing on browser)
<div id="DivN">
<ul class="nav menu nav-pills">
<li class="item-101 current active">
Home
</li>
<li class="item-113">
School Info
</li>
<li class="item-114">
Achievements
</li>
<li class="item-115">
News & Events
</li>
<li class="item-116">
Parents & Carers
</li>
<li class="item-117">
Community
</li>
<li class="item-118">
Contact Us
</li>
</ul>
</div>
css
#DivN{
width:100%;
height:42px;
border-top:1px solid black;
border-bottom:1px solid black;
text-decoration:none;
background-color:black;
text-align:center;
font-size:13px;
font-weight:700;
}
#DivN ul{
list-style:none;
width:100%;
}
#DivN ul li{
display:inline-block;
/*float:left;*/
line-height:22px;
height:32px;
list-style-type:none;
margin:4px;
overflow:hidden;
width:auto;
}
I have already tried numerous ways for the past few days...
Yet none of what is found on the internet works.
I do not know what the classes added by Joomla do, nor do I know where they are.
The navigation bar looks like this: https://www.dropbox.com/s/5sw94euzbsgwvrc/Capture.PNG
When mouse is over a button: https://www.dropbox.com/s/lv73war905ii0rh/2.PNG
How can I get it so the list will take up all available space while they are the same size?
If equal width among the items is important to you, you can float the items to the left and give them a set equal width (this works when you know how many items you have. Alternatively, you can use js to determine the width if you have a variable number of menu items):
#DivN{
width:100%;
height:42px;
border-top:1px solid black;
border-bottom:1px solid black;
text-decoration:none;
background-color:black;
text-align:center;
font-size:13px;
font-weight:700;
}
#DivN ul{
list-style:none;
width:100%;
height: 100%;
padding: 0;
margin: 0;
}
#DivN ul li{
float:left;
line-height:37px;
height:100%;
list-style-type:none;
margin:0;
overflow:hidden;
width: 14.28571428571429%;
cursor: pointer;
}
#DivN ul li:hover{
background-color: gray;
}
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
#DivN ul:before,
#DivN ul:after {
content: " "; /* 1 */
display: table; /* 2 */
}
#DivN ul:after {
clear: both;
}
/**
* For IE 6/7 only
* Include this rule to trigger hasLayout and contain floats.
*/
#DivN ul {
*zoom: 1;
}
Here is a fiddle: http://jsfiddle.net/kZb9C/
Updated to make the cf (clearfix) target your element: http://jsfiddle.net/4LUQe/16/
If you want to use the display: table approach, just remember to use display: table-cell on the <li> elements. Also, use vertical-align: middle if you want to vertically center them. (Note that table and table-cell CSS properties do not work in IE7 and below).
Here's a fiddle with the second approach (table): http://jsfiddle.net/kZb9C/1/
I think You should try to use
display: table
once again (for the nav element) and display: table-row for the ul, and display: table-cell for the li.
If You have any problems, please write, but this method SHOULD work.
Don't be afraid of display: table, it isn't an old table element, but really a great trick to make good layout with validate and semantic HTML. Hope it helps
UPDATE
The same working solution: CSS dynamic horizontal navigation menu to fill up specific width (table behavior)
<style>
div { border:1px solid red; width:400px; height:400px; }
ul { width:100%; height:50px; list-style: none; margin:0; padding:0; text-align: center; }
li { background-color:green; color:White; width:1%; position:relative; display:table-cell; border:solid 1px white; }
</style>
<div>
<ul>
<li>CELL 1</li>
<li>CELL 2</li>
<li>CELL 3</li>
<li>CELL 4</li>
</ul>
</div>

Text wont align on second Nav bar

Hi I'm trying to make a second navigation bar on my homepage the same as http://www.adventurelink.com/Gallery/Destination.com.
I have the first (top nav bar & text) in place but the text (links) for the second only sits underneath and I'm not sure why as I copy and pasted the code changing the "id" names. At the moment I'm just setting the layout before adding real content but need to sort this first. Any help would be much appreciated.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>website</title>
<link href="file:///C|/Users/Deniz/Desktop/Website/css/2nd.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!--TOP NAVIGATION BAR AND LOGO-->
<div id="topnavbar">
<div id="logo"></div>
<nav id="topnavlinks">
<ul>
<li>About</li>
<li>Profile</li>
<li>Sign Up</li>
<li>Login</li>
</ul>
</nav>
</div>
<!--SPACE FOR CHANGING PICTURES-->
<div id="picspace"></div>
<!--BOTTOM NAVIGATION BAR-->
<div id="botnavbar"></div>
<nav id="botnavlinks">
<ul>
<li>Destinations</li>
<li>Activities</li>
<li>Things to do</li>
<li>Accomodation</li>
<li>Transport</li>
</ul>
</nav>
<!--CONTENT---->
<div id="content"></div>
<!--FOOTER-->
<div id="footer"></div>
</body>
</html>
CSS:
* {
margin:0px;
}
#topnavbar{
height:50px;
margin:0 auto;
background: -webkit-linear-gradient(#e78869, #ad4e2f); /* For Safari */
background: -o-linear-gradient(#e78869, #ad4e2f); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#e78869, #ad4e2f); /* For Firefox 3.6 to 15 */
background: linear-gradient(#e78869, #ad4e2f); /* Standard syntax (must be last) */
}
#topnavlinks{
width:500px;
float:right;
margin: 0 auto;
}
#topnavlinks ul{
margin: 0 auto;
list-style:none;
height:35px;
}
#topnavlinks li{
margin: 0 auto;
height:35px;
float:left;
}
#topnavlinks li a:link, a:visited{
display:block;
color:#fff;
padding:10px;
text-decoration:none;
}
#topnavlinks li a:hover{
background-color:#6880af;
}
#logo{
}
#picspace{
height:400px;
background-color:grey;
}
#botnavbar{
height:50px;
background: -webkit-linear-gradient(#6880af, #314a79); /* For Safari */
background: -o-linear-gradient(#6880af, #314a79); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#6880af, #314a79); /* For Firefox 3.6 to 15 */
background: linear-gradient(#6880af, #314a79); /* Standard syntax (must be last) */
}
#botnavlinks{
width:500px;
float:right;
margin: 0 auto;
}
#botnavlinks ul{
margin: 0 auto;
list-style:none;
height:35px;
}
#botnavlinks li{
margin: 0 auto;
height:35px;
float:left;
}
#botnavlinks li a:link, a:visited{
display:block;
color:black;
padding:10px;
text-decoration:none;
}
#botnavlinks li a:hover{
background-color:#e78869;
}
#content{
height:500px;
background-color:grey;
}
#footer{
}
It's still going to need a lot more styling but the reason for this is because in your botnavbar you closed the div before you put the links in it.
<!--BOTTOM NAVIGATION BAR-->
<div id="botnavbar"></div> <!-- here, this shouldn't be closed yet -->
<nav id="botnavlinks">
<ul>
<li>Destinations</li>
<li>Activities</li>
<li>Things to do</li>
<li>Accomodation</li>
<li>Transport</li>
</ul>
</nav>
You created the "botnavbar" and immediately closed that div, so the links aren't going to be inside that bar. Just move the </div> down.
<!--BOTTOM NAVIGATION BAR-->
<div id="botnavbar">
<nav id="botnavlinks">
<ul>
<li>Destinations</li>
<li>Activities</li>
<li>Things to do</li>
<li>Accomodation</li>
<li>Transport</li>
</ul>
</nav>
</div>

HTML/CSS - Remove spaces from line breaks in code for LI

Hey,
Is there a way to get browsers to ignore line breaks in the source?
<div id="navbar">
<div id="navbar-container">
<ul>
<li>HOME</li>
<li>TUTORIALS</li>
<li>BLOG</li>
<li>FORUMS</li>
<li>LINKS</li>
<li> </li>
</ul>
</div>
</div>
#navbar {
background:#FFF;
width:940px;
margin:auto;
border-radius: 10px 10px;
-webkit-box-shadow: 5px 5px 10px #888;
}
#navbar-container {
margin:auto;
}
#navbar-container ul {
list-style:none;
text-align:center;
display:block;
width:auto;
padding:0;
margin:0;
}
#navbar-container li{
list-style:none;
border-left:3px solid black;
display:inline-block;
font-family:"Arial", sans-serif;
font-size:2em;
padding:0 7px 0 10px;
margin:0;
white-space:nowrap;
}
#navbar-container li:hover{
color:#FFF;
background:#000;
border-left:3px solid black;
display:inline-block;
font-family:"Arial", sans-serif;
font-size:2em;
margin:0;
padding:0 7px 0 10px;
}
It's placing a small space between each LI, I've set it up so then line up horizontally,
i could just remove the line breaks in the source, but id prefer not to.
You can float them (either left or right), or you can comment-out the spaces:
<ul>
<li>...</li><!--
--><li>...</li>
</ul>
Or simply leave the tags open 'til the next line.
<ul>
<li>...</li
><li>...</li
><li>...</li>
</ul>
IE seems to do that as a hold-over from the days when list items did not have closing tags. A common way around that is to put the closing > on the next line, i.e.
<ul>
<li>HOME</li
><li>TUTORIALS</li
><li>BLOG</li
>etc...
All browsers should totally ignore whitespace. Is there a particular browser giving you trouble?
Try:
li { margin: 0; padding: 0 }
I was wondering the same thing and what worked for me was:
li { display: table-cell; }
All breaks are ignored and now my menu buttons are right next to each other.
You can see a live example here on my music site: http://www.yanike.tk
I used a CSS Sprite on my UL LI for my navigation menu (home, media,...).