css sprite for navigation not working - html

I am trying to use a css sprite for naviation in a dreamweaver template for a school project, and the image is not showing up.. Here is my code, right now I am only working on the home button. I have made individual sprites for every button.
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jordan's Website</title>
<link href="Styles/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="header"><img src="" alt="Insert Logo Here" name="Insert_logo" width="180" height="90" id="Insert_logo" style="background: #C6D580; display:block;" />
<!-- end .header --></div>
<div class="sidebar1">
<ul class="nav">
<li id="home"> </li>
<li id="projects">Projects</li>
<li id="tutorials">Tutorials</li>
<li id="family">Family</li>
<li id="hobbies">Hobbies</li>
<li id="tennis">Tennis</li>
<li id="yng">Youth and Gov</li>
<li id="sources">Sources</li>
</ul>
<p> </p>
<!-- end .sidebar1 --></div>
<div class="content">
<h1>Instructions</h1>
<p>Be aware that the CSS for these layouts is heavily commented. If you do most of your work in Design view, have a peek at the code to get tips on working with the CSS for the fixed layouts. You can remove these comments before you launch your site. To learn more about the techniques used in these CSS Layouts, read this article at Adobe's Developer Center - http://www.adobe.com/go/adc_css_layouts.</p>
<h2> </h2>
<!-- end .content --></div>
<div class="footer">
<p>This .footer contains the declaration position:relative; to give Internet Explorer 6 hasLayout for the .footer and cause it to clear correctly. If you're not required to support IE6, you may remove it.</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
</html>
CSS:
#charset "utf-8";
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #42413C;
margin: 0;
padding: 0;
color: #000;
}
/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}
/* ~~this fixed width container surrounds the other divs~~ */
.container {
width: 960px;
background: #FFF;
margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
}
/* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */
.header {
background: #ADB96E;
}
/* ~~ These are the columns for the layout. ~~
1) Padding is only placed on the top and/or bottom of the divs. The elements within these divs have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
2) No margin has been given to the columns since they are all floated. If you must add margin, avoid placing it on the side you're floating toward (for example: a right margin on a div set to float right). Many times, padding can be used instead. For divs where this rule must be broken, you should add a "display:inline" declaration to the div's rule to tame a bug where some versions of Internet Explorer double the margin.
3) Since classes can be used multiple times in a document (and an element can also have multiple classes applied), the columns have been assigned class names instead of IDs. For example, two sidebar divs could be stacked if necessary. These can very easily be changed to IDs if that's your preference, as long as you'll only be using them once per document.
4) If you prefer your nav on the right instead of the left, simply float these columns the opposite direction (all right instead of all left) and they'll render in reverse order. There's no need to move the divs around in the HTML source.
*/
.sidebar1 {
float: left;
width: 180px;
background: #EADCAE;
padding-bottom: 10px;
}
.content {
padding: 10px 0;
width: 780px;
float: left;
}
/* ~~ This grouped selector gives the lists in the .content area space ~~ */
.content ul, .content ol {
padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */
}
/* ~~ The navigation list styles (can be removed if you choose to use a premade flyout menu like Spry) ~~ */
ul.nav {
list-style: none; /* this removes the list marker */
border-top: 1px solid #666; /* this creates the top border for the links - all others are placed using a bottom border on the LI */
margin-bottom: 15px; /* this creates the space between the navigation on the content below */
}
ul.nav li {
border-bottom: 1px solid #666; /* this creates the button separation */
}
ul.nav a, ul.nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */
padding: 5px 5px 5px 15px;
display: block; /* this gives the link block properties causing it to fill the whole LI containing it. This causes the entire area to react to a mouse click. */
width: 160px; /*this width makes the entire button clickable for IE6. If you don't need to support IE6, it can be removed. Calculate the proper width by subtracting the padding on this link from the width of your sidebar container. */
text-decoration: none;
}
#home li a{
display: block;
background: url(Assets/Images/homesprite.png) no-repeat;
height: 20px;
width: 155px;
background-color:transparent;
}
#home:hover{
background-position: 0 -20px;
}
/* ~~ The footer ~~ */
.footer {
padding: 10px 0;
background: #CCC49F;
position: relative;/* this gives IE6 hasLayout to properly clear */
clear: both; /* this clear property forces the .container to understand where the columns end and contain them */
}
/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}

