473,414 Members | 1,691 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,414 software developers and data experts.

How to get rid of the gap between Div tags

Frinavale
9,735 Expert Mod 8TB
Hi there!

I'm creating a control that lets user's enter a time value using two text boxes and two buttons. When the user clicks the button, the text box value for the hours or minutes change....that's just JavaScript stuff and it works fine.

My problem is that I want to have a "Start" time and an "End" time in my control and I've run into a few problems manipulating the look of the controls.

What I'd like is to have the two text boxes beside each other (the text box for the hour followed by the text box for the minutes) and the buttons beside (to the left) of the text boxes...where the buttons are on top of one another...

I have it so that the text boxes are in their own <div> and the buttons in their own <div>. The buttons have been moved using CSS to be beside the text boxes. I couldn't use float because of issues I've been experiencing with Firefox.

Right now it looks okay except for the Huge gap between the Start time and the End time.

I think this gap is occurring because I'm moving the buttons beside the text boxes using position:relative and left,top,&bottom.

Could someone please help me get rid of this gap.

I've included my code so far...its pretty simple. I apologize for the asp tags, and I hope they don't confuse you.

Thanks a lot for your time!


Expand|Select|Wrap|Line Numbers
  1. <div class="picker">
  2.              <div id="hrStart">
  3.                 <div class="time">
  4.                     <asp:TextBox ID="TXT_HrStart" runat="server" MaxLength="2" Height="20px" Width="15px"></asp:TextBox>&nbsp;<asp:TextBox ID="TXT_MinStart" runat="server" MaxLength="2" Height="20px" Width="15px"></asp:TextBox>
  5.                 </div>
  6.                 <div class="timeAdjustingButtons">
  7.                     <div style="padding:0 0 0 0;">
  8.                         <input type=button ID="BTN_UpStart" runat="server"  style="height:20px; Width:20px; font-size:smaller;" value="↑" />
  9.                         <input type=button ID="BTN_DownStart" runat="server" style="height:20px; Width:20px; font-size:smaller;" value="↓"  />
  10.                     </div>
  11.                 </div> 
  12.             </div>
  13.  
  14.             <div class="hrEnd">
  15.                 <div class="time">
  16.                     <asp:TextBox ID="TXT_HrEnd" runat="server" MaxLength="2" Height="20px" Width="15px"></asp:TextBox>&nbsp;<asp:TextBox ID="TXT_MinEnd" runat="server" MaxLength="2" Height="20px" Width="15px"></asp:TextBox>
  17.                 </div>
  18.                 <div class="timeAdjustingButtons">
  19.                     <div style="padding:0 0 0 0;">
  20.                         <input type=button ID="BTN_UpEnd" runat="server"  style="height:20px; Width:20px; font-size:smaller;" value="↑"  />
  21.                         <input type=button ID="BTN_DownEnd" runat="server" style="height:20px; Width:20px; font-size:smaller;" value="↓"  />
  22.                     </div>
  23.                 </div> 
  24.             </div>     
  25.         </div>
  26.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. .hrStart
  3. {
  4.  
  5. }
  6. .hrEnd
  7. {    clear:both;
  8.     padding:3px 0px 0px 0px;
  9. }
  10. .picker
  11. {    height:auto;
  12.     width:80px;
  13.     border:solid 1px LightSteelBlue;
  14.     text-align:left;
  15. }
  16. .pickerTitle
  17. {    height:auto;
  18.     width:80px;
  19.     border:solid 1px LightSteelBlue;
  20.     text-align:center;
  21.     background-color:Silver;
  22. }
  23.  
  24. .time
  25. {    padding:0px 5px 0px 5px;
  26.     text-align:left;
  27.     position:static;
  28.     width:50px;
  29.     /*background-color:Yellow;*/
  30.  
  31. }
  32. .timeAdjustingButtons
  33. {
  34.     padding:0px 0px 0px 0px;
  35.     text-align:left;
  36.     width:20px;
  37.     position:relative;
  38.     left:55px;
  39.     top:-35px;
  40.     bottom:-35px;
  41.     /*background-color:Green;*/
  42. }
  43. #hrStart
  44. {    padding:10px 0px 0px 0px;
  45.     width:100%;
  46. }    
  47. #hrEnd
  48. {    width:100%;
  49. }
  50.  
