Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Background Image In Css?

CSS

  • Please log in to reply
2 replies to this topic

#1 simonhaykin

simonhaykin

    CC Lurker

  • New Member
  • Pip
  • 3 posts
  • Programming Language:C, Java, C++
  • Learning:JavaScript

Posted 24 May 2012 - 12:26 AM

Alright my exact question is how do I take an image off my hard drive and put it as a background in CSS ?
also I know how to do this with a url I mean specifically taking it from C\drive\libraries\photos
  • 0

#2 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 24 May 2012 - 06:58 AM

In your CSS: (Obviously replace "element" with the element to apply the background image.)
element
{
    background-image:url('path/to/image.jpg');
}
Make sure the contents of the element are large enough to reveal the entire dimensions of the picture, or set its height and width CSS properties. (The element won't be automatically sized to the dimensions of the picture, like the case with an img tag.)
  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1310 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 24 May 2012 - 07:52 AM

<div style="background: url('mywebsite.com/picture1.jpg'); background-size: 100% 100%;"> 

Hello World! 

</div>

  • 0
Regards,
RR





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download