You're targeting it wrong. Your CSS code is #home li a.
Your html is <li id="home"></li>.
You need to target it like this #home a since home is the list item.
Here's the jsfiddle to show you.

Related

adding space between items, making background not stretch horizontally

I'm practicing basic HTML programming and have added a list object to the code between two headings. when I view the list background I see that it stretches right to the side of page. About this I want to know how to limit the width of background so it ends just after covering the li elements (also curious how to get it stretch downward - maybe I need another div?)
also want to add some spacing between the li elements as shown in a book I have. I have added liststyle li {} as instructed but the ul box does not respond. it also does not respond to side / background-size properties for above issue.
how could I get this list box working?
part of the HTML code:
.liststyle { /* class */
list-style: square; /* circle / lower-roman */
padding : 15px; /*spacing between border and element*/
margin : 20px; /*spacing outside border*/
background: #66ccff; /*background box colour */
color: #ff0000; /*text color */
list-style-position: inside; /*get bullets inside background box*/
border-style: double;
border-width: 5px;
border-color: #600;
size: 100px 100px; /* background stretches horizontally to side of page*/
}
.liststyle li{ /*trying to get spacing between list items - will not work*/
padding-bottom = 100px;
}
<h1>National Geographic</h1>
<h2>How a Remote Peak in Myanmar Nearly Broke an Elite Team of Climbers</h2>
<ul class="liststyle">
<li>the beggining</li>
<li>reaching the rampart</li>
<li>regrouping</li>
<li>freezing cold</li>
</ul>
<h4>On one of mountaineering’s most dangerous journeys,
group was pushed to the limit by physical and mental challenges.</h4>
there is no size property, exists thought background-size (although you don't need this since it is only a background-color)
you have padding= should be padding:
you can use border shortand
to contain the background, you need to use a max-width in ul + display:inline-block
(extra) adding box-sizing:border-box it will make the border+padding part of the calculations for width
.liststyle {
/* class */
list-style: square;
/* circle / lower-roman */
padding: 15px;
/*spacing between border and element*/
margin: 20px;
/*spacing outside border*/
background: #6cf;
/*background box colour */
color: #ff0000;
/*text color */
list-style-position: inside;
/*get bullets inside background box*/
border: 6px solid #600;
max-width: 300px;
display: inline-block;
box-sizing:border-box
}
.liststyle li {
/*trying to get spacing between list items - will not work*/
padding-bottom:100px;
}
<ul class="liststyle">
<li>the beggining</li>
<li>reaching the rampart</li>
<li>regrouping</li>
<li>freezing cold</li>
</ul>
<h4>On one of mountaineering’s most dangerous journeys,
group was pushed to the limit by physical and mental challenges.</h4>
Use
.liststyle {
display:inline-block;
width:500px;
If you leave width param, it fits to the content.

setting color for links using nav ul li a in a css

Is there something special about links when setting certain properties?
It looks like some properties (font-weight, etc) will cascade down to the element from higher elements, but others don't. (I played around setting color at various levels in my code, then commented it out).
Color does not seem to work and text-decoration does not work fully.
Do certain properties need to be directly assigned to links? I am thinking this might be related to browser behavior (like visited)?
/*
Example1 css
*/
body {
color: red;
font-weight: bold;
text-decoration: line-through;
}
nav {
/* float: left; */
margin-right: 10px;
width: 200px;
}
nav {
background-color: rgb(235,235,235);
/* color: black; */
/* font-weight: bold; */
}
nav ul {
/* color: green; */
}
nav ul li {
/* color: yellow; */
}
nav ul li a{
/* color: orange; */
}
<!DOCTYPE html>
<html>
<head>
<!--
Example1
-->
<link rel="stylesheet" type="text/css" href="Example1_styles.css">
</head>
<body> BOO1
<nav> BOO2
<ul>BOO3
<li>Option 1 BOO4</li>
<li>Option 2</li>
</ul>
</nav>
</body>
</html>
The default for a lot of elements on many css properties is 'inherit' which causes the parent's styling to apply. However, each type of element has it's own specific styling on some css properties (different properties for different elements), causing the parent's styling to not apply. I know this is kind of vague, but pretty much every kind of tag has something unique to it so there is not an easy, all-encompassing rule.
Let me give some examples: if you have <div><p>Some Text</p><div> any styling regarding text (font-size, color,etc.) that is placed on the div tag will apply to the p tag because it inherit's those properties by default. Anchor tags <a>anchor</a> however have a default for the attributes font-color and text-decoration and therefore these attributes applied to their parent div would be overwritten. You can look at this stack overflow answer for lists of different element's default behaviors.Hope that helps.

How do I add a class to my unordered list in Weebly?

Weebly help center can't help me on this simple one and they recommended the forums, google and w3schools. I wan't to style my <ul></ul> in weebly by adding a class to it. How do I do this?
So, Weebly's support documentation says your backend will have a tab to manage your CSS and HTML.
Option one
1 - Go to the HTML tab and add a class to your ul.
<ul class="myClass"></ul>
2 - Go to the CSS tab and at the bottom of the main css file write in your new class style
.myClass { /* whatever */}
By placing the class at the bottom of your CSS, these class styles will override the current styles if they are different. You may need to cancel out certain things like margin or padding. For instance:
ul { margin: 100px; }
.myClass { margin: 0; }
.myClass will have a margin of 0 as the uls defined style has been overridden.
Option two
Wrap your editable content in a div with a class or id and target the ul within that div. The div itself can remain unstyled.
Example
HTML
<div id="editableContent">
<ul>
<li>List Item</li>
</ul>
</div>
CSS
#editableContent ul {
color: #F00;
}
Every list item within div#editableContent will have red text. The editor doesn't need any HTML knowledge and styles will be consistent.
I solved it, I override the standard theme design rather than create my own.
These are the CSS parts I modified: #main-wrap .paragraph ul and #main-wrap .paragraph ol
#main-wrap .paragraph ul {
padding-left:5px !important;
}
#main-wrap .paragraph ul li {
list-style: none !important;
background: url(red-arrow.png) no-repeat 0px 0px;
color: #000000;
padding-left:30px !important;
}
#main-wrap .paragraph ol li {
list-style: none !important;
background: url(red-bullet.png) no-repeat 0px 6px;
color: #000000;
padding-left:20px !important;
}

