473,545 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to line a box with thin border containing background image

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 image, thus creating a
kind of fancy border. What would be the best practice to do that? I
thought that if the containor box was relative and the contained boxes
were absolute, that would work because the absolute boxes would be
measured againsted the containing box. But, it seems that each
subsequent box is measured off of the preceeding box, not the
containing one.
Here's what I get:
(the containing box, called calendar, is invisible)
||============= =========
||
||
||
|| <-----line should be
here to make a box
||
||
||
||
||
||============= =========||
||
||
|| <------ this should
be up above to make a box.
||
||
||
||
||
||
Here's the code:
HTML:
<div id="calendar">
<div id="top-border"/>
<div id="left-border"/>
<div id="bottom-border"/>
<div id="right-border"/>
</div>
CSS:
#calendar {
width: 1000px;
height: 887px;
margin-left: auto;
margin-right: auto;
margin: 0em;
padding: 0em;
position: relative;
border: 1px solid;
}
#top-border {
width: 100%;
background-image: url(images/bg_top.gif);
background-repeat: repeat-x;
height: 7px;
position: absolute;
top: 0em;
left: 0em;

}
#left-border {
background-image: url(images/bg_left.gif);
height: 887px;
width: 8px;
background-repeat: repeat-y;
position: absolute;
left: 0px;
top: 0px;
}
#right-border {
background-image: url(images/bg_right.gif);
height: 887px;
width: 8px;
background-repeat: repeat-y;
position: absolute;
right: 0px;
top: 0px;
}
#bottom-border {
width: 1000px;
background-image: url(images/bg_bottom.gif);
background-repeat: repeat-x;
height: 7px;
position: absolute;
bottom: 0px;
left: 0px;
}
Thanks in advance for your help.
Skeeve

Mar 16 '06 #1
2 4538
Just to follow up because I found something interesting. I had my divs
in my html document coded like this:

<div id="top-border"/>

As I'm really a java programmer, when I deal with xml (which xhtml
actually is), it's usually revolving around data processing (dom or
xslt), where there is no difference between <node/> and <node></node>.
But, aparently, there *is* when it comes to browsers and css. When I
changed it to

<div id="top-border"></div>

the results were much better (not perfect). Now, I still have a
question, but it's different now.

I've changed the top and bottom borders to:
#top-border {
width: 100%;
background-image: url(images/bg_top.gif);
background-repeat: repeat-x;
position: absolute;
top: 0em;
left: 0em;}

The bottom border has different coordinates and gif. Otherwise,
theyr'e the same.

The problem is that they're too tall.

Should be like:
-----------------------------------------------
|xxxxxxxxxxxxxx xxxxxxxxxxxx| <-- height of 7px to match the gif
-----------------------------------------------

Instead it's like:
-----------------------------------------------
|xxxxxxxxxxxxxx xxxxxxxxxxxx| <-- gif is 7px but
| | <-- the box extends
beyond that
-----------------------------------------------

I changed the div's height to be smaller, and then just removed the
height property, but it makes no difference. The graphic that is
repeated along the x axis is only 7 px, but the height of the box is
closer to double that, and I can't seem to shrink it to 7px. I suspect
that it thinks there some character in there that is forcing the
height, but I'm not certain.

Thoughts? And, I'm still interested in why the form of the div tag
really makes a difference, so if anyone has any thoughts...

Thanks again.
Skeeve

Mar 16 '06 #2
Furthermore, I just found that it's perfect in FF, but in IE, this
problem exists.

Mar 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2681
by: Michael Winter | last post by:
I have the familiar 'thumbnail' scenario. I want to place a small border around the image when the cursor hovers above it. I use a 1 pixel, solid border around the image that changes between normal and hover. This works fine in Internet Explorer, but in Opera 7.22, the bottom border is 3 pixels thick. If I expand all borders to 3 pixels,...
2
40630
by: Lars | last post by:
Hello all, Having googled around without any luck, I resort to posting my own question: Is there any way I can make a <div> adjust to the width of a contained image and line break any long text instead of expanding the <div>? The background of the problem is that I use a nested <div> to contain an image and its caption. I float the...
6
2451
by: Alan J. Flavell | last post by:
The page under discussion was http://ppewww.ph.gla.ac.uk/~flavell/www/html-smac.html An email correspondent referred to the link text "screenshot" in part 2, which in his case was coming at the right-hand end of a line. As soon as he hovered over it in MSIE, it sprang to the next line - making it impossible to use it, obviously. This...
12
1836
by: scott | last post by:
Is there a way to prevent IE from forcing a line break? Below in LISTING 2, you notice the table background image extention of '.jpg' begins a new line, instead of staying on the same line as it's file name. Same happens with my javascript onclick event, IE forces a line break and breaks my code. In my asp code, you notice I'm inserting line...
3
1832
by: Pierre Jelenc | last post by:
I am trying to put a graphical border along the top, left, and right edges of a page. For left and top I have an oversize GIF with the proper graphics used as the background-image of either the body or an inside div. For the right, I tried a floated div of height: 100% and with the complementary right border as the background-image, and...
2
2459
by: Daniel Kaplan | last post by:
First off thanks to those that helped me with my background image on a form, topic... "Manipulating a forms input border" I finally opted for spilting my image up into a table, and it pretty much stays the same even when Text is changed. Fortunatly it's a simple image, therefore it's ok. I have another question, I would like to...
0
1529
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 image, thus creating a kind of fancy border. What would be the best practice to do that? I thought that if the containor box was relative and the...
1
3872
by: mudasserrafiq | last post by:
I am using following asp file default.asp <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> <META content="0 Days" name=revisit-after> <META content=info@siderinternational.com name=email> <META content="Omer Safdar" name=author> <META...
0
2644
by: Berlin Brown | last post by:
I have two DIVs on the same line, a left navigation frame and the right content. I want both of those items on the same line. Lets say the left nav content is 140pixels and the right content is 1400 pixels. In internet explorer, if I put these together the right content is pushed below the left nav on a separate row. I want them on the...
0
7396
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7751
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1874
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
700
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.