473,385 Members | 2,004 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,385 software developers and data experts.

Using % instead of px

OK I have read some docs about fluid layout. The point is to use %
instead of fixed-size staff with px, right?

So for example if I have 3-columns I should define something like this:
..left {width:20%;}
..right {width:10%;}
..center{width:65%;}

But what happens if I have an image on .left for example which let's say
is 250px width. Then I want .left to be at least 250px so that the
picture is shown always. What then? How do I define size?

thanks
Nov 29 '06 #1
7 2734
Scripsit Harris Kosmidhs:
OK I have read some docs about fluid layout. The point is to use %
instead of fixed-size staff with px, right?
No, the point is to avoid setting widths, letting browsers select the
widths. Of course, in _some_ cases you might set _some_ width.
So for example if I have 3-columns I should define something like
this: .left {width:20%;}
.right {width:10%;}
.center{width:65%;}
First, your class names are poor. They refer to your intended layout, not to
the meanings of the blocks. Second, you are apparently trying to imitate
frames and waste about 30 % of available width (which might be less than you
imagine) to "navigation". While this is not (yet) judged as a mortal sin,
it's bad practice, and as you realize it one day, you'll realize how poor
the class names like "left" are.
But what happens if I have an image on .left for example which let's
say is 250px width.
It wastes more space than you can afford. So don't put such an image there.
Then I want .left to be at least 250px so that the
picture is shown always. What then? How do I define size?
In _fluid_ layout, you don't. If a block contains an image that is 250
pixels wide, this apparently sets a minimum width for the block, and other
factors probably cause that will also be the maximum width.

If problems recur, post the URL.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Nov 29 '06 #2
Jukka K. Korpela wrote:
>So for example if I have 3-columns I should define something like
this: .left {width:20%;}
.right {width:10%;}
.center{width:65%;}

First, your class names are poor. They refer to your intended layout,
not to the meanings of the blocks. Second, you are apparently trying to
imitate frames and waste about 30 % of available width (which might be
less than you imagine) to "navigation". While this is not (yet) judged
as a mortal sin, it's bad practice, and as you realize it one day,
you'll realize how poor the class names like "left" are.
this was just an example. It's div.left actually.
>But what happens if I have an image on .left for example which let's
say is 250px width.

It wastes more space than you can afford. So don't put such an image there.
again an example. But I have a 450px logo on center column.
>Then I want .left to be at least 250px so that the
picture is shown always. What then? How do I define size?

In _fluid_ layout, you don't. If a block contains an image that is 250
pixels wide, this apparently sets a minimum width for the block, and
other factors probably cause that will also be the maximum width.
so min-width will be set automatically to 250px? So I just do <img
src="logo"??
Nov 29 '06 #3

Harris Kosmidhs wrote:
OK I have read some docs about fluid layout. The point is to use %
instead of fixed-size staff with px, right?
As a gross simplification.
But what happens if I have an image on .left for example which let's say
is 250px width.
Then a _totally_ fluid layout is inappropriate for you in this case
(this isn't unusual).

min-width is a useful property here to give a robust layout that's
still highly fluid. Of course, guess which browser doesn't support
it....

Other techniques are to start nesting <div>s and fix the widths of the
inners, letting the outers follow percentage sizes, and letting the
browsers fight it out. Generally the results are acceptably good, but
no-one claims they're perfect.

This stuff is hard to do well. I suggest reading the source of some of
the better tutorials out there (try glish.com or bluerobot) and seeing
the issues they've had to deal with.
PS = "left" is fine as a class name, so long as you understand what
you're doing. If you really mean "Get the damned thing onto the left if
at all possible" then it's reasonable. If you can re-state it more
generally as "where the major nav menu lives" then it might be better
to give it a class name like that. Remember that sometimes your "left"
is going to find itself rendered at the top of the page anyway (on my
skinny-screened phone, for instance) -- can you live with this?

Conversely, it's better to have a class called "left" if you're really
using this as a "presentational bucket" <divin the HTML where you
collect all those things you want to force in that direction, whether
they're menus or stock tickers (you might have a further element inside
there that is called "nav-menu"). It's better than having a bucket,
calling it something like <div class="nav-menu">, using the CSS to
float it leftwards, and still having all sorts of baggage in there
that's anything but a nav-menu.

Base your class names on what you're doing with the HTML and what the
_essence_ of how you're using the HTML is. Think about the results of
applying your CSS to them as very much secondary to this. But if the
function of the HTML element is still purely presentational (and
sometimes it just is), then don't be afraid of putting anodyne
presentational names on it.

Nov 29 '06 #4
Scripsit Harris Kosmidhs:
this was just an example.
Not really. It was just a sketch of a draft of an example. A URL would have
meant giving an example.

And "left" etc. as class names are _bad_ examples. Giving them as examples
means that you really use such names. Really.
It's div.left actually.
The class name there is "left".
>It wastes more space than you can afford. So don't put such an image
there.

again an example. But I have a 450px logo on center column.
Again, a bad sketch of a draft of an example. And eating up 450 pixels means
eating up more than 250 pixels.
so min-width will be set automatically to 250px?
What? The initial value of min-width is 0. But why would that matter?
So I just do <img src="logo"??
Don't. But you might consider doing

<img alt="ACME" src="logo.gif" width="200" height="20">

if you cannot satisfactorily represent the logo as styled text. (Actually,
far too many "logos" on web pages are just text in image format so that the
particular appearance is _not_ the company's established shape for its name
or abbreviation, used consistently in different media. That is, they aren't
logos at all. A _genuine_ logo should probably be presented as an image,
since text styling isn't accurate and reliable enough.)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Nov 29 '06 #5
Harris Kosmidhs wrote:
Jukka K. Korpela wrote:
>First, your class names are poor. They refer to your intended layout,...

this was just an example. It's div.left actually.
What Jukka is suggesting is that you name the class "navigation" or
maybe "menu" instead of "left".

Use something like "sidebar" instead of "right".
Use something like "content" instead of "center".
If you've a banner ad at the top, call the class "banner" instead of
"top".

This way, if in the future you decide to move the navigation to the top,
or above the sidebar, you won't have a "left" on the right.

Here is a sample of a three-column template:
http://benmeadowcroft.com/webdev/css.../3-column.html

--
-bts
-Motorcycles defy gravity; cars just suck
Nov 29 '06 #6
In article
<jy*********************@bgtnsc04-news.ops.worldnet.att.net>,
"Beauregard T. Shagnasty" <a.*********@example.invalidwrote:
This way, if in the future you decide to move the navigation to the top,
or above the sidebar, you won't have a "left" on the right.

Here is a sample of a three-column template:
http://benmeadowcroft.com/webdev/css.../3-column.html
OK B, time to fess up. How much do you get per plug for this url?
Is Ben Meadowcroft family? <g>

--
dorayme
Nov 29 '06 #7
dorayme wrote:
"Beauregard T. Shagnasty" <a.*********@example.invalidwrote:
>This way, if in the future you decide to move the navigation to the top,
or above the sidebar, you won't have a "left" on the right.

Here is a sample of a three-column template:
http://benmeadowcroft.com/webdev/css.../3-column.html

OK B, time to fess up. How much do you get per plug for this url?
Is Ben Meadowcroft family? <g>
$0.00. No, Ben is not family, no idea who he is; I just like his
example.

--
-bts
-Motorcycles defy gravity; cars just suck
Nov 29 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
22
by: Bradley | last post by:
Has anyone else noticed this problem? I converted the back-end to A2000 and the performance problem was fixed. We supply a 97 and 2000 version of our software so we kept the backend in A97 to make...
1
by: Epson Barnett | last post by:
Hi, I'm new to C# and I'd like to be able to reference a field of an object using a variable instead of literal text. In the PHP scripting language, you can create a variable: $var = "name";...
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
3
by: Faisal | last post by:
Hi. I'm in the process of moving an application from ASP to ASP.NET, & I'm writing in VB, using VS.NET. I'm new to the .NET framework & have a basic question regarding static objects defined in...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
4
by: duffaz | last post by:
I am trying to I am trying to connect to an SQL Server using a vb.net program. It works if I put it on the SQL Server computer, but will not connect over my local network that is set up as a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
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...

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.