May 16 '07 #1
13 10064
drhowarddrfine
7,435 Expert 4TB
Any way you can give us html out of that? It is hard to decipher.

EDIT: Never mind. I figured it out.

What problems are you having with the floats? It's usually IE that has float problems.
May 16 '07 #2
drhowarddrfine
7,435 Expert 4TB
It's hard for me to work with this because I didn't want to eliminate some things because I don't know what else is planned. It looks like you have a touch of 'div-itis', the need to wrap everything in a div, and there is a lot of unnecessary css. I had to stop what I was doing to go somewhere but this sort of does what you want. It can be simplified further.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6. <style type="text/css">
  7.  
  8. .picker
  9. {    height:auto;
  10.     width:80px;
  11.     border:solid 1px LightSteelBlue; /* Not a valid color */
  12.     text-align:left;
  13. }
  14.  
  15. textarea
  16. {    
  17.     float:right;
  18.     padding:0;
  19.     text-align:left;
  20.     width:20px;
  21.     /*background-color:Yellow;*/
  22.  
  23. }
  24. .timeAdjustingButtons
  25. {
  26.     padding:0;
  27.     text-align:left;
  28.     width:20px;
  29. }
  30. </style>
  31.  
  32. </head>
  33.  
  34. <body>
  35.     <div class="picker">
  36.             <div class="hrStart">
  37.               <div class="time">
  38.               <textarea rows=1 cols=5></textarea>
  39.           </div>
  40.                     <div class="timeAdjustingButtons">
  41.  
  42.                             <input type=button ID="BTN_UpStart" style="height:20px; Width:20px; font-size:smaller;" value="↑" >
  43.                             <input type=button ID="BTN_DownStart" style="height:20px; Width:20px; font-size:smaller;" value="↓"  >
  44.  
  45.                     </div>
  46.         </div>
  47.  
  48.     <div class="hrEnd">
  49.             <div class="time">
  50.                 <textarea rows=1 cols=5></textarea>
  51.             </div>
  52.         <div class="timeAdjustingButtons">
  53.  
  54.                 <input type=button ID="BTN_UpEnd" style="height:20px; Width:20px; font-size:smaller;" value="↑"  >
  55.                 <input type=button ID="BTN_DownEnd" style="height:20px; Width:20px; font-size:smaller;" value="↓"  >
  56.  
  57.         </div>
  58.         </div>     
  59.     </div>
  60. </body>
  61. </html>
  62.  
May 16 '07 #3
Frinavale
9,735 Expert Mod 8TB
It's hard for me to work with this because I didn't want to eliminate some things because I don't know what else is planned. It looks like you have a touch of 'div-itis', the need to wrap everything in a div, and there is a lot of unnecessary css. I had to stop what I was doing to go somewhere but this sort of does what you want. It can be simplified further.
Thanks for helping Drhowarddrfine!

I definitely have a touch of "div-itis". I'm quite new to CSS and especially quite new to <div> tags.

I'm finding it really challenging to get this stuff to work the way I think it should.
The problem I'm having with FireFox is that the floating tags are floating out side (and on top) of their containing <div>.

I've made the changes that you've recommended (removed those unnecessary <div>) but when I run it in FireFox they are still floating out side of the containing box.

Do you have any recommendations on how to fix this problem?
(I guess it was the original problem because that gapping thing was happening while I was trying to work around it)

-Frinny
May 17 '07 #4
Frinavale
9,735 Expert Mod 8TB
According to W3C's articles on the topic of float:
  • float: left The image or text will float to the left in the parent element
  • float: right The image or text will float to the right in the parent element
  • float:none The image or the text will be displayed just where it occurs in the parent element

If its supposed to float the element within the parent element, why do my elements always float on top of my parent element in FireFox?

CSS is a confusing place.
I'm starting to realize why I like doing the back end of things so much.

-Frinny
May 17 '07 #5
drhowarddrfine
7,435 Expert 4TB
I don't know that article but it may be in a certain context. Parent elements are NOT to expand to contain floated elements automatically, though we can make it happen. You may see IE do this but it is a bug in IE. This, along with a bazillion other bugs, are reasons why you should never use IE as the browser you design with. All versions, including IE7, are nine years behind web standards or incorrect in their interpretation of the standard. Always use a modern browser like Firefox or Opera as your reference for how things should work. Then we can adjust for IEs quirks and bugs because they are well known, documented and fixable (in most cases).

