473,383 Members | 1,855 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.

Need help with a css problem involving divs and background images

Hi,

I am trying to create a colored box using background images. I am able to do it easily using tables but doing it in divs is proving to be an issue. Moreover IE and Mozilla also seems to be showing diff representations for the same code piece..

Can somebody help me out on this!

The code is as shown below
[html]
<html>
<head>
<style>
.left_top {
background: #fff url(top_left_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.left_bottom {
background: #fff url(bottom_left_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.left_center {
background: #fff url(center_left_alertbox.gif) repeat-y 0px 0px;
width:15px;
height:1px;
padding:0; margin:0;
}
.right_top {
background: #fff url(top_right_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.right_bottom {
background: #fff url(bottom_right_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.right_center {
background: #fff url(center_right_alertbox.gif) repeat-y 0px 0px;
width:15px;
height:1px;
padding:0; margin:0;
}
.middle_top {
background: #fff url(top_midle_alertbox.gif) no-repeat 0px 0px;
width:442px;
height:15px;
padding:0; margin:0;
}
.middle_bottom {
background: #fff url(bottom_middle_alertbox.gif) no-repeat 0px 0px;
width:442px;
height:15px;
padding:0; margin:0;
}
.middle_center {
background-color: #FFCCCC;
padding:0; margin:0;
}
</style>
</head>
<body>

<P>Using tables</P>
<table width="472" style="padding:0; margin:0;" cellspacing="0" cellpadding="0">
<tr>
<td class="left_top"></td>
<td class="middle_top"></td>
<td class="right_top"></td>
</tr>
<tr>
<td class="left_center"></td>
<td class="middle_center">Hi how are u? Box comes fine if we uses tables!</td>
<td class="right_center"></td>
</tr>
<tr>
<td class="left_bottom"></td>
<td class="middle_bottom"></td>
<td class="right_bottom"></td>
</tr>
</table>

<p>Using divs</p>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="left_top"></div>
<div style="display:block; float:left; width:442px; padding:0;margin:0;" class="middle_top"></div>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="right_top"></div><br/>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="left_center"></div>
<div style="display:block; float:left; width:442px; padding:0;margin:0;" class="middle_center">Hi how are u? Can u help me with this please! This has been giving me some heart ache alrite!</div>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="right_center"></div><br/>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="left_bottom"></div>
<div style="display:block; float:left; width:442px; padding:0;margin:0;" class="middle_bottom"></div>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="right_bottom"></div>

</body>
</html>
[/html]

I have attached the screenshot of output and also required images for the html above.

The table code in the HTML works fine but the one using the divs does not.

Help please!!!

TIA,
Arup
Attached Images
File Type: gif untitled.GIF (14.6 KB, 183 views)
Attached Files
File Type: zip alert_box.zip (4.4 KB, 90 views)
May 21 '07 #1
7 2108
drhowarddrfine
7,435 Expert 4TB
You will never get IE to pretend it's a modern browser without a proper doctype. See the articles section for html/css. Use html4.01 strict. Then validate your html for your list of errors. (Your css is fine).
May 21 '07 #2
You will never get IE to pretend it's a modern browser without a proper doctype. See the articles section for html/css. Use html4.01 strict. Then validate your html for your list of errors. (Your css is fine).
Yes I agree. I added doctype and got it validated with W3C HTML and CSS validator but still it doesn't seem to have an iota of effect on the output :(

