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

CSS variable width divs

4
Hi everyone, I'm new to the community but looking forward to answering questions myself. I've got the horizontal menu bar going across the top of my page. There is some stuff above it but it's not important. On the left of this menu sits a background-jpeg and then there are several "tabs" (links) after it. I placed each link inside a menuLink div, and floated them left, which works great.

My problem is I cannot set the widths for these tabs. The number of links will change depending on the page, so setting it to a % will not work. I obviously cannot set it to a px or other hard value because the customer will be using many different resolutions. I want this to be flush on the right, but it currently is not. Here is the code.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <link href="style2.css" rel="stylesheet" type="text/css">
  4.     </head>
  5.     <body>
  6.         <div name="menu" class="menu">
  7.             <div name="menuLinkDesktop" class="menuLink">
  8.                 <a href="" class="on">Desktop</a>
  9.             </div>
  10.             <div name="menuLinkFiles" class="menuLink">
  11.                 <a href="">Files</a>
  12.             </div>
  13.             <div name="menuLinkContacts" class="menuLink">
  14.                 <a href="">Contacts</a>
  15.             </div>
  16.             <div name="menuLinkCalendar" class="menuLink">
  17.                 <a href="">Calendar</a>
  18.             </div>
  19.             <div name="menuLinkEmail" class="menuLink">
  20.                 <a href="">Email</a>
  21.             </div>
  22.             <div name="menuLinkTasks" class="menuLink">
  23.                 <a href="">Tasks</a>
  24.             </div>
  25.             <div name="menuLinkMembership" class="menuLink">
  26.                 <a href="">Membership</a>
  27.             </div>
  28.         </div>
  29.     </body>
  30. </html>
  31.  
Expand|Select|Wrap|Line Numbers
  1. div.menu {
  2.     background-image: url('menuCorner.png');
  3.     background-repeat: no-repeat;
  4.     height: 19px;
  5.     padding-left: 297px;
  6. }
  7.  
  8. div.menu div.menuLink {
  9.     background-color: #003399;
  10.     float: left;
  11.     width: 13%;
  12.     height: 100%;
  13.     text-align: center;
  14.     vertical-align: middle;
  15.     border-right: 1px solid black;
  16. }
  17.  
  18. div.menu div.menuLink a {
  19.     font-family: Verdana, Helvetica;
  20.     font-size: x-small;
  21.     font-weight: bold;
  22.     text-decoration: none;
  23.     color: #F6F5F5;
  24. }
  25.  
Sep 1 '06 #1
1 5350
Stucco
4
Here's an easier example...

Expand|Select|Wrap|Line Numbers
  1. <style>
  2.  
  3. body {
  4.     margin: 0;
  5. }
  6.  
  7. div.parent {
  8.     border: 1px solid green;
  9.     height: 50px;
  10. }
  11.  
  12. div.parent div.child {
  13.     border: 1px solid blue;
  14.     float:left;
  15.     height: 100%;
  16.     width: 24%;
  17.     vertical-align: middle;
  18. }
  19.  
  20. </style>
  21.  
  22.  
  23. <div class="parent">
  24.     <div class="child">1</div>
  25.     <div class="child">2</div>
  26.     <div class="child">3</div>
  27.     <div class="child">4</div>
  28. </div>
  29.  
Sep 1 '06 #2

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

Similar topics

6
by: Jason Bassford | last post by:
Okay, What I'm trying to do is create two boxes, one on top of the other. The first is a static height, the 2nd, underneath it, should take up the remaining amount of screen space and overflow...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
25
by: Sune A | last post by:
Hi All! I'm having problems with www.suneworld.com The thing is that I'd like to lock the width of the page, so that it won't adjust dynamically. Any CSS people out there that can help me? ...
5
by: Josh Renaud | last post by:
I'm still trying to solve a problem I have experienced in Safari. This is my third post on the subject. I'm hoping someone can shed some light. The problem is that, in Safari, a table with no...
18
by: day | last post by:
I know I've seen this issue described before, but I can't find it, or the solution now that I need it. I have some css-specified floating divs that contain images or text. The text divs have a...
11
by: Rob | last post by:
I know, I know, don't use frames. Well, I'm stuck with these frames and I'm trying to add functionality without a complete redsign. You can look at this as a nostalgic journey. Anyway, I've got...
0
by: JamesBong | last post by:
So I am building something with divs that will be filled with dynamic data... so I dont know how tall the divs will be, but I want to make sure that div has a margin so the next div is 25px below the...
1
by: JamesBong | last post by:
I am building something with divs that will be filled with dynamic data... so I dont know how tall the divs will be, but I want to make sure that div has a margin so the next div is 25px below the...
11
by: yawnmoth | last post by:
How do you get both of these div's to have a 100% width? (1): <div style="float: left; background: black; color: white">Hello, world! </div> <div style="clear: both; background: blue; color:...
12
by: daniel2335 | last post by:
This problem is everywhere! I have read all forums available, spent about 40+ hours on it and lost a bit of hair. I was going to explain what its ment to look like but I just realised removing the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.