Once you get your head wrapped around it, CSS isn't that bad. It usually works just fine in Firefox and the only headache is getting IE to cooperate. When I was learning, the tutorial that really helped me was this one. You can gain a lot from this one too.

When people start thinking CSS, too many times they feel <div>'s are part of it and necessary, but divs are HTML and have nothing to do with CSS. They are only there to help with structure and the ability to manipulate their positioning is a bonus. So it's entirely possible to find and create pages that have no div elements at all.

Remember that any element can be positioned using CSS and you don't need it wrapped in a div to do so. I only use divs to keep related elements together so they won't interfere with other elements on the page.
May 17 '07 #6
Frinavale
9,735 Expert Mod 8TB
I don't know that article but it may be in a certain context. Parent elements are NOT to expand to contain floated elements automatically, though we can make it happen. You may see IE do this but it is a bug in IE. This, along with a bazillion other bugs, are reasons why you should never use IE as the browser you design with. All versions, including IE7, are nine years behind web standards or incorrect in their interpretation of the standard. Always use a modern browser like Firefox or Opera as your reference for how things should work. Then we can adjust for IEs quirks and bugs because they are well known, documented and fixable (in most cases).
Working with a browser other than IE isn't so easy to do. I'm working with Visual Studio 2005 to develop an ASP.NET application. VS 2005 creates its own little "happy world" and everything always works perfectly until I move it to the web server and see the horror that has actually been created through another browser.

Every time I make a change I have to re-publish the website to my server in order to see it in another browser and this process is very time consuming. I'd love to start designing in Firefox and work my way backwards to IE and IE6 (*shivers*) because it seems like the logical thing to do.

Once you get your head wrapped around it, CSS isn't that bad. It usually works just fine in Firefox and the only headache is getting IE to cooperate. When I was learning, the tutorial that really helped me was this one. You can gain a lot from this one too.

When people start thinking CSS, too many times they feel <div>'s are part of it and necessary, but divs are HTML and have nothing to do with CSS. They are only there to help with structure and the ability to manipulate their positioning is a bonus. So it's entirely possible to find and create pages that have no div elements at all.

Remember that any element can be positioned using CSS and you don't need it wrapped in a div to do so. I only use divs to keep related elements together so they won't interfere with other elements on the page.
I'm going to check out the links you sent me! You've been a great help and have pointed me in the right direction (I've already started to remove my <div>'s). I've never done a project that needs to be quite so visually pleasing as this one and in the past I've always used tables to produce the look I wanted. I want to get it right this time and get away from tables.

Now that I'm starting to understand CSS a bit more, this doesn't feel so much like torture.

:) Thank you for the sound advice!

-Frinny
May 18 '07 #7
I strongly disagree - IE is much better to build your website off. It's better to start off with IE because the changes you make in IE usually work the same for all other browsers.

Try your website in different browsers along the way - you usually don't have to change the coding if you base it in IE. But add extra codes that work for that particular browser.

Saves you basically re-doing your whole site.
Sep 26 '08 #8
David Laakso
397 Expert 256MB
I IE is much better to build your website off. It's better to start off with IE because the changes you make in IE usually work the same for all other browsers.
Nothing personal, sarahxclare, but that is a naive conclusion that belongs at the top of the list of worst possible best practice.
Sep 26 '08 #9
David Laakso
397 Expert 256MB
Could someone please help me get rid of this gap.
Dunno. There are at least a zillion probable causes. Could you put the page in question on a public server and point to it in your post to the forum so that those of us who are not too bright can have some idea of what in the world you are talking about, and perhaps eliminate some among the zillion probable causes for a gap...?
Sep 26 '08 #10
Frinavale
9,735 Expert Mod 8TB
Dunno. There are at least a zillion probable causes. Could you put the page in question on a public server and point to it in your post to the forum so that those of us who are not too bright can have some idea of what in the world you are talking about, and perhaps eliminate some among the zillion probable causes for a gap...?
Thanks for trying to help Dave but I solved the problem over a year ago. I can't even remember the solution...but I was quite new at using CSS at the time.

I find it amusing how people have such strong opinions about web-browsers because I never favor one browser over another.

Since this thread I have figured out how to develop with multiple browsers....Visual Studio 2008 just checks which is the default and lets you debug with it. I typically just work directly on the web server so I can load up any browser without changing the settings.

