473,383 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Border affecting background repeat

KeredDrahcir
426 256MB
I've got a really wierd problem. I've got some nested DIVs which I'm trying to give background to. I've got the top image, bottom image and a repeating middle image to cater for different div using the same class having differnet heights.

When I put it together I get a large gap between the top, the middle and the bottom. If I put a border round it, it disappears. It doesn't make sense to me.
Expand|Select|Wrap|Line Numbers
  1. .main{
  2.     background-color:#ffffff;
  3.     border: 0 solid #ffffff;
  4.     color: #000000;
  5.     background: #ffffff url(bottom image) no-repeat center bottom;
  6.     margin: 0 0 5px;
  7.     padding: 0 0 100px;
  8. }
  9.  
  10. .main div{
  11.     padding: 0;
  12.     margin: 0;
  13. }
  14.  
  15. .main div div{
  16.     background: #ffffff url(middle image) repeat-y center top;
  17.     padding: 0 15px;
  18.     margin: 0;
  19. }
  20.  
  21. .main h3{
  22.     background:#ffffff url(top image) no-repeat center top;
  23.     color: #000000;
  24.     border: 0;
  25.     padding: 35px 15px 0;
  26.     height:38px;
  27.     margin: 0;
  28. }
Expand|Select|Wrap|Line Numbers
  1. <div class="main">
  2.     <div>
  3.         <h3>Title</h3>
  4.         <div><p>Content</p></div>
  5.     </div>
  6. </div>
If I add a one pixel border to .main div div it fixes the problem expect I don't want the border.
The only thing that changes is that the top and bottom reamin where they are but the background of the middle section repeats further at the top on bottom to meet the other two sections when I add the border.


This is best example I can give below.

Without border
Expand|Select|Wrap|Line Numbers
  1. +--------------------------------+
  2. | Title                          |
  3. +--------------------------------+
  4.  
  5. +--------------------------------+
  6. |                                |
  7. | Content                        |
  8. |                                |
  9. +--------------------------------+
  10.  
  11. +--------------------------------+
  12. |                                |
  13. +--------------------------------+
  14.  

With border
Expand|Select|Wrap|Line Numbers
  1. +--------------------------------+
  2. | Title                          |
  3. +--------------------------------+
  4. |                                |
  5. |                                |
  6. | Content                        |
  7. |                                |
  8. |                                |
  9. +--------------------------------+
  10. |                                |
  11. +--------------------------------+
Images are attached.

Please help becuase I would pulling my hair our if I had any.
Attached Images
File Type: jpg no-border.jpg (5.7 KB, 240 views)
File Type: jpg border.jpg (7.1 KB, 165 views)
Aug 17 '12 #1

✓ answered by KeredDrahcir

overflow:hidden solves it.

5 2163
Claus Mygind
571 512MB
did you notice this line in your code?

.main div div{

did you really mean a double "div"

May not solve your problem but it is a start
Aug 21 '12 #2
KeredDrahcir
426 256MB
Yes I did plan to have a division nested like that. The HTML shows that I'm using an extra division for the content the keep it seperate from the header.
Aug 21 '12 #3
KeredDrahcir
426 256MB
I seem to have fixed the problem but I can't remember how and now I've got it again on a different kind division. Again it only works when I include a border which is unacceptable. Can anyone help?
Sep 4 '12 #4
KeredDrahcir
426 256MB
Look at the box model, when the border is absent, it is treated the padding as a margin. Does that help narrow down the problem?
Sep 4 '12 #5
KeredDrahcir
426 256MB
overflow:hidden solves it.
Sep 4 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: debugger | last post by:
Hi, background-repeat: repeat-x works fine in IE and FF and as expected, produces something like ............ hello ............
34
by: The Good Son | last post by:
I'm trying to get my head around a problem that has me baffled. The following element: #wrapper {border:1px solid #000;background:#fff;} Renders as expected when using this DTD: ...
4
by: Susan | last post by:
This code should repeat a gif that measures 545-pixels wide by 18 pixels high along the left edge of the division, but it doesn't show up at all. Here's the definition of the div in the...
2
by: debugger | last post by:
background-repeat: repeat-x works fine in IE and FF and as expected, produces something like ............ hello ............ On Safari, the output is not what is desired....
0
by: Skeeve | last post by:
Hi there, I'm trying to create a containing box (relative position), and within it, I'm trying to line that box with four (top, right, left, bottom) thin boxes that contain a repeated background...
2
by: Skeeve | last post by:
Hi there, I'm trying to create a containing box (relative position), and within it, I'm trying to line that box with four (top, right, left, bottom) thin boxes that contain a repeated background...
3
by: jacksoncn | last post by:
Hey everyone, I am havin a problem here, maybe someone could lend me their mind for a second. Here it is: I am using a repeat background on a y axis. When I am testing the file from my...
2
XedinUnknown
by: XedinUnknown | last post by:
Hi! I am new to this forum, but not new to web design and programming. Nevertheless, I have never tried to use PNG so extensively in my pages. here's the problem. First, I have found that the...
7
by: cabman | last post by:
I'm having trouble with a page and getting the background image to repeat itself on the y-axis. Here is a sample of the code: div.main { background-image: url(backround_image.gif);...
1
JnrJnr
by: JnrJnr | last post by:
Hi guys and girls. How can I set a <div>'s background-repeat while using position: absolute; without having to "have" to use width: px;. Is there any way? pls help #header { position: absolute;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.