How to make a hrefs in nav span the entire div - html

I am trying to make my nav span the entire div, I want their background colour/target to have a width of 33%
<nav>
Home
Lesson 1: Intro
Lesson 2: Creating a Project
</nav>
#nav1 {
background-color: #a43200;
color: white;
text-decoration: none;
padding: 10px 100px 10px 100px;
font-size: 1.3em;
}
#nav2 {
background-color: #c73d00;
color: white;
padding: 10px 100px 10px 100px;
font-size: 1.3em;
text-decoration: none;
}

There are a couple things wrong with your setup (for example: you have multiple ids, which is a no-no, so I've changed them to classes).
I've also gone through and tried remove some repetitious styling. So you'll see that a lot of the button styles have been condensed into one #nav a style, then the custom colours have been applied in separate styles.
I've set the font-size property in #nav to 12px, but that was only for demonstration purposes. Please edit this to your liking.
This fiddle should help:
Fiddle:
http://jsfiddle.net/fACmM/
HTML:
<div id="nav">
Home
Lesson 1: Intro
Lesson 2: Creating a Project
</div>
CSS:
#nav
{
width:100%;
font-size:12px;
}
#nav a
{
width:33%;
float: left;
color: white;
padding: 10px 0px;
font-size: 1.3em;
text-decoration: none;
text-align:center;
}
.nav1 {
background-color: #a43200;
}
.nav2 {
background-color: #c73d00;
}

Added display:block to your CSS.
See fiddle: http://jsfiddle.net/djwave28/audAt/6/
<nav>
<ul>
<li>Home
</li>
<li>Lesson 1: Intro
</li>
<li>Lesson 2: Creating a Project
</li>
</ul>
</nav>
nav ul {
list-style:none;
}
nav ul li {
float:left;
width:30%;
}
#nav1 {
position:relative: float:left;
background-color: #a43200;
color: white;
text-decoration: none;
padding: 10px 0px 10px 0px;
font-size: 1.3em;
display:block;
}
#nav2 {
display:block;
position:relative: float:left;
background-color: #c73d00;
color: white;
padding: 10px 0px 10px 0px;
font-size: 1.3em;
text-decoration: none;
}

use class instead of id by the way this article help you understand why you used class instead of id with your current code
html
<nav>
Home
Lesson 1: Intro
Lesson 2: Creating a Project
</nav>
css
nav {width:960px}
nav a {
float:left;
text-decoration: none;
padding: 10px 50px 10px 50px;
font-size: 1.3em;
color: white;
}
.nav1 {
background-color: #a43200;
}
.nav2 {
background-color: #c73d00;
}
working demo
hope this help you

Related

Stop li element outlines from touching

One of my assignments is to create a responsive webpage. I'm running into trouble when attempting to open it on mobiles. My 'li' elements touch and look awful.
How can I stop the 'box' around each li item from touching?
HTML -
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet" type="text/css">
<body>
<center>
<div id="Menubar">
<ul>
<li id="active">Home
</li>
<li>Services
</li>
<li>Contact
</li>
</ul>
</div>
</center>
CSS -
#Menubar ul {
padding: .05em 0;
margin: 0;
list-style-type: none;
background-color: #3A3734;
color: #FFF;
width: 100%;
font-family: Oswald;
font-size: 32pt;
font-weight: bold;
text-align: center;
border-top:solid #8E7861 4px;
border-bottom:solid #8E7861 4px;
}
#Menubar ul li { display: inline; }
li a {
text-decoration: none;
margin: 0 0 3px 0;
background-color: white;
color: #6AA0CC;
padding: .1em 1em;
border: 2px solid #6AA0CC;
}
li a:hover {
background-color: #6AA0CC;
color: #fff;
border: 2px solid white;
}
.listcenter{
width:250px;
margin:0 auto;
text-align:left;
}
JSFIDDLE
Add the following code to the li a selector apart from other styles that you have applied.
li a {display:inline-block;}
Check the updated JSFIDDLE
The important thing is that for responsive webpage you should use media queries as well.

CSS right border not fitting right

