Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-10-2004, 02:49 PM   #1 (permalink)
emus
Registered User
 
Join Date: Aug 2002
Posts: 3
emus is on a distinguished road
CSS float

Hi everyone,

I have a slight problem with the following code

Code:
<div style="float:left">abc</div>
<div style="border:1px solid #000000">def</div>
Why does the border encompass the first div when it is only specified in the second div?

Thanks,

emus
emus is offline   Reply With Quote
Old 04-10-2004, 06:41 PM   #2 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Hmm. I don't know that I've seen the float property used like that; you might try this instead (what I take you're going for) -
Code:
<div align="left">abc</div>
<div style="border:1px solid #000000";>def</div>
If I'm not mistaken, the float property makes the element's position 'absolute' for lack of a better word. It's static in its positioning, in other words. Other elements are supposed to flow around it, although another <div> tag may not (which is what we're seeing here)...
bdl is offline   Reply With Quote
Old 04-10-2004, 08:19 PM   #3 (permalink)
ender
Code Monkey
 
ender's Avatar
 
Join Date: Mar 2003
Location: Evansville, IN
Posts: 75
ender is on a distinguished road
Send a message via AIM to ender Send a message via Yahoo to ender
I think I have found some solutions to your problem, although they are not all that pretty.

The first thing you could do is make your side-bars a fixed width and then back non-floated div 100 px to the right to make it seem as though you want:

Code:
<div style="float:left; width:100px;">abc</div>
<div style="border:1px solid #000000; margin-left: 102px">def</div>
Another thing you could do is 'fake' the no-border like the following:

Code:
<div style="border-left: 1px solid #FFFFFF; border-right: 1px solid #000000;
	border-top: 1px solid #FFFFFF; border-bottom: 1px solid #000000;
	float: left; margin: 0px;">abc</div>
<div style="border:1px solid #000000;">def<br>ghi</div>
This however, is not very pretty as it forces you to have the non-floated div to have more than one line of content, and it forces some strict rendering tricks to get it to work.

I can look into this further if you want, but that is what I came up with for now.

Thanks,
Ted Morse
__________________
while(1) fork();
ender is offline   Reply With Quote
Old 04-11-2004, 03:47 AM   #4 (permalink)
emus
Registered User
 
Join Date: Aug 2002
Posts: 3
emus is on a distinguished road
Thanks a lot bdl and ender.
I'll try both solutions and let you know the results.


emus
emus is offline   Reply With Quote
Old 04-11-2004, 05:13 AM   #5 (permalink)
emus
Registered User
 
Join Date: Aug 2002
Posts: 3
emus is on a distinguished road
Here is what I did.

Since the right side is tabular data, I suppose it would be acceptable to use tables instead of divs.

Code:
<div style="float:left;margin-right:10px">Label</div>
<table style="border:1px solid #000000">
	<tr>
		<td> data 1</td>
	</tr>
	<tr>
		<td> data 2</td>
	</tr>
</table>
thanks again for your help,

emus
emus is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Explorer trouble (of course) easilyi HTML, XML, Javascript, AJAX 6 11-11-2004 03:59 PM
I'm having some problems with inheritance... <-- newb mik0rs Standard C, C++ 5 04-08-2003 10:54 PM
CSS question Miststlkr HTML, XML, Javascript, AJAX 7 12-05-2002 07:29 AM


All times are GMT -8. The time now is 04:44 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting