473,401 Members | 2,139 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,401 software developers and data experts.

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 4529
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:
-----------------------------------------------
|xxxxxxxxxxxxxxxxxxxxxxxxxx| <-- height of 7px to match the gif
-----------------------------------------------

Instead it's like:
-----------------------------------------------
|xxxxxxxxxxxxxxxxxxxxxxxxxx| <-- 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
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...
2
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...
6
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...
12
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...
3
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...
2
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...
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...
1
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.