473,809 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I get the image to repeat the correct height?

I have three div blocks defined like this:

#left1
{
float: left;
background-color: white;
width: 184px;
margin-right: 4px;
text-align: left;
}

#left2
{
float: left;
background: url(images/barrav.gif) repeat;
width: 23px;
}

#left3
{
float: left;
background-color: white;
width: 573px;
margin-left: 4px;
}

The idea is to have the blocks displayed side by side. I do not know
the height of left1 and left3, but I want the image in left2 to be
repeated for the max height of left1 and left3. If I set the height in
left2 it will either be too short or too long.

Kind regards,

Jan Nordgreen
Jun 27 '08 #1
2 1233
SAM
damezumari a écrit :
I have three div blocks defined like this:

#left1
{
float: left;
background-color: white;
width: 184px;
margin-right: 4px;
text-align: left;
}

#left2
{
float: left;
background: url(images/barrav.gif) repeat;
width: 23px;
}

#left3
{
float: left;
background-color: white;
width: 573px;
margin-left: 4px;
}

The idea is to have the blocks displayed side by side. I do not know
the height of left1 and left3, but I want the image in left2 to be
repeated for the max height of left1 and left3. If I set the height in
left2 it will either be too short or too long.

<script type="text/javascript">
function $(id) { return document.getEle mentById(id); }
function maxHeightDivs(d ivs) {
divs = divs.split(',') ;
var H = 0, ok=false;
for(var i=0; i<divs.length; i++)
if($(divs[i]) &&
$(divs[i]).offsetHeight &&
$(divs[i]).offsetHeight> H ) {
H = $(divs[i]).offsetHeight;
ok = true;
}
if(ok) {
for(var i=0; i<divs.length; i++) $(divs[i]).style.height = H+'px';
}
else alert('this script is out :-(');
}
window.onload = function() {
maxHeightDivs(' left1,left2,lef t3');
}
</script>

Variante :

<script type="text/javascript">
function $(id) { return document.getEle mentById(id); }
function maxHeightDivs() {
var H = 0, ok=false;
for(var i=0; i<arguments.len gth; i++)
if($(arguments[i]) &&
$(arguments[i]).offsetHeight &&
$(arguments[i]).offsetHeight> H ) {
H = $(arguments[i]).offsetHeight;
ok = true;
}
if(ok) {
for(var i=0; i<arguments.len gth; i++)
$(arguments[i]).style.height = H+'px';
}
else alert('this script is out :-(');
}
window.onload = function() {
maxHeightDivs(' left1', 'left2', 'left3');
}
</script>
not tested with IE

--
sm
Jun 27 '08 #2
Thank you!

I put your code just before </bodyand it worked like a charm!

Kind regards,

Jan Nordgreen
Jun 27 '08 #3

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

Similar topics

2
10482
by: Markus Mohr | last post by:
Hi, everyone, I have a special problem: For every monitor resolution in 200 pixel steps from 800 to 1600 pixels I have an image to be shown as centered background-image. Those images all have the same name and reside in the following physical path structure:
1
6233
by: tlyoung99 | last post by:
I have been working on this issue and can not seem to make any headway. Everything is beginning to run together. Any help would be greatly appreciated. Basically, my page looks just as I want it to in FireFox, but I can not get IE to repeat my images vertically. I need a background image to tile vertically so that it is the same height as the main column of the page. I am using CSS and tables for the layout. I should have made the jump, but...
0
1544
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 contained boxes were absolute, that would work because the absolute boxes would be measured...
2
4554
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 contained boxes were absolute, that would work because the absolute boxes would be measured...
3
27221
by: KNDesign | last post by:
I've set a background image to repeat-y and at 100% height. It appears fine when I open the window, but when I resize to a smaller height so that I must scroll down to see the rest, the background image is suddenly gone from the bottom. #background { position: absolute; top: 0px; bottom: 0px; left: 50%;
2
3197
by: darkzone | last post by:
Looked almost ok in my editor but not so good in fire fox. I was going for a layout that was elastic some what. A header with one image repeating 100%, an there image slightly to the left also in the header, a container a 20% wide box for a list, two 80% wide boxes for content, a footer with the same image set up to end it. It was looking almost there for white but the footer image could now be viewed. ?= <!DOCTYPE HTML PUBLIC...
1
3131
by: rirby2 | last post by:
Hi everyone, I'm currently having a rendering problem in IE7 (haven't even tried the lower IEs yet), vs. what I see in FF2. The simplified site can be found at solerasd.com . (There are more image elements that belong in the list but I've only posted 2 since it replicates the problem and minimizes the code to read. In FF, you should see a logo with two images (currently not HREF's) of the same size below it, and a copyright statement below...
0
1914
by: tom59593 | last post by:
Hi there. I have been attempting (for a few days on end, sadly) to get a navigation section of my new site to work. Granted, this is the first time I've ever written CSS...although I had PLENTY of practice using tables...tee hee. Anyways, this should be EXTREMELY simple...as I want NO rollovers, no fancy hovers, no current-page differences...I just want the navigation bar image to be "click-able" where the words are. You can see the...
2
14079
by: thephatp | last post by:
I'm having a problem with IE rendering correctly. I'm experimenting with using all div's in my pages now, and I'm not very familiar with the quirks of IE. I have created a sample page, and I'm really confused as to what is going on in IE. FF renders the page exactly as I expect. IE renders the page with everything in the correct location, but it seems to double the background image for a sub-div section that is moved up using a negative...
2
4097
by: studentofknowledge | last post by:
For some unknown reason ie is placing images I have in a div in a weird way. One image is overlapping another but this problem is not occuring in mozilla. I have looked at my code over and over again but cant seem to find out what the problem is. I think this could be fixed with a i.e hack??? please advise the problem of the overlapping image is occuring in imagerow2 div on line 56. please see my code below here is my html <!DOCTYPE...
0
9601
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10115
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7660
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3014
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.