Why the margin on css doesn't work properly for div

<html>
<head>
<link rel="stylesheet" type="text/css" href="calendar.css">
</head>
<body>
<div class="textAreaWrapper">
<div class="textAreaWrapperPanel">
<h3 class='textblockheader'>Text Block Settings</h3>
</div>
</div>
</body>
</html>
This is my html code, and below is my css code:
.textAreaWrapper{
border: 1px solid black;
background-color: white;
}
.textAreaWrapperPanel{
background-color : #093459;
color: white;
margin-top:0px;
}
.textblockheader{
font-family : "Helvetica Neue,Helvetica,Arial,sans-serif";
font-size: 16px;
font-weight : normal;
}
I expect there will me no space between textAreaWrapperPanel and textAreaWrapper div elements, but instead, it still have. But if I change textblockheader's margin-top to 0px, its work, can anyone explain why this happen?
That's cause the browser applies to H3 elements (and other elements) a margin by default. DEMO
All you need is to use a CSS Reset
To quickly view an ugly rest just use
*{margin:0; padding:0;} /* will apply to all (*) elements */
http://meyerweb.com/eric/tools/css/reset/
http://yuilibrary.com/yui/docs/cssreset/
Regarding your concerns about **[Collapsing Margins][2]**:
*Why the blue background of the H3's parent DIV does not fully cover the space taken by the `H3` element?*
That's cause you're nesting two block-level elements: h3 into div, where the box models and natural floats are being handled by the browser unless specified like in this three solutions:
Set overflow:auto; to the parent div
Or set your H3 element as display: inline-block;
Use a clearfix for the block-level parent element
jsBin PLAYGROUND
/* // uncomment
*{margin:0;padding:0;}
*/
.textAreaWrapper{
border: 1px solid black;
background-color: white;
}
.textAreaWrapperPanel{
/* overflow:auto; */ /* Uncomment this or */
background-color : #093459;
color: white;
}
.textblockheader{
/* display:inline-block; */ /* ... this one or ...*/
font-family : "Helvetica Neue,Helvetica,Arial,sans-serif";
font-size: 16px;
font-weight : normal;
}
/* add this class to your DIV .textAreaWrapperPanel */
.clearfix:before,
.clearfix:after {
content:" ";
display:table;
}
.clearfix:after {
clear:both;
}
Micro clearfix resource: http://nicolasgallagher.com/micro-clearfix-hack/
I think your problem is that they are already at 0 space between? The two divs both have the same background color and the inner one has no border. Try making the inner one a different color just to see. I bet it will have no upper margin. It's just your H3 tag that by default has a margin.
EDIT:
Sorry I misread your code. You are correct, they are different colors. Here is the WHY of what's going on. Your H3 element is by default presenting as a BLOCK level element. This causes it to have its own background margin that is set to 10px top and bottom. If you were to tell your H3 class textblockheader to:
display: inline;
It would cause it to remove the background area and margins as well without having to reset anything. As it stands the two divs are touching each other, but the white margin from your textblockheader class is adding extra space that gets the default margin color which is white.
But yeah, the reason it's doing that is the default css styling of H3 elements as block level elements with a default top and bottom margin.
The heading tags have default margins. This link might help:Default Heading Styles
Also resetting the default css values of tags may avoid similar future errors: Reset CSS

