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 background-repeat problem

Featured Replies

I have a page with a wrapper so that I can centre the main content etc. I wanted to have a background image to cover the area outside of the wrapper which works fine, but it will not tile. I have tried all the variations. This is my CSS:

 

body	{
background-color:#FFF;
font-family:Arial, Helvetica, sans-serif;
background-image:  url(../images/Background.jpg);
background-repeat:repeat;	}

 

Is my CSS incorrect? If not, is there any other area of html or css which could be having an impact?

Edited by Renaissance-Design
Please use the code button or tags to format your code.

SNIP!!

Edited by Bomb

  • Author

Short answer: yup. For example, if all the content is floated but not cleared, the body may not be long enough for the image to repeat.

 

Thanks for getting back to me and for putting my code into a box - forgot to do that, sorry.

 

I don't understand what you mean re content etc. This is the CSS for my container (I hope I've done it correctly this time):

 

#outer				{
width:840px;
margin:0 auto;
background-color:#FFF;	}

#wrapper			{
width:800px;
margin:0 auto;
background-color:#FFF;	}

#logo				{
margin:15px 0;
float:left;	}

#group-title		{
margin:20px 0 15px 5px;
float:left;	}

#topnav				{
clear:both;	}

#main-image			{
margin: 30px 0 0 0;
padding: 10px 0 0 0;	}

#content			{
width:500px;
float:left;	}

#news				{
width:259px;
float:right;	}

#footer				{
clear:both;
border-top:1px #ccc solid;
padding:10px 0 3px 0;	}


/* Miscellaneous */

.footer-text		{
font-size:12px;
text-align:center;
}

Try:

 

body {
border: 1px solid red;
}

 

to see what the calculated height for your body element is. Floated elements have zero height in the document flow and containers take their height from their content, so if a container only contains floats its height will be zero. If it contains floats and non-floated elements, its height will be equal to the non-floated content. See this JSFiddle.

Edited by Renaissance-Design

  • Author

Thanks again. I added the border css and my page displays with a red box surrounding it, which spans the height of my page and the width of my screen into the background area.

 

I've read the jsfiddle link, but am a little uncertain as to what I need to do to rectify the problem.

  • 4 weeks later...
  • Author

D'you have it online somewhere I could take a look at it?

Hi, I've decided against having a background image, but am still having one or two problems with the display in IE6 and 7 which some of the potential users may have.

 

The main image should only be a couple of mm below the menu bar, but drops by about 1/2" in IE 6/7. Not sure if it's linked to the float problem. I've loaded the test site here: www.gomeril.co.uk.

 

I'd appreciate your comments.

 

Thanks.

Edited by LuluG

  • Author

Is it dropping by the total height of your dropdown menus?

 

 

I've just checked it in IE7 and the drop quite possibly equates to the height of the top level menu's.

 

It's a spry menu bar, not sure if that helps (or hinders!)?

 

OK, progress of sorts! I went back to your link (jsFiddle) and read through it again and suddenly it all made sense! There was just a flat line across the top of the menu bar. I added your cleared statement to index.html and my templates and have a box around the spry menu. I removed a margin I had previously set to force the image away from the menu.

 

However, the cleared statement makes no difference to my Contact page. Would you be able to have a look at it for me to see what is happening?

Edited by LuluG

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.