Stef's Coding Community

Text in Neighboring Div's too close.

Recommended Posts

Hello,

I have two adjacent divs that are placed throughout a few pages. The text is too close to the neighboring div. What is the best way to put a small buffer b/w these two?

Thanks

Edited by 803andy

Share on other sites

In most cases, adding a bit of margins or padding is the way to go about this. Sorta depends on how your site is currently coded.... You have a link to one of the pages (and specify which are the two divs that are "too close")?

Share on other sites

Thanks Ben,

I've been trying to use padding and margin, but the side text then flys off the page.

Below is my file (bare minimum):

http://www.sendspace.com/file/4kv863

Please let me know where I'm wrong.

Thnx

Share on other sites

//The right div will contain text and sometimes contain an image.

Share on other sites

Can you clarify -- in the HTML file, which are the two divs that you are talking about, and how exactly are you hoping to change what is there? Where are you wanting to add spacing?

Share on other sites

The solo_text & solo_left divs are too close. I would like some more space b/w the two. Depending on the words or the sentence the text and the two divs nearly touch in some instances.

I've tried padding and margin, but the results have always pushed one div completely out of focus.

Share on other sites

In general, I try to stay away from setting both a height and top/bottom margins/padding on the same element (or similarly, setting a width and a left/right margins or padding). This avoids some potential browser compatibility issues.

Your best bet here is to add a wrapper div within one of the two that will give it the padding you need. For example:

```
content here...

```

And then the css:

``` .left_wrapper { padding-right: 40px; }
```

Share on other sites

Thanks a lot, that idea is very slick..........

Share on other sites

Hmmmm... now the only problem is IE or IE6,

I'm using:

.left_wrapper {

}

I'm using the left_wrapper div right under the main_left div.

It works well in Firefox but it's going off the page in IE6

Share on other sites

I took a look at your code again... Check the "images/right_line.jpg" images which is within the .solo_text div. You have given them a width of 540px, but the .solo_text div is only 532px wide. That may be causing the issue you are experiencing.

Share on other sites

Text, text, text, text,

text, text Text, text, text, text, text, text Text, text, text, text, text, text Text, text,

text, text, text, text Text, text, text, text, text, text Text, text, text, text, text, text

Text, text, text, text, text, text Text, text, text, text, text, text:

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

Text, text, text, text, text, text Text, text, text, text, text, text Text, text, text, text,

text, text Text, text, text, text, text, text Text, text, text, text, text, text Text, text,

text, text, text, text Text, text, text, text, text, text Text, text, text, text, text, text

Creative Web Designs

Left left left left left left left left left left Left left left left

left left left left left left Left left left left left left left left left left

Affordable Pricing

ALeft left left left left left left left left left Left left left left

left left left left left left Left left left left left left left left left left

Share on other sites

Could it be the doctype??

Share on other sites

here is one way that I have tested and know that it works...

-- I've added a wrapper div surrounding the two columns, giving that the specific width and margin: 0 auto (margin top and bottom 0, margin left and right auto). I also added "overflow:auto" so it would correctly wrap around the two text columns

-- I also added a background color on both the body and the wrapper div to show where the columns were

Changing the doctype shouldn't affect the positioning of the columns, though I always use the strict doctype rather than transitional.

css:

```body { margin:0; background: #ffff00; }

.wrapper {
width: 780px;
margin:0 auto;
background: #fff;
overflow: auto;
}

.solo_text {
width: 540px;
float: right;
color: #999999;
font-size: 14px;
font-family: Verdana, Arial, Helvetica, sans-serif;

}
.solo_left {
width: 240px;
float: left;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;

}
.left_wrapper {
}```

html:

```br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Text, text, text, text,

text, text Text, text, text, text, text, text Text, text, text, text, text, text Text, text,

text, text, text, text Text, text, text, text, text, text Text, text, text, text, text, text

Text, text, text, text, text, text Text, text, text, text, text, text:

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

- Text Text

Text, text, text, text, text, text Text, text, text, text, text, text Text, text, text, text,

text, text Text, text, text, text, text, text Text, text, text, text, text, text Text, text,

text, text, text, text Text, text, text, text, text, text Text, text, text, text, text, text

Creative Web Designs

Left left left left left left left left left left Left left left left

left left left left left left Left left left left left left left left left left

Affordable Pricing

ALeft left left left left left left left left left Left left left left

left left left left left left Left left left left left left left left left left

```

Share on other sites

I hate to sound greedy....

The above code does work; however, when I try and implement it into the entire page, I am still getting an issue in IE6. I believe there is something small I'm missing:

I have attached the "full-webpage" with the wrapper class implemented. Its fine in fireworks but still acts up IE6.

http://www.sendspace.com/file/ac6u38

I appreciate your time in helping me troubleshoot this matter greatly!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×