Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 16th, 2006, 04:35 PM
Skeeve
Guest
 
Posts: n/a
Default 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

  #2  
Old March 16th, 2006, 05:25 PM
Skeeve
Guest
 
Posts: n/a
Default Re: How to line a box with thin border containing background image

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

  #3  
Old March 16th, 2006, 05:55 PM
Skeeve
Guest
 
Posts: n/a
Default Re: How to line a box with thin border containing background image

Furthermore, I just found that it's perfect in FF, but in IE, this
problem exists.

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles