The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> CSS Help
|
CSS fill remaining width of a screen
Discuss CSS fill remaining width of a screen in the CSS Help forum on Dev Shed. CSS fill remaining width of a screen Cascading Style Sheets (CSS) forum discussing all levels of CSS, including CSS1, CSS2 and CSS Positioning. CSS provides a robust way of applying standardized design concepts to your web pages.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 10th, 2003, 09:04 PM
|
 |
Contributing User
|
|
Join Date: Aug 2002
Location: Queensland, Australia
|
|
|
CSS fill remaining width of a screen
Well, I'm finding that using <DIV> with CSS for layout purposes is far more complex then using <TABLE>
How do I make an element, such as <SPAN>, fill the remaining width of a screen using CSS?
For example, let's say I have an images and a single line of text enclosed by <DIV>, I want to place a <SPAN> on the right of the the text (also within the DIV) and have it stretch to the right side of the screen.
Is this possible? It would be simple using tables.
__________________
Ooh, they have the Internet on computers now!
|

June 10th, 2003, 10:02 PM
|
|
Contributing User
|
|
Join Date: Sep 2002
Location: Canberra, Australia
Posts: 348
  
Time spent in forums: 1 Day 34 m 44 sec
Reputation Power: 12
|
|
|
you could use
width: 100%;
text-align: left;
That may work. I haven't tested it, should work with IE but the rest ???
|

June 10th, 2003, 10:42 PM
|
 |
Contributing User
|
|
Join Date: Aug 2002
Location: Queensland, Australia
|
|
|
Unfortunately the width attribute is calculated on the width of your screen. So if your browser window is 800 pixels wide then "width" will return 800. If you put this element beside something like I want to it will either wrap to the next line or increase the width of your page beyond the width of the window.
|

June 11th, 2003, 06:16 AM
|
 |
Senior Polecat
|
|
Join Date: Jun 2003
Location: Jersey (the original version)
Posts: 210
Time spent in forums: 59 m 57 sec
Reputation Power: 10
|
|
|
i had the very same problem.
my solution was to create the spav at 100% width - 0px from the top and the left and then use the margin attribute (or it might have been clipping) to force the text over to the right. Then i put my lefthand vertical div over the top of the main span.
It's a lame way of doing it but it worked for me.
Of course what you really want is some kind of alternative size system similar to * in framesets but i don't see this being implemented until the next release of CSS
Icy
|

June 11th, 2003, 06:48 AM
|
 |
|<.+#f@#+.&.|
|
|
Join Date: Mar 2002
Location: norway
|
|
|
remember you can't normaly set width to a span. its for inline style-
though browsers like ie let you set width to it, others like mozilla will not,
you could use display:block in the span and then set a width.
but then again you could just as well have used a div tag.
|

June 11th, 2003, 05:36 PM
|
 |
Contributing User
|
|
Join Date: Aug 2002
Location: Queensland, Australia
|
|
|
The problem with setting the width is that I don't know how wide the screen is and the content on the left may change width from browser to browser.
icy_polecat looks to have the best option.
It's surprising that something this trivial wasn't implemented into the current version of CSS.
|

June 11th, 2003, 06:36 PM
|
 |
|<.+#f@#+.&.|
|
|
Join Date: Mar 2002
Location: norway
|
|
|
i'm not completely
getting your problem
so if you phrase it a bit better, i might be albe to help,
why do you want the span to fill the whole width? just to have another background color, or?
|

June 11th, 2003, 07:00 PM
|
 |
Contributing User
|
|
Join Date: Aug 2002
Location: Queensland, Australia
|
|
|
I've attached a picture which shows how I'm using it.
You will see that between the pale green and the dark green area's there is a black line (border-bottom). But the line stops after the "PELM Enquiries" link. I need it to continue to all the way across.
The pale green area is dfined by a DIV which enloses a series of SPAN tags and the links that have Border-Bottom set. The dark green is defined by another DIV. I've done it this way as I don't want a border below the link for the current page, in this case "About PELM".
I was hoping I could simply put in a SPAN after PELM Enquiries to fill this gap with a black line.
Perhaps there is an easier way to do this?
|

June 11th, 2003, 07:26 PM
|
 |
Contributing User
|
|
Join Date: Aug 2002
Location: Queensland, Australia
|
|
|
My attachment doesn't appear to have attached. I'll try again.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|