Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

css div background image

Featured Replies

hi, i have this problem with a web design im doing for my new website,

 

i have an image that i want to apply to a div which is my container div that holds all my other divs, but not apply a height so that when the content changes on each page the image will just shorten n expand on its own( its a gradient image nothing special), but when i apply no height to the container div, the image doesnt show, even if i try a colour it doesnt work, what im wanting is for the container div to display the image with no height property

 

can you have a look at the css and html and help me out it would be much appreciated

 

here is the link http://ellensalterations.co.uk/david2/index.html i have supplyed the link because to paste the code would have made this post even longer.

 

any help would be much appreciated

 

Collie

Odd that the 'black' is not working... Cant spot anything obvious.

 

With the background image property, it normally works better like this:

 

background-image:url('images/content2.png');

 

Note the 'single quotes'...

 

Also, maybe try:

 

background-position:top; 

 

??

 

HTH :D

  • Author

i tried that, didnt work, i added both the "background-position:top" and the single quotes and nothing happened :S, so annoying been trying to fix it for a while, im not wanting to have a different container for each page, that will just make the code even more a mess than it is

</div<!-- end of header -->

 

That div tag is missing the closing '>'

 

Then try the quotes etc again..

 

HTH

Edited by greyhat

  • Author

i never even notice the missing ">" i fixed that n kept the quotes in and its still not working, this is starting to do my head in lol, i appreciated all the help man :)

Yh did u try the css fix?? U cant have 3 values in that property.. it should be 0px auto... To center the div...

* also, this is wrong:

 

margin: 30px auto 10px;

 

 

Is that not 30px top, auto left & right, 10px bottom ?

Is that not 30px top, auto left & right, 10px bottom ?

 

... mayb i am wrong.. sorry i just never used it that way b4.

  • Author

i tried changing it to "margin:0 auto;" & "margin:0px auto;" still not working :( :(

You had a script tag missing and I've changed it to the latest jquery lib on google

 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
   <script type="text/javascript" src="http://ellensalterations.co.uk/david2/scripts/jquery.nivo.slider.pack.js"></script>
<script type="text/javascript">
   $(window).load(function() {
       $('#slider').nivoSlider();
   });
   </script>

  • Author

You had a script tag missing and I've changed it to the latest jquery lib on google

 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
   <script type="text/javascript" src="http://ellensalterations.co.uk/david2/scripts/jquery.nivo.slider.pack.js"></script>
<script type="text/javascript">
   $(window).load(function() {
       $('#slider').nivoSlider();
   });
   </script>

 

i copyed that code into mine, re-uploaded it to the server, and its still not working, this is so annoying cause i like the design, but its looking like i wont be able to :(

Just add the overflow property to your container div man.

 

#container {

overflow: hidden;

}

 

You can also add a clearfixhack if you need visible overflow.

You'll need another container outside of your current container:

 

<div id="container-main">

 <div id="container">

    All your content

 </div>

</div>

 

CSS:

 

#container-main{
margin: 0 auto;
 width: 900px;
} 

#container {
 background-color: black;
 background-image: url("images/content2.png");
 background-repeat: repeat;
 border-radius: 5px 5px 5px 5px;
 box-shadow: 3px 3px 10px #000000;
float: left;
}

 

Make sure you put the float: left on #container

 

no heights needed :D

  • Author

thanx everyone for your help and @pedro and @ i-am-css both what use said worked perfect, thanx alot :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.