473,698 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested divs need to be inline, not block

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 disappear, and if I try to define this
for just the div with the image, it does nothing.

Here's the code I'm using:

<div style="height: 19px; width: 100%;">
<div style="backgrou nd-color: #B5302B; width: 334px;"></div>
<div style="width: 19px;"><img src="images/innercorner.gif "></div>
<div style="backgrou nd-color: #B5302B; width: 100%;"></div>
</div>

Any help would be appreciated.

Thanks,
Aaron
Jul 20 '05 #1
3 7695
Aaron wrote:
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 disappear, and if I try to define
this for just the div with the image, it does nothing.

Here's the code I'm using:

<div style="height: 19px; width: 100%;">
<div style="backgrou nd-color: #B5302B; width: 334px;"></div>
<div style="width: 19px;"><img src="images/innercorner.gif "></div>
<div style="backgrou nd-color: #B5302B; width: 100%;"></div>
</div>


The problem here is that you are using generic containers to do something
other then contain something (and that width doesn't apply to non-replaced
inline elements).

I'd do something along the lines of:

<div style="backgrou nd-color: #B5302B; margin: 0; padding: 0;"><img
src="images/innercorner.gif " alt="??" style="margin-left: 334px;"></div>

--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #2
That helped alot, David...thanks! I have one more area I'm stumped...I have
the following code:

<div style="width: 100%;">
<div style="height: 800px; width: 339px; background: #B5302B
url(week01/images/innerright.gif) repeat-y right;"></div>
<h1>Heading text</h1></div>

I'm trying to get the heading text to show up to the right of the div
containing the y-tiling background image. Right now, the heading appears
below the div, since the div is a block element. But when I set the display
of the div to inline, it disappears. Is there simple way to achieve this?

Thanks,
Aaron

"David Dorward" <do*****@yahoo. com> wrote in message
news:c0******** ***********@new s.demon.co.uk.. .
Aaron wrote:
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 disappear, and if I try to define
this for just the div with the image, it does nothing.

Here's the code I'm using:

<div style="height: 19px; width: 100%;">
<div style="backgrou nd-color: #B5302B; width: 334px;"></div>
<div style="width: 19px;"><img src="images/innercorner.gif "></div>
<div style="backgrou nd-color: #B5302B; width: 100%;"></div>
</div>


The problem here is that you are using generic containers to do something
other then contain something (and that width doesn't apply to non-replaced
inline elements).

I'd do something along the lines of:

<div style="backgrou nd-color: #B5302B; margin: 0; padding: 0;"><img
src="images/innercorner.gif " alt="??" style="margin-left: 334px;"></div>

--
David Dorward <http://dorward.me.uk/>

Jul 20 '05 #3
Aaron wrote:
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 disappear, and if I try to define this
for just the div with the image, it does nothing.
I't 'display: inline' and you should put your CSS code outside the
elements ;-)

Here's the code I'm using:

<div style="height: 19px; width: 100%;">
<div style="backgrou nd-color: #B5302B; width: 334px;"></div>
<div style="width: 19px;"><img src="images/innercorner.gif "></div>
<div style="backgrou nd-color: #B5302B; width: 100%;"></div>
</div>

Any help would be appreciated.

Thanks,
Aaron

Jul 20 '05 #4

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

Similar topics

20
2862
by: Firas D. | last post by:
http://firasd.org/ The divs of the 'box' class seem to have the effect I want in IE (namely: consistent height and horizontal alignment along the set of divs), but it totally falls apart in Firebird, like the p's inside teh divs are independent of the div's properties... (looked okay until I applied "display: inline;") What would be the proper way (I'm assuming that Firebird is displaying the proper behaviour)?
30
2787
by: Adam Siler | last post by:
i want to display a series of inline, fixed-width DIVs that will wrap into columns - a table, basically. i can do it under Internet Explorer, but the same code under Netscape or Opera does not behave as expected. the DIVs "collapse" into small rectangles (i put a border around them so i could see), but their contents (some middle-aligned text) span the width of the page. if not for the borders that i added, it would appear that each DIV was...
9
4074
by: Dustin | last post by:
Here's what I am trying to do: (Names represent CSS classes.) I want to create a photo gallery. I want the entire gallery to be surrounded by a box named PhotoGallery. I want a fluid placement of the individual Items within PhotoGallery. An Item is a box that has two child boxes, PhotoBox and Caption. Photobox has an explicit width and height. PhotoBox contains an image whose dimensions may vary, but are constrained to be within...
4
10217
by: Aaron | last post by:
I have the following divs: <div style="background-image: url(images/house_01.jpg); width: 249px; height: 346px;"></div> <div style="background-image: url(images/house_02.jpg); width: 251px; height: 346px;"></div> Since by default, the display property is set to block, they show up on different lines. Since each div contains half of a complete background image, I need then to show up side-by-side. The thing is, when I set the
10
3830
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/dev/test.html I'd like to have the colored boxes appear on the same line as "Test" does. The div containing the colored boxes is defined as being inline, yet doesn't seem to be acting as an inline element. I suspect the floats in the images within the div may be contributing to the problem, but I don't know what to do about it if that's the case. Any ideas?
4
2369
by: txican | last post by:
the HTML is: ---------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html> <head> <title>foo</title> <style type="text/css"> <!-- ..b {
2
2325
by: Ben Wall | last post by:
I have a page with six or seven absolutely positioned DIV blocks ... they all contain form elements .. text boxes, buttons, etc. and they all reside within a containing "master" DIV. What I need to do is overlay all of the DIVs with a "pop-up" DIV to get some additional input; so, on a button click I am setting the visibility and the top/left coordinates to bring it into position ... but what's happening is that three elements underneath...
7
5434
by: massic80 | last post by:
Hi everybody! I'm making a page for an exam at uni. In two DIV blocks of it there should appear (and disappear) some "icons", due to XML messages, so I dunno how many of them should I can obtain; I want to show a small image, with its "icon name" under it, so I thought to use a DIV where I put a small image, a <br/and the icon name (and text-align:center as CSS). My page is fully liquid, so my DIVS may be resized, and I wanted them to be...
4
8406
by: Adam | last post by:
I have four roughly square DIVs, all the same height, which I need to line up horizontally across the page. What would be the best way to do this? At the moment I have a very botched solution where I have display:table-cell set on each of the DIVs. This works as far as lining them up is concerned, however to get any spacing between them the only thing I could do was to put some &nbsp; in between each one (margin had no effect). This...
0
9170
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
9031
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
8871
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...
1
6528
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
5862
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();...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.