CSS Nav Bar wrapping around

I'm trying to create my very own css menubar and I am learning a lot. Unfortunately I am stuck on this one piece and I can't figure out how to get around it. My menubar is to long so I use line breaks to wrap each menu element around but its not letting my menu to run across the menu bar. Can you tell me what I am missing here?
<div id="menucontainer">
<ol id="navlinks">
<li>COMPANY<br />OVERVIEW</li>
<li>CLIENTS<br />TESTIMONIALS</li>
<li>ACCREDITATION<br />SERVICES</li>
<li>LEGAL<br />SUPPORT</li>
<li>TRAINING</li>
<li>CONSULTING<br />SERVICES</li>
<li>FREE<br />POLICY CENTER</li>
<li>IN THE NEWS</li>
<li>STRATEGIC<br />PARTNERS</li>
</ol>
</div>
CSS Code:
/* We set the width and color of the background for a menu wrapper. */
#menucontainer{width: 1021px; height: 61px; background-color:#0C318C; margin: auto; padding-top:5px;}
/* We target the top of the order list and remove the list properties. */
#navlinks li {display: inline; list-style: none;}
/* This line sets the font style of the bullet menu */
ol{font-size: 12px; font-family: 'Tinos', serif;line-height: 18px;}
/* We target the li items with and without a hyper link and color the font white. */
li, li a {text-decoration: none; color: white;}
I put it up on JFiddle and you can find it here: http://jsfiddle.net/L4sTB/
Thanks,
Frank G.
Check this fiddle.
I have made changes to the following CSS rule.
#navlinks li {
display: inline-block; /* to display the menu items as blocks in same line */
list-style: none;
text-align: center; /* center align the text within the block */
width: 10%; /* set each block a width */
vertical-align: middle; /* align the contents to middle vertically */
}
You can set display:inline-block to your li elements and it will span the width of your nav bar: http://jsfiddle.net/shaunp/L4sTB/3/
Is this your desired effect?
The list should be inline-block. I added center align text and a border to each.
#navlinks li {display: inline-block; list-style: none;text-align:center;border: 1px solid white;}