Need Help with a Background Image

Discussion in 'CSS' started by jawinn, Nov 5, 2006.

  1. #1
    How could I add a background image to the left column in the code below?

    
    body	{	font:normal 11px Verdana, Arial, Helvetica, sans-serif; background-color:#000; margin:0px; padding:0px; margin-bottom:15px; }
    a	{	color:#660033; }
    a img	{	border:0px; }
    .canvas	{	width:770px; background-color:#eee; margin:auto; }
    .header	{	height:76px; background-color:#660033; text-align:center; padding:10px 0px; }
    .bar	{	height:2px; background-color:#eee; font-size:1px; border-top:2px solid #000; border-bottom:2px solid #000; }
    .main	{	background-color:#e5e5e5; height:100%; }
    .lcol	{	float:left; width:170px; }
    .rcol	{	float:right; width:550px; background-color:#fff; height:100%; padding-left:20px; padding-right:20px; padding-top:40px; }
    .footer	{	font-size:10px; text-align:center; line-height:25px; color:#666; background-color:#000; clear:both; }
    .footer a	{	color:#fff; text-decoration:none; }
    .footer a:hoverc	{	text-decoration:underline; }
    .vmenu	{	background-color:#fff; line-height:25px; color:#666; font-weight:bold; padding-left:15px; border-bottom:1px solid #e5e5e5; }
    .madd	{	text-align:center; margin:20px 0px; }
    .mblock a	{	text-decoration:none; color:#666; }
    Code (markup):
    Thanks,
     
    jawinn, Nov 5, 2006 IP
  2. jascele

    jascele Peon

    Messages:
    48
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    .lcol { float:left; width:170px; background: url('image.jpg');}
     
    jascele, Nov 5, 2006 IP
    jawinn likes this.
  3. jawinn

    jawinn Active Member

    Messages:
    1,024
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    88
    #3
    Awesome, that worked great. How can I make it so the image does not repeat?
     
    jawinn, Nov 5, 2006 IP
  4. jascele

    jascele Peon

    Messages:
    48
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    background-repeat: no-repeat;

    :)
     
    jascele, Nov 5, 2006 IP
  5. Colleen

    Colleen Illustrious Member

    Messages:
    6,777
    Likes Received:
    725
    Best Answers:
    1
    Trophy Points:
    430
    #5
    Or use shorthand css:
    background: url(image.jpg) no-repeat;
     
    Colleen, Nov 6, 2006 IP
  6. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #6
    Is there any real advantage to shorthand? I mean, if your stylesheet were a mile long, I see how it could be useful, but in everyday use is it essentially the same?
     
    dp-user-1, Nov 6, 2006 IP
  7. kh7

    kh7 Peon

    Messages:
    2,715
    Likes Received:
    109
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Shorter CSS-stylesheets load faster. Since your visitors are going to download the whole CSS-file for every page they see, it needs to be as light as you can make it. Hence shorthand is a very good idea.
     
    kh7, Nov 6, 2006 IP
  8. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Most browsers will cache a stylesheet so users don't need to download it more than once.

    Obviously its still preferable to make it as short as possible. :)
     
    mad4, Nov 6, 2006 IP
  9. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #9
    A prime reason for shorthand notation is ease of human readability. The computer doesn't care, but when you're trying to alter or debug the css, good formatting and sensible rulesets make a huge difference in the time and effort it takes.

    It is a Good Thing® to write your code as if the maintainer is a violent psychotic who knows where you live.

    cheers,

    gary
     
    kk5st, Nov 6, 2006 IP
  10. Colleen

    Colleen Illustrious Member

    Messages:
    6,777
    Likes Received:
    725
    Best Answers:
    1
    Trophy Points:
    430
    #10
    I code by hand, faster to type it out.
     
    Colleen, Nov 6, 2006 IP