I'm just learning CSS and HTML and decided to have a go at making a mock up website. I'm having trouble with the border not meeting the end of the top bar. Other times I've had it go over.
https://jsfiddle.net/9gonuvu7/
#topnav li {
float: left;
margin: 0;
padding: 16px 10px 10px 20px;
list-style: none;
color: white;
font-size: 1.2em;
border-right: solid #3E6F87 1px;
You can see this in the above link. If you could explain to me why this is happening and how I can avoid it in future I would be very grateful.
Remove the padding from the parent.
That's preventing it from reaching top.
#topbar {
background-color: #2A4F6E;
width: 100%;
height: 50px;
padding: 0px 0 0px 0;
margin: 0;
}
Okay, because you said you just started with HTML and CSS I changed a bit more in your code.
At the moment your fixedwith div has no impact on the code (maybe you use it in your full website).
You applied the background on the whole topbar, that HTML-wise also contains your menu points, assuming you only want your headline to have that blue background I swapped that property to the h1-tag.
With this change the borderlines are overlapped b the headline, which should do the job.
new JSFiddle
* {
margin:0;
padding:0;
}
body {
margin: 0;
font-family: arial, helvetica, sans-serif;
}
a {
text-decoration: none;
color: white;
}
a:hover {
text-decoration: underline;
}
#topbar {
float:left;
width:100%;
height:100%;
overflow:hidden;
}
#topbar h1 {
display: block;
width:100%;
height:100%;
background-color: #2A4F6E;
padding: 7px 50px 7px 40px;
margin: 0;
color: white;
float: left;
border-right: solid #3E6F87 1px;
}
#topnav {
float:left;
width:100%;
height:50px;
background:#ccc;
}
#topnav li {
float: left;
margin: 0;
padding: 16px 10px 10px 20px;
list-style: none;
color: white;
font-size: 1.2em;
border-right: solid #3E6F87 1px;
}
#topnav ul {
margin: 0;
padding: 0;
}
#topnav a:hover{
color: #A97437;
}
<body>
<div id="container">
<div id="topbar">
<div class="fixedwidth">
<h1>Neil's Tech Reviews</h1>
<div id="topnav">
<ul>
<li> Home</li>
<li> Reviews</li>
<li> Forum</li>
<li> Partners</li>
<li> About</li>
</ul>
</div>
</div>
</div>
</div>
</body>

Bullet points appearing in navigational menu with the addition of list-style-type: none

I've been having issues with adding CSS to a UL and still having the bullet points showing up.
this is my html code
<div id="menu">
<ul>
<li> تماس با ما</li>
<li>درباره ما</li>
<li> آرشیو ویدئو</li>
<li>آرشیو سرودها و منابع پرستشی</li>
<li>خانه</li>
</ul>
</div>
and this is my CSS
<style>
#menu {
width: 780px;
height: 40px;
font-size: 13px;
font-family: Tahoma, Geneva, sans-serif;
font-weight: bold;
text-align: center;
text-shadow: 3px 2px 3px #333333;
background-image: url("images/Menu_Background.jpg");
border-radius: 9px;
}
#menu li {
list-style:none;
list-style-type:none;
display: inline;
padding: 20px;
}
#menu ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
#menu a {
text-decoration: none;
color: #fff;
padding: 8px 8px 8px 8px;
}
#menu a:hover {
color: #F90;
background-color: none;
}
</style>
I've read many other forums and questions that were asked on Stackoverflow and the solution was to add the `list-style-type=none; but when I added that I am still having the same issue.
here is my URL to the site http://khaneyeparastesh.com/indexHomeNew.htm
list-style-type is not your issue. When you enter the code you've provided on a JS Fiddle there are no bullets. I believe that you are referring to the red "bullet" points that are showing on your website. These are a result of this style:
li a {background: url(images/bull.gif) 0 7px no-repeat;}
Remove that and the red bullets will be gone.

href tag not working. css style interfering?

