473,769 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with a css problem involving divs and background images

4 New Member
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_al ertbox.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_a lertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.right_bottom {
background: #fff url(bottom_righ t_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.right_center {
background: #fff url(center_righ t_alertbox.gif) repeat-y 0px 0px;
width:15px;
height:1px;
padding:0; margin:0;
}
.middle_top {
background: #fff url(top_midle_a lertbox.gif) no-repeat 0px 0px;
width:442px;
height:15px;
padding:0; margin:0;
}
.middle_bottom {
background: #fff url(bottom_midd le_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_t op"></td>
<td class="right_to p"></td>
</tr>
<tr>
<td class="left_cen ter"></td>
<td class="middle_c enter">Hi how are u? Box comes fine if we uses tables!</td>
<td class="right_ce nter"></td>
</tr>
<tr>
<td class="left_bot tom"></td>
<td class="middle_b ottom"></td>
<td class="right_bo ttom"></td>
</tr>
</table>

<p>Using divs</p>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="left_top "></div>
<div style="display: block; float:left; width:442px; padding:0;margi n:0;" class="middle_t op"></div>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="right_to p"></div><br/>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="left_cen ter"></div>
<div style="display: block; float:left; width:442px; padding:0;margi n:0;" class="middle_c enter">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;margi n:0; width:15px;" class="right_ce nter"></div><br/>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="left_bot tom"></div>
<div style="display: block; float:left; width:442px; padding:0;margi n:0;" class="middle_b ottom"></div>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="right_bo ttom"></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, 187 views)
Attached Files
File Type: zip alert_box.zip (4.4 KB, 90 views)
May 21 '07 #1
7 2126
drhowarddrfine
7,435 Recognized Expert Expert
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
arupfrancis
4 New Member
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_al ertbox.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_a lertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.right_bottom {
background: #fff url(bottom_righ t_alertbox.gif) no-repeat 0px 0px;
width:15px;
height:15px;
padding:0; margin:0;
}
.right_center {
background: #fff url(center_righ t_alertbox.gif) repeat-y 0px 0px;
width:15px;
height:1px;
padding:0; margin:0;
}
.middle_top {
background: #fff url(top_midle_a lertbox.gif) no-repeat 0px 0px;
width:442px;
height:15px;
padding:0; margin:0;
}
.middle_bottom {
background: #fff url(bottom_midd le_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_t op"></td>
<td class="right_to p"></td>
</tr>
<tr>
<td class="left_cen ter"></td>
<td class="middle_c enter">Hi how are u? Can u help me with this please! This has been giving me some heart ache alrite!</td>
<td class="right_ce nter"></td>
</tr>
<tr>
<td class="left_bot tom"></td>
<td class="middle_b ottom"></td>
<td class="right_bo ttom"></td>
</tr>
</table>

<p>Using divs</p>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="left_top "></div>
<div style="display: block; float:left; width:442px; padding:0;margi n:0;" class="middle_t op"></div>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="right_to p"></div><br/>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="left_cen ter"></div>
<div style="display: block; float:left; width:442px; padding:0;margi n:0;" class="middle_c enter">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;margi n:0; width:15px;" class="right_ce nter"></div><br/>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="left_bot tom"></div>
<div style="display: block; float:left; width:442px; padding:0;margi n:0;" class="middle_b ottom"></div>
<div style="display: block; float:left; padding:0;margi n:0; width:15px;" class="right_bo ttom"></div>

</body>
</html>[/html]
May 22 '07 #3
arupfrancis
4 New Member
And its not just a problem with IE alone.. Mozilla also displays it in a weird manner..
May 22 '07 #4
drhowarddrfine
7,435 Recognized Expert Expert
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
arupfrancis
4 New Member
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@gma il.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 Recognized Expert Expert
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 Recognized Expert Expert
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=RoundedCo rners
http://virtuelvis.com/gallery/css/rounded/
http://www.456bereastr eet.com/archive/200505/transparent_cus tom_corners_and _borders/
http://www.schillmania .com/content/projects/even-more-rounded-corners/
http://www.roundedcorn r.com/
http://www.w3.org/Style/Examples/007/roundshadow.htm l
http://www.fireandknow ledge.org/archives/2004/05/22/rounded-corners-without-images-part-1/
http://www.spiffycorne rs.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
7699
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 one another inside the first div. Whenever I nest these divs inside the first, it always treats each of them like a block element and puts them on the next line down. If I try to define 'block: inline' for each of them, the ones without images...
9
1504
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 goal is to get equal height columns (with #content having another background-color than the two other divs). The two divs on the sides and the wrapper get the same background-color #222, and the content-div gets #555. All works fine, as long as...
0
4952
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 example http://www.btinternet.com/~lee_friend/layers/layerexample.jpg
0
2076
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 border/background effects. Rather than duplicate the entire chunk of CSS 3 times, I thought "Gee, I should only have to specify the 3 backgrounds (all the other placement directives would be identical). However I must not be correctly specifying the...
1
2577
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 not use the "standard" rounded corner method of sliced images for the corners (since that would only allow a certain color to match) I tried using a corner-rounding js tool from http://openrico.org, but it failed miserably (in both IE and Opera) ...
1
2561
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 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>1920s to 1930s high-style Vintage Clothing at Vintage Textile</title>
1
1512
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 ***************************/ body{ margin:0px; width:100%;
1
2084
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 hacked it by changing to 24% but don;t know why. 2) I can't get the right border to extend down to the bottom border (both IE and Firefox).
4
5022
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 curved bottam border...i did this by making images and setting them as backbround images fo the respective divs here my code <div id="docket">
0
9590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
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
10051
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
9866
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
8879
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...
0
6675
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3968
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
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.