View Full Version : Div tags and pixel/percents
07-31-2009, 04:05 AM
Bit of a basic one...
I was considering today what do you use when having a div tag with text inside it? Should I be using pixel/percent - and why?
07-31-2009, 04:21 AM
I usually make all of my web pages a fixed width of 950px.
So my <div> sections are also fixed at various pixel widths.
If you want a fluid width page that changes widths based
on browser width, then you use percents.
It's simply a matter of personal preference.
This page (coding forums) that you're now viewing is based on percent.
Try resizing the width of your browser and see what happens.
07-31-2009, 11:28 AM
I am trying to create about 2-3 lines of text in the centre of the page. But when I resize my browser, I don't want it to change form and stretch and space out over 5 lines. I've tried both pixel and percentages.
07-31-2009, 11:34 AM
You may need to set a min-width to the container.
07-31-2009, 04:32 PM
Use inline CSS to control just those few lines ...
<span style="width:250px; text-align:justify;">
This is the text that makes up the few lines of content. blah blah blah blah
You can style that text however you want and it will then take-on your new
style, separately from the <div> where it resides.
07-31-2009, 06:41 PM
It's prob easier if I show you the site (http://thepsychologyforum.com/test/) if you resize the browser, you can see the words at the bottom blue area adjusting - I don't want this, I want them to fix fixed as you would see them in a normal res.
Is what you've told me suitable for that?
07-31-2009, 07:15 PM
Then set a width to that div or even a min-width. Wrapping them in a span won't work because you can't set a width on a span unless you make it display:block.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.