I'm relatively new to HTML (only a few weeks now), and I'm stuck. The "about" section on my page doesn't seem to be clickable and won't bring me to the linked page. The confusing thing is that the link appears to be clickable since the floating hand icon appears when hovering over the link. I can right-click and open the link in a new tab. If I delete the css and try the link without the formatting, it is also valid.
I'm confused... is the CSS somehow messing with my href tag?
here's the html:
<div id="header">
<div class="container">
<div class="row">
<div class="twelwecol last">
<div id="navigation"> <!-- Navigation Links -->
<ul>
<li>about</li>
<li>members</li>
<li>events</li>
<li>media</li>
<li>social</li>
</ul>
</div>
</div>
</div>
</div>
</div>
and the code from the "navigation.css" page:
#header {
width: 100%;
height: 49px;
color: white;
background-color: #1b1e25;
position: fixed;
z-index: 9999;
}
#logo {
background-image: url('../images/assets/logo.png');
background-repeat: no-repeat;
height: 80px;
width: 80px;
display: block;
float: left;
}
#navigation {
padding-top: 2px;
width: 480px;
display: block;
margin: 0px auto;
}
#navigation ul {
padding:0px;
margin: auto;
text-transform: uppercase;
}
#navigation ul li {
display:inline;
float:left;
list-style:none;
padding: 13px 20px 13px 20px;
}
#navigation ul li {
display:inline;
float:left;
list-style:none;
padding: 13px 20px 13px 20px;
}
#navigation ul li a {
color: gray;
text-decoration: none;
font-family:'Scada', sans-serif;
font-size: 13px;
}
#navigation ul li a:hover {
color: white;
}
.current {
border-bottom: 1px solid #cb1c1c;
color: white;
}
#contact {
padding-top: 12px;
float: right;
position: relative;
}
#contact a {
text-decoration: none;
text-transform: uppercase;
font-size: 9px;
color: gray;
padding: 11px;
}
#contact a:hover {
color: white;
border: #333333 1px solid;
padding: 10px;
}
Could someone please tell me what is going on here? Any help would be most appreciated!
it appears clickable because it is contained within the a tag. When you link something your href needs to have a proper extension. Are you sure youre using .htm and not html?
furthermore CSS affects Style (css= cascading style sheet) it wont affect html (or any other) functions like the href function.
try changing your href to href="about.html"

How to add space between border line and menu item

I'm trying to add space between a bottom border line and my <li> item but no luck.
My code:
<div class="menuwrap">
<div class="menu">
<ul>
<li>Home
</li>
<li>Query
</li>
<li>Reports
</li>
</ul>
</div>
</div>
CSS styles:
.menu {
color: #000;
background: #FFF;
}
.menu ul {
list-style: none;
display: inline;
float: left;
padding-left: 40px;
margin-top: 90px;
}
.menu li {
float:left;
margin-left:10px;
}
.menu li a:hover {
padding: 0 10px 0 10px;
font-size: xx-large;
border-bottom: 1px solid white;
border-spacing: 20px;
}
.menu li a {
text-decoration: none;
color: #000;
font-weight: bold;
font-size: large;
}
.menuwrap {
overflow:hidden;
}
I tried couple of different things, but nothing worked so far. border-spacing is not doing what I want. I tried padding-bottom and that also didn't work. Can someone tell me how to achieve that? I want a space between the "li" item and its border-bottom.
Adding a padding-bottom or margin-bottom seems to be working.
li:hover{
padding-bottom: 10px;
}
Here's a FIDDLE
or
li:hover{
margin-bottom: 10px;
}
Here's a FIDDLE
Update: After reading your comment and having a look at the fiddle you provided, I've created one which does what you are trying to do. It's different from the code you provided but it's easier to read and you can modify it according to your needs
.menu{
list-style-type: none;
}
.menu li{
display: inline-block;
*display: inline;
zoom: 1;
margin: 10px;
}
.menu li a{
text-decoration: none;
color: #000;
border-bottom: 2px solid #000;
padding-bottom: 30px;
}
.menu li a:hover{
font-size: 2em;
font-weight: bold;
}
FIDDLE
I guess you didn't give your styles. padding-bottom works. Please check http://jsfiddle.net/VZCrq/8/