Find below the corrected html
[html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en-us">
<HEAD>
<title>Error box</title>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
.left_top {
background: #fff url(top_left_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.left_bottom {
background: #fff url(bottom_left_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.left_center {
background: #fff url(center_left_alertbox.gif) repeat-y 0px 0px;
width:15px;
height:1px;
padding:0; margin:0;
}
.right_top {
background: #fff url(top_right_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.right_bottom {
background: #fff url(bottom_right_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.right_center {
background: #fff url(center_right_alertbox.gif) repeat-y 0px 0px;
width:15px;
height:1px;
padding:0; margin:0;
}
.middle_top {
background: #fff url(top_midle_alertbox.gif) no-repeat 0px 0px;
width:442px;
height:15px;
padding:0; margin:0;
}
.middle_bottom {
background: #fff url(bottom_middle_alertbox.gif) no-repeat 0px 0px;
width:442px;
height:15px;
padding:0; margin:0;
}
.middle_center {
background-color: #FFCCCC;
padding:0; margin:0;
}
</style>
</HEAD>
<body>

<P>Using tables</P>
<table width="472" style="padding:0; margin:0;" cellspacing="0" cellpadding="0">
<tr>
<td class="left_top"></td>
<td class="middle_top"></td>
<td class="right_top"></td>
</tr>
<tr>
<td class="left_center"></td>
<td class="middle_center">Hi how are u? Can u help me with this please! This has been giving me some heart ache alrite!</td>
<td class="right_center"></td>
</tr>
<tr>
<td class="left_bottom"></td>
<td class="middle_bottom"></td>
<td class="right_bottom"></td>
</tr>
</table>

<p>Using divs</p>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="left_top"></div>
<div style="display:block; float:left; width:442px; padding:0;margin:0;" class="middle_top"></div>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="right_top"></div><br/>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="left_center"></div>
<div style="display:block; float:left; width:442px; padding:0;margin:0;" class="middle_center">Hi how are u? Can u help me with this please! This has been giving me some heart ache alrite!</div>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="right_center"></div><br/>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="left_bottom"></div>
<div style="display:block; float:left; width:442px; padding:0;margin:0;" class="middle_bottom"></div>
<div style="display:block; float:left; padding:0;margin:0; width:15px;" class="right_bottom"></div>

</body>
</html>[/html]
May 22 '07 #3
And its not just a problem with IE alone.. Mozilla also displays it in a weird manner..
May 22 '07 #4
drhowarddrfine
7,435 Expert 4TB
Your doctype still isn't right; it's incomplete and IE still goes into qurks. Also, new pages have no need for the transitional doctype. Always use strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

They look the same to me.
Attached Images
File Type: gif 2.gif (10.8 KB, 189 views)
May 22 '07 #5
Your doctype still isn't right; it's incomplete and IE still goes into qurks. Also, new pages have no need for the transitional doctype. Always use strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

They look the same to me.
hmm.. I made the doctype change but still don't see any change happening in my html. I am using IE ver 6 and Mozilla firefox ver 1.5.0.6.

Can you use the images tat I have attached and make it come the way tat it is in my screenshot of the page for the box done using tables. Your screenshot doesn't show the side elements but just the pink box.

The content inside the table will be dynamic in the sense that the box will expand vertically if more content is there.

Can you send me ur html files to arupfrancis@gmail.com or post it in ur next reply.
Then probably I can see where I am going wrong.

TIA
May 23 '07 #6
drhowarddrfine
7,435 Expert 4TB
Well, I screwed up and that's what I get for working too fast. I didn't notice the images. I'll look at this soon.
May 23 '07 #7
drhowarddrfine
7,435 Expert 4TB
So, really, this is a CSS Rounded Corners problem. To solve this, I would go to sites that talk about this as it's been solved in many ways. You can Google for CSS Rounded Corners or look at these links:

http://css-discuss.incutio.com/?page=RoundedCorners
http://virtuelvis.com/gallery/css/rounded/
http://www.456bereastreet.com/archive/200505/transparent_custom_corners_and_borders/
http://www.schillmania.com/content/projects/even-more-rounded-corners/
http://www.roundedcornr.com/
http://www.w3.org/Style/Examples/007/roundshadow.html
http://www.fireandknowledge.org/archives/2004/05/22/rounded-corners-without-images-part-1/
http://www.spiffycorners.com/
http://www.html.it/articoli/nifty/index.html
http://kalsey.com/2003/07/rounded_corners_in_css/
May 23 '07 #8

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

Similar topics

3
by: Aaron | last post by:
Hi, I'm trying to use style sheets instead of tables for layout, but I'm not sure on how to do something... I have a div (100% width) containing 3 other divs. Each needs to be lined up next to...
9
by: Werner Hempel | last post by:
Hello, I'm trying to do a simple three column layout, with two divs (#left and #right) floating left and right, and the #content-div with margins in between, and all three in a wrapper-div. The...
0
by: friendlycoder | last post by:
Hi there, How do you align DIVS next to each other? I have 3 images, each image is assocated in the style sheet as background image. I want the images to align to each other like this...
0
by: Jeb Hunter | last post by:
Well, how can I describe this succinctly? I have a page with DIVs that us background images to produce a border effect. It works perfectly well, but I want to make up (for now) 3 different...
1
by: kidelectric | last post by:
The issue I am having is that I would like to be able to drag-and-drop div elements that have rounded corners.* Since these elements will be dynamically created (including background color), I could...
1
by: cma6 | last post by:
I have a page which uses tables for layout http://www.vintagetextile.com/1920s_to_1930s.htm The checkerboard pattern is achieved with this markup: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML...
1
by: musaligari | last post by:
hi all, when i am using div tags, i am getting gaps between the divs. please refer the code which i have written. please find free to help me out. /******************* CSS...
1
by: donpro | last post by:
Hi, I'm creating a template paging sing pure CSS and all looks good except the footer which I am having problems with. 1) When I space out each of the FOUR DIVS at 25%, it wraps in IE. I...
4
by: pankajsingh5k | last post by:
Hi guys, i only know basic css mainly the formatting part.... i want to create a side panel for my website that looks like a small window that has a blue header and blue borders and slightly...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...

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.