I'm a newbie and I'm trying to figure out how to put a background image on my site. I've linked the image but it seems that it is only showing about 30% of the image. (Just the top of the photo is showing, the whole way across but none of the bottom) I'd like the entire image to be the background. The image is 594kb.
Here is my CSS:
#nav1 {
width: 100%;
float: left;
margin: 0 0 3em 0;
padding: 0;
list-style: none; }
#nav1 li {
float: left; }
#nav1 {
width: 100%;
float: left;
margin: 0 0 3em 0;
padding: 0;
list-style: none;
background-color: #f2f2f2;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc; }
#nav1 li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #069;
border-right: 1px solid #ccc; }
#nav1 li a:hover {
color: #c00;
background-color: #fff; }
.nav
{
position: fixed;
top: 0;
}
.jumbotron {
background-image: url(../images/image.jpg);
background-repeat: no-repeat;
min-width: 100%;
min-height: 100%;
}
.jumbotron {
padding:0px;
}
body {
font-family: 'Lobster', serif;
text-shadow: 4px 4px 4px #aaa;
text-align: center;
}
h1 {
font-size: 70px;
line-height: 4em;
}
h2 {
font-size: 95px;
line-height: 1em;
}
You have to remember here, that for background images, each person has different screen resolutions and sizes. So having the entire image without some cropping or messing the image ratio is kind of impossible across different screen sizes.
Here is my preferred simple method using background-size cover. - I learned this from CSS Tricks..
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Hi i am having trouble making a vertical navigation using a sprite as a .gif file.
I want to have it with a gray background and use my sprite to change as I hover. If you look at my sprite i have 2 pairs of each button, i want the faded icon to be there first then when hovered it moves it to the 100% opacity icon. Here is what i have so far...
link to view my sprite
my css:
#socialmedia {
margin: 0;
padding: 0;
list-style: none;
background:#666;
width:150px;
}
#socialmedia a {
display:block;
width:137px;
height:10px;
margin: 1em 0; padding:7px 0 10px 20px;
font: bold 14px/1 sans-serif;
color: #000;no-repeat;
text-decoration: none;
}
#socialmedia a:hover {
background-position: -157px 0;
color: #fff;
background: url("images/buttons.gif") 0 0
}
#socialmedia a:active {
background-position: -314px 0;
color:white;
}
my html:
<ul id="socialmedia">
<li>FB</li>
<li>TW </li>
<li>LI</li>
<li>GM</li>
<li>YH</li>
</ul>
I'd change a couple of things with your sprite to make it easier - the images should have no space between them and the icons should be aligned vertically, unless you want them to move horizontally when moused over in addition to changing opacity?
At any rate, you could do something like this:
#socialmedia {
margin: 0;
padding: 0;
list-style: none;
background:#666;
width:150px;
}
#socialmedia li a {
display:block;
width:137px;
height:10px;
margin: 1em 0;
padding:7px 0 10px 20px;
font: bold 14px/1em sans-serif;
color: #666;
background: transparent url("buttons1.gif") 0 0 no-repeat;
text-decoration: none;
}
#socialmedia li a:hover {
background-position: 0 -32px;
color: #fff;
}
#socialmedia li a.twitter {
background-position: 0 -63px;
}
#socialmedia li a.linkedin {
background-position: 0 -127px;
}
#socialmedia li a.google {
background-position: 0 -191px;
}
#socialmedia li a.yahoo {
background-position: 0 -255px;
}
#socialmedia li a.twitter:hover {
background-position: 0 -95px;
}
#socialmedia li a.linkedin:hover {
background-position: 0 -159px;
}
#socialmedia li a.google:hover {
background-position: 0 -223px;
}
#socialmedia li a.yahoo:hover {
background-position: 0 -287px;
}
Then in your html just add the correct classes:
<ul id="socialmedia">
<li>FB</li>
<li>TW </li>
<li>LI</li>
<li>GM</li>
<li>YH</li>
</ul>
Oh, and you'll need a different color for your link text - #000 won't work too well on top of black :)
I changed it to #666.
Trying to get the following sprite to work http://reversl.net/sprites/ on hover. Here's my styling
#social {margin: 0; padding: 0; width: 212px; height: 48px; background-image: url('images/social-icons.png');}
#social li {margin: 0; padding: 0; list-style-type: none; display: inline; height: 48px; text-align: center; float: left;}
#social a {display: block; height: 48px;}
#social a:hover {background-image: url('images/social-icons.png');}
#social-home {width: 48px;}
#social-home a:hover {background-position: bottom 0;}
#social span {display: none;}
I think the problem is the background position of my hover declaration?
http://jsfiddle.net/aFL8A/2/
This seems like a thing you want to achieve, yes?
HTML :
<ul id="social">
<li id="social-facebook"><span>Facebook</span></li>
<li id="social-twitter"><span>Twitter</span></li>
<li id="social-googlePlus"><span>Google+</span></li>
<li id="social-youtube" class="last"><span>Youtube</span></li>
</ul>
CSS :
#social {margin: 0; padding: 0; width: 212px; height: 48px;}
#social li {
margin: 0 5px 0 0;
padding: 0;
list-style-type: none;
display: inline;
height: 48px;
float: left;}
#social li.last{
margin-right:0px;
}
#social li a {
background-image: url("images/social-icons.png") left top;
background-repeat : no-repeat;
display: block;
height: 48px;
width: 48px;
}
#social li#social-facebook a{
background-position: left top;
}
#social li#social-facebook a:hover{
background-position: left -53px;
}
#social li#social-twitter a{
background-position: -53px top;
}
#social li#social-twitter a:hover {
background-position: -53px -53px;
}
#social li#social-googlePlus a{
background-position: -106px top;
}
#social li#social-googlePlus a:hover {
background-position: -106px -53px;
}
#social li#social-youtube a{
background-position: -159px top;
}
#social li#social-youtube a:hover {
background-position: -159px -53px;
}
#social span {display: none;}
Ok, I give up - I can't work it out; the wrapper seems to go from the top to the bottom while I want it to leave a gap at the top and bottom so the background appears through. I can't seem to work it out. I am very novice to this. Any help & ideas very welcome.
Code
body {
background: #ffffff url(bgfin.jpg) repeat;
font-family: Tahoma,arial, sans-serif;
font-size:12px;
color:#666666;
height: 100%;
margin:0;
padding:0;
}
#wrapper {
background: url(body-line.png) center repeat-y;
padding-top: 65px;
padding-bottom: 65px;
}
#wrappertop{
background: url(header.png) top center no-repeat;
}
#wrappertbtm{
background: url(footer-new.png) bottom center no-repeat;
padding-bottom: 65px;
}
#container{
width: 959px;
margin: 0 auto;
}
.title{
width: 959px;
height: 56px;
padding: 15px 0px 10px 0px;
font-size: 30px;
color: #bd7821;
}
#navigation{
position: relative;
width: 959px;
height: 40px;
z-index: 2;
}
#navigation li{
float: left;
z-index: 2;
padding: 0px 34px 0px 0px;
}
#navigation li a{
display: inline-block;
position: relative;
outline: none;
height: 28px;
color: #e3e3e3;
z-index: 2;
font-size: 12px;
padding: 15px 0px 0px 0px;
text-decoration: none;
}
#navigation li a:hover, #navigation li#active a{
color: #bd7821;
text-decoration: none;
}
#header{
position: relative;
width: 959px;
height: 196px;
z-index: 1;
margin: 20px 0px 0px 0px;
}
Try:
body { padding:20px 0; }
Or:
#wrapper { margin:20px 0; }
That is shorthand for:
#wrapper {
margin-top:20px;
margin-right:0;
margin-bottom:20px;
margin-left:0;
}
Remember:
Padding is rendered inside of the element
Margin is on the outside
This might help as a reminder:
How to remember in CSS that margin is outside the border, and padding inside
I am working on a project where I need to build the pages using div tags and css. The pages look fine in Firefox, Opera, Safari and IE 8, but my client who is using IE7 is complaining of layout problems in IE 7. Can someone take a look and tell me how to fix the code so it will work in all the browsers, especially IE 7? Links and css code is below. Thanks.
Home Page is here: (Code is below)
http://www.danieldicenso.20m.com/citybeams/
/* HOME PAGE CSS CODE */
body {font-size:12px; font-family:"trebuchet MS", verdana, arial, sans-serif; background: #CCCCCC; word-wrap:break-word;}
#wrapper {
text-align: left;
margin: 0px auto;
padding: 0px;
border:0;
width: 1000px;
background: #FFFFFF;
}
#header {
margin: 0 0 15px 0;
background: #ffffff;
}
#side-a {
float: left;
width: 300px;
}
#side-b {
float: right;
width: 300px;
}
#content {
float: left;
width: 400px;
}
#footer {
clear: both;
background: #ffffff;
}
.curvy2 {
position:relative;
width:250px;
color:#000;
margin-top: 1em;
margin-right: auto;
margin-bottom: 1em;
margin-left: auto;
background-color: #99FF99;
background-image: url(bl.gif);
background-repeat: no-repeat;
background-position: left bottom;
}
#ctl, #cbl, #ctr, #cbr {position:absolute; width:20px; height:20px; color:#327734; background:#fff; background-image:url(metalgreen2.jpg); overflow:hidden; font-style:normal; z-index:1;}
#ctl {top:0; left:0;}
#cbl {bottom:0; left:0;}
#ctr {top:0; right:0;}
#cbr {bottom:0; right:0;}
.curvy em b {position:absolute; font-size:150px; font-family:arial; color:#327834; line-height:40px; font-weight:normal;}
#ctl b {left:-8px;}
#ctr b {left:-25px;}
#cbl b {left:-8px; top:-17px;}
#cbr b {left:-25px; top:-17px;}
.curvy p {position:relative; z-index:100; padding:5px 10px;}
.bl {
width: 330px;
background-color: #99ff99;
background-image: url(bl.gif);
background-repeat: no-repeat;
background-position: 0 100%;
}
.br {background: url(br.gif) 100% 100% no-repeat}
.tl {background: url(tl.gif) 0 0 no-repeat}
.tr {background: url(tr.gif) 100% 0 no-repeat; padding:10px}
.clear {font-size: 1px; height: 1px}
.bl2 {
width: 330px;
background-color: #ffffff;
background-image: url;
background-repeat: no-repeat;
background-position: 0 100%;
}
.br2 {background: url100% 100% no-repeat}
.tl2 {background: url 0 0 no-repeat}
.tr2 {background: url 100% 0 no-repeat; padding:10px}
.clear2 {font-size: 1px; height: 1px
}
#navmenu {
position: relative;
left: 16px;
top: 0px;
width: 712px;
height: 22px;
z-index: 2;
background: #99FF99;
text-align: center;
padding: 0px;
}
body,td,th {
color: #000000;
}
a:link {
color: #003333;
}
a:visited {
color: #000066;
}
a:active {
color: #FF0000;
}
--------------------
Sign-up page is here: (CSS Code below)
http://www.danieldicenso.20m.com/citybeams/signuppage.html
/* SIGNUP PAGE CSS CODE */
body {font-size:12px; font-family:"trebuchet MS", verdana, arial, sans-serif; background: #CCCCCC; word-wrap:break-word;}
#wrapper {
text-align: left;
margin: 0px auto;
padding: 0px;
border:0;
width: 1000px;
background: #FFFFFF;
}
#header {
margin: 0 0 15px 0;
background: #ffffff;
}
#side-a {
float: left;
width: 100px;
}
#side-b {
float: right;
width:100px;
}
#content {
float: left;
width: 800px;
}
#footer {
clear: both;
background: #ffffff;
}
.curvy2 {
position:relative;
width:250px;
color:#000;
margin-top: 1em;
margin-right: auto;
margin-bottom: 1em;
margin-left: auto;
background-color: #99FF99;
background-image: url(bl.gif);
background-repeat: no-repeat;
background-position: left bottom;
}
#ctl, #cbl, #ctr, #cbr {position:absolute; width:20px; height:20px; color:#327734; background:#fff; background-image:url(metalgreen2.jpg); overflow:hidden; font-style:normal; z-index:1;}
#ctl {top:0; left:0;}
#cbl {bottom:0; left:0;}
#ctr {top:0; right:0;}
#cbr {bottom:0; right:0;}
.curvy em b {position:absolute; font-size:150px; font-family:arial; color:#327834; line-height:40px; font-weight:normal;}
#ctl b {left:-8px;}
#ctr b {left:-25px;}
#cbl b {left:-8px; top:-17px;}
#cbr b {left:-25px; top:-17px;}
.curvy p {position:relative; z-index:100; padding:5px 10px;}
.bl {
width: 330px;
background-color: #99ff99;
background-image: url(bl.gif);
background-repeat: no-repeat;
background-position: 0 100%;
}
.br {background: url(br.gif) 100% 100% no-repeat}
.tl {background: url(tl.gif) 0 0 no-repeat}
.tr {background: url(tr.gif) 100% 0 no-repeat; padding:10px}
.clear {font-size: 1px; height: 1px}
.bl2 {
width: 330px;
background-color: #ffffff;
background-image: url;
background-repeat: no-repeat;
background-position: 0 100%;
}
.br2 {background: url100% 100% no-repeat}
.tl2 {background: url 0 0 no-repeat}
.tr2 {background: url 100% 0 no-repeat; padding:10px}
.clear2 {font-size: 1px; height: 1px}
#navmenu {
position: relative;
left: 16px;
top: 0px;
width: 712px;
height: 22px;
z-index: 2;
background: #99FF99;
text-align: center;
padding: 0px;
}
.signupfield {
float: none;
width:480px;
color:#000;
margin-top: 1em;
margin-right:1 em;
margin-bottom: 1em;
position: relative;
left: 75px;
background-color: #99FF99;
background-image: url(bl.gif);
background-repeat: no-repeat;
background-position: left bottom;
}
----------------------------------
Reviews page example is here: (CSS code below)
http://www.danieldicenso.20m.com/citybeams/reviewers.html
/* REVIEW PAGE CSS CODE */
body {font-size:12px; font-family:"trebuchet MS", verdana, arial, sans-serif; background: #CCCCCC; word-wrap:break-word;}
#wrapper {
text-align: left;
margin: 0px auto;
padding: 0px;
border:0;
width: 1000px;
background: #FFFFFF;
}
#header {
margin: 0 0 15px 0;
background: #ffffff;
}
#side-a {
float: left;
width: 50px;
}
#side-b {
float: right;
width: 200px;
}
#content {
float: left;
width: 750px;
}
#footer {
clear: both;
background: #ffffff;
}
.curvy2 {
position:relative;
width:250px;
color:#000;
margin-top: 1em;
margin-right: auto;
margin-bottom: 1em;
margin-left: auto;
background-color: #99FF99;
background-image: url(bl.gif);
background-repeat: no-repeat;
background-position: left bottom;
}
#ctl, #cbl, #ctr, #cbr {position:absolute; width:20px; height:20px; color:#327734; background:#fff; background-image:url(metalgreen2.jpg); overflow:hidden; font-style:normal; z-index:1;}
#ctl {top:0; left:0;}
#cbl {bottom:0; left:0;}
#ctr {top:0; right:0;}
#cbr {bottom:0; right:0;}
.curvy em b {position:absolute; font-size:150px; font-family:arial; color:#327834; line-height:40px; font-weight:normal;}
#ctl b {left:-8px;}
#ctr b {left:-25px;}
#cbl b {left:-8px; top:-17px;}
#cbr b {left:-25px; top:-17px;}
.curvy p {position:relative; z-index:100; padding:5px 10px;}
.bl {
width: 330px;
background-color: #99ff99;
background-image: url(bl.gif);
background-repeat: no-repeat;
background-position: 0 100%;
}
.br {background: url(br.gif) 100% 100% no-repeat}
.tl {background: url(tl.gif) 0 0 no-repeat}
.tr {background: url(tr.gif) 100% 0 no-repeat; padding:10px}
.clear {font-size: 1px; height: 1px}
.bl2 {
width: 330px;
background-color: #ffffff;
background-image: url;
background-repeat: no-repeat;
background-position: 0 100%;
}
.br2 {background: url100% 100% no-repeat}
.tl2 {background: url 0 0 no-repeat}
.tr2 {background: url 100% 0 no-repeat; padding:10px}
.clear2 {font-size: 1px; height: 1px}
#navmenu {
position: relative;
left: 16px;
top: 0px;
width: 712px;
height: 22px;
z-index: 2;
background: #99FF99;
text-align: center;
padding: 0px;
}
.signupfield {
position:relative;
width:480px;
color:#000;
margin-top: 1em;
margin-right: auto;
margin-bottom: 1em;
margin-left: -120px;
background-color: #99FF99;
background-image: url(bl.gif);
background-repeat: no-repeat;
background-position: left bottom;
}
body,td,th {
color: #000000;
}
a:link {
color: #003333;
}
a:visited {
color: #000066;
}
a:active {
color: #FF0000;
}
#selectionbar {
position: relative;
left: 0px;
top: 0px;
width: 750px;
height: 22px;
z-index: 2;
background: #ffffff;
padding: 0px;
}
#selectionbartwo {
position: relative;
left: 0px;
top: -10px;
width: 750px;
height: 22px;
z-index: 2;
background: #ffffff;
padding: 0px;
}
#selectionbarthree {
position: relative;
left: 0px;
top: -10px;
width: 750px;
height: 22px;
z-index: 2;
background: #ffffff;
padding: 0px;
}
#dividerline {
position: relative;
left: 0px;
top: -4px;
width: 750px;
height: 1px;
z-index: 2;
background: #ffffff;
padding: 0px;
}
#results {
position: relative;
left: 55px;
top: -14px;
width: 600px;
height: 1px;
z-index: 2;
background: #ffffff;
padding: 0px;
}
If default margins and padding are indeed your problem as Ryan so helpfully suggested, you can force every element to have the same base margin and padding with the following statement:
* {
margin: 0px;
padding: 0px;
}
Note that this will probably break your layout in the other browsers too, but at least they'll all be broken the exact same way.
IE7 has different defaults and behaviour for margin and padding than the other browsers. A quick viewing of the page in IE7 suggests that is likely where the majority of your problems are.
You might try using padding to offset navmenu instead of using position:relative and left.
Don't use
*{margin: 0px;padding: 0px;}
U dont want to rewrite your whole site for html elements who actually need the default value.
use css reset
Use xhtml and css valid code
And fix common bugs
You can force your IE8 to render pages like IE7 and check the layout yourself.
Read that: http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx
Use:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
but only for debug
To test how your page looks in IE7 without meta-tag tricks or similar, you can download a virtual sandboxed browser from here: http://www.xenocode.com/browsers/ Great for testing web applications.