What most web developers have to realize is that even though they have a preferred web-browser, your users may be using anything. When developing web applications I constantly jump between different browsers and never really "start in" IE, or FireFox, or Safari, or Opera....I just use them all.

I do however favor FireBug...a tool that lets you debug CSS, JavaScript and other web page issues.

There are tools out there for Safari and even one for IE (although this one needs to be improved upon a lot before I start using it regularly)

But really, don't start using one browser and move to another...just use them all regularly to check your web content.
Sep 26 '08 #11
drhowarddrfine
7,435 Expert 4TB
But really, don't start using one browser and move to another...just use them all regularly to check your web content.
This is still a naive method of doing things. You can't use Internet Explorer to make sure your markup is written correctly. If you do, and it shows what you want, you will be jumping around to other browsers trying to force them to work like IE. But IE is old, broken and non-compliant. So you would be trying to force your broken code to work in modern browsers. The point is, if you want to write modern code you have to test it first in browsers that understand and work properly with modern code. That has NEVER been IE and won't be true in IE8 either.

Plus, you show you don't realize that markup that works in the modern browsers (that is, not IE) will typically work everywhere and that markup written in IE will typically not work anywhere else. I know of NO developer that would use ANY version of IE as their initial test and THAT is where your humor at such things should disappear. IE8 will still be 10 years behind web standards.

Microsoft has publicly stated they wish their browser worked like the others. Never, ever, ever use IE to test your code for proper implementation.

Now what most Microsofties always hear in alll that is "Don't make your page work in IE" which, of course, I've never said. I'll repeat what I did say. You want to make sure your code is working right so check it in a browser that works right. Then you can look and see if IE botches it up (and it probably will). The hacks, quirks and bugs of IE are all well known and published on hundreds of web sites so it will be relatively easy to fix IE.

And for those who still don't get it: But it works in IE!
Sep 26 '08 #12
David Laakso
397 Expert 256MB
Thanks for trying to help Dave but I solved the problem over a year ago. I can't even remember the solution...but I was quite new at using CSS at the time.
What help? You got a uri for that page or not?
Sep 26 '08 #13
Frinavale
9,735 Expert Mod 8TB
What help? You got a uri for that page or not?
I no longer need help with this issue since it has been resolved over a year ago.
I was probably just having problems because I was using so many <div> tags.

I would love to show off my product but it's a private web application that cannot be accessed through the web.

-Frinny
Sep 26 '08 #14

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

Similar topics

7
by: varois83 | last post by:
Hi I am fairly new to PHP/mysql and was reading an online tutorial and learned that my short tags weren't enabled. At this time I have no need for them, my setup apache/mysql/php runs on my PC...
0
by: Philippe Poulard | last post by:
People that have a knowledge of XQuery, XSLT, Ant, JSP/PHP/ASP, Cocoon, XMLBeans, taglibs and many others should recognize any of them in "Active Tags". " Active Tags is a set of specifications...
24
by: Day Bird Loft | last post by:
Web Authoring | Meta-Tags The first thing to understand in regard to Meta Tags is the three most important tags placed in the head of your html documents. They are the title, description, and...
7
by: Jasper Bryant-Greene | last post by:
I have three tables: `photos`, `tags` and `tags_photos`. The `photos` table contains a unique ID and a bunch of other stuff, the `tags` table contains a unique ID and a tag name, and the...
1
by: Jenny | last post by:
Hi, Can I create an array of tags by assigning same name to these tags? For example, I have two <p> tags with the same name t1. But document.all.b.value=document.all.t.length does not...
12
by: Oberon | last post by:
I have a large HTML document. It has hundreds of <span>s which have no attributes so these <span>s are redundant. How can I remove these tags automatically? The document also has <span>s with...
12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
23
by: Big Bill | last post by:
http://www.promcars.co.uk/pages/bonnie.php I don't believe they should be there, can I take them out without stopping the includes from functioning? I'm the (hapless) optimiser on this one... I...
3
by: Paul Moore | last post by:
I'd like to write some scripts to analyze and manipulate my music files. The files themselves are in MP3 and FLAC format (mostly MP3, but FLAC where I ripped original CDs and wanted a lossless...
1
by: arrival123 | last post by:
Hello, I'm currently trying to decide on a database design for tags in my web 2.0 application. The problem I'm facing is that I have 3 separate tables i.e. cars, planes, and schools. All three...
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...
0
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,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...
0
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...

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.