Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

div dynamic width

Status
Not open for further replies.

SlykFX

Programmer
Oct 12, 2002
76
GB
ive got divs strewn thoughout my page with stuff like navigation, positioning, etc. in them that are resulting in different lines of the page being different widths
is it possible to form some method of giving a div tag a variable width based on where the div lies

i need this done in css as it is a section div and can be called multiple times on one page so i dont want to have to give each one a fixed width every time i use one

iev tried using width:100%; but this wont do as all the nav/positioning divs are required to float so they can be positioned correctly

i.e.
at the top of the page the section div needs to be 525px half way doen it needs to be only 450px and at the bottom of the page it needs to be 600px, obviously as content changes, the position of the div will also change so i cant hard-code any fixed size

if what im after isnt possible then it doesnt matter as im using spans and sorting the widths using padding, but im not happy with as all the section divs are different sizes

thanks for any help

I can't be bothered to have a sig!
 

Why not use CSS? You can have a base "class" for your DIVs that sets up most of the properties, and have an ID that sets the specifics for each unique DIV. Something like this:

Code:
<style type="text/css">
.myDivs {
   /* generic DIV stuff here */
}
#div1 {
   /* div1 specific stuff goes here */
   width: 525px;
}
#div2 {
   /* div2 specific stuff goes here */
   width: 450px;
}
</style>

...

<div class="myDivs" id="div1">...</div>
<div class="myDivs" id="div2">...</div>

Hope this helps,
Dan


 
thats how i do have it it setup, dont think i explaned it very well

ive got a left hand navigation div expanding down for most of the page and in some areas a right hand div that may only be a few lines in height
because i want text to flow round these, im not using a center div

but i do require some centre section divs that fill the space between either the left navigation div and the right hand side of the page or the left hand navigation div and the right hand side div tags with variable content in them

they are all setup in css, the left nav div has a fixed width of 150px, the right divs can be anything from 50px to 150px or even none at all, the whole page width is a fixed width of 750px

I can't be bothered to have a sig!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top