473,587 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

div CSS Width Setting

8 New Member
Hi, I have a question about setting the widths of divs with CSS that I have a feeling will be answered simply with a "no".

I have some divs that I want to have conform to the right hand side of their content but I don't want to arbitrarily set their widths to a set measurement or percentage. However if I don't specify a width it defaults to 100% of the page width. Is there any way I can set the width to automatically shrink to that of the content?

Cheers

Phil
Nov 8 '06 #1
6 2198
drhowarddrfine
7,435 Recognized Expert Expert
Yes, the answer is no.
Nov 8 '06 #2
PlexusMaldon
8 New Member
Yes, the answer is no.
Thought so, thanks for that.

If anyone has found a neat way of doing this is CSS rather than having to go back to tables, I'd appreciate an overview, and if I work out an alternative I'll post it here.

Cheers

Phil
Nov 9 '06 #3
drhowarddrfine
7,435 Recognized Expert Expert
In what way does tables do that without setting a width?
Nov 9 '06 #4
PlexusMaldon
8 New Member
In what way does tables do that without setting a width?
I'm referring to the effect you can get with a table with the border set to 0 and a background colour so that if its width is less than the page width it will only take up however much room it actually requires, and no more, so it looks like a "frame". As I'm moving to CSS, I don't want to (ab)use tables for these sort of layout purposes any more.
Nov 10 '06 #5
drhowarddrfine
7,435 Recognized Expert Expert
I'm not sure I'm correctly picturing what you want to do. Do you have a screenshot or link? I think you can do what I think you want.
Nov 10 '06 #6
PlexusMaldon
8 New Member
I'm not sure I'm correctly picturing what you want to do. Do you have a screenshot or link? I think you can do what I think you want.
Is it possible to upload local images to this server (I'm guessing not as the IMG tag looks like it only serves online images) as I don't have anywhere I can load images up to, to create links to?
Nov 13 '06 #7

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

Similar topics

2
4977
by: Kai Grossjohann | last post by:
I would like to put a text input field (in the sense of <input type="text">) and an image next to each other, where I know the size in pixels of the image, and I know the total width in em. I haven't found a way to do this. I tried <span style="width:20em"> <input type="text"> <img width="25px" src="...">
5
6093
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge of the screen. I want it to only extend as far as it needs to to nicely contain the content within (a couple of links). Is width: auto the wrong...
4
9527
by: Matt | last post by:
Hi, Got an unordered list with 100% width, with 5 list items of 20% width styled to fill the width of the container element. Renders fine in Mozilla, but when you change the size of the window in IE, the last item in the list has a nasty tendency to wrap down to the next line (and stay there). I can hack it (imperfectly) by setting the...
2
2229
by: Paresh Dhakan | last post by:
Hi ! I am facing a wierd problem in setting the width of a form to 20. Suppose I create two forms Form1 and Form2. Form1 is the container, meaning this.IsMdiContainer = true; Form2 is child form meaning,
4
2764
by: Hiwj | last post by:
I am having a problem with a cell in a table in ASP.NET which used to work OK in classic ASP. I have one cell in a row where the width should be 22 pixels and the other cell should take up the remainder of the width available. In ASP.NET the 2nd cell (when set to 100%) is 500 pixels wide (hence overlapping the image in row 1), wheras in...
50
6035
by: Shadow Lynx | last post by:
Consider this simple HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Strict kills my widths!</title> </head> <body> <table style="width:400px; table-layout:fixed;">
4
39338
by: Man-wai Chang | last post by:
-- iTech Consulting Co., Ltd. Expert of ePOS solutions Website: http://www.itech.com.hk (IE only) Tel: (852)2325 3883 Fax: (852)2325 8288
4
5081
by: p.numminen | last post by:
Is it possible, with CSS, to determine a certain _maximum_ width for a text, paragraph, division, etc.?
5
54684
by: mohaaron | last post by:
OK, I have now gone through lots of posts, and there are lots, looking for a anwer as to why I can't set the width of the columns in my gridview. So far I have tried the following methods to set the width and nothing works. 1. <asp:BoundField HeaderText="fieldName" ItemStyle-Width="300px" DataField="fieldName" /> 2. <asp:BoundField...
2
3199
by: paul | last post by:
I have a JS function to change the width of a <divthat works great in Firefox, but not at all in IE7. In IE an error message occurs: Line: 92 Char: 5 Error: Invalid Argument Code: 0 Firefox reports no errors in the Error Console, or Firebug, and the <divis resized correctly. Here is the function:
0
7920
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.