PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > Web Site Design > HTML/CSS/Javascript
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
Old 6-14-12, 12:10 AM   #1
sammiedawg
 
Join Date: Aug 2004
Location: syracuse
Posts: 360
Reputation: 5
Optimizing css stylsheet for different resolutions

I am working on building a blog. It is a simple blog with 3 columns.

When I change the width below from 86% to 75%, the middle (main) column looks perfect on my computer but then looks all out of wack on a different computer under a different resolution.

Is there a way that I can "define the width in concrete" so that the middle column looks the same under different resolutions?

Thanks



#doc {


background-color: #ffffff;

padding:0px;
width: 86%;
}
sammiedawg is offline   Reply With Quote
Old 6-14-12, 12:22 AM   #2
sammiedawg
 
Join Date: Aug 2004
Location: syracuse
Posts: 360
Reputation: 5
Or is there a way where I can do the following in css...

if resolution is 800+, then set width at 86%

if resolution is 420+, then set width at 75%
sammiedawg is offline   Reply With Quote
Old 6-14-12, 11:56 AM   #3
entrecon
Custom User Title
 
entrecon's Avatar
 
Join Date: Aug 2006
Location: Michigan
Posts: 2,669
Reputation: 337
Can't you set the width in px too instead of using % ?
__________________
________________________________
Find me on twitter: @entrecon
entrecon is offline   Reply With Quote
Old 6-14-12, 06:49 PM   #4
rainbore
Rick
 
Join Date: May 2002
Location: Minneapolis, MN
Posts: 1,696
Reputation: 280
You can use media queries in your stylesheet to control the display. While Internet Explorer didn't support them until IE9, this is not often an issue for checking screen width since the devices with limited dimensions all rely on compatible browsers.
Code:
@media screen and (min-width:420px) { #doc { width: 75%; } } @media screen and (min-width:800px) { #doc { width: 86%; } }
Searching on "media queries" should point you to some tutorials. Good luck!
__________________
Rick Trethewey
rainbore is offline   Reply With Quote
Old 6-14-12, 11:20 PM   #5
Builder
Thinkin' out loud again
 
Join Date: Nov 2002
Location: Illinois
Posts: 1,846
Reputation: 262
That is just sweet! I'll be putting that in my bag-o-tricks. I can see lots of potential in mobile browsers there.
__________________
A good friend will come and bail you out of jail...
but a true friend will be sitting next to you saying,
"Damn... that was fun!"
Builder is offline   Reply With Quote
Old 6-15-12, 10:34 AM   #6
tpoynton
Custom User Title
 
tpoynton's Avatar
 
Join Date: Sep 2004
Location: Mass
Posts: 2,119
Reputation: 293
It is precisely these posts that keep me on this forum, thanks Rick!
tpoynton is offline   Reply With Quote
Old 6-21-12, 09:24 PM   #7
sammiedawg
 
Join Date: Aug 2004
Location: syracuse
Posts: 360
Reputation: 5
Thanks Everyone.

Is it possible to apply this same "@media screen" width concept to images?

For example, right now I set the size of my image as width="612" height="559". However I would like the size of the image to adjust accordingly alongside the resolution.

for example-
Access blog on phone or tablet = smaller image
Access blog on desktop = larger image

Thanks!!
sammiedawg is offline   Reply With Quote
Old 6-21-12, 10:30 PM   #8
rainbore
Rick
 
Join Date: May 2002
Location: Minneapolis, MN
Posts: 1,696
Reputation: 280
The short answer is yes, of course. But this is one of many "God is truly in the details" issues you face in creating a site that's both desktop and mobile friendly. I'd suggest you start with this article on Combining Meta Viewport and Media Queries which is helpful because smart phones do not natively constrain themselves to the dimensions of their screens in pixels. They're perfectly happy to squeeze the page to fit the screen and let the user zoom in and out. Then, with that under your belt, you can check out another article, Responsive Web Design: 5 Handy Tips that has a good discussion on handling images for mobile devices.
__________________
Rick Trethewey
rainbore is offline   Reply With Quote
Old 7-10-12, 12:52 AM   #9
sammiedawg
 
Join Date: Aug 2004
Location: syracuse
Posts: 360
Reputation: 5
I have a 3-column wordpress layout (css). It is a mess under different resolutions. The widths of the 3 columns all mesh up under different resolutions

But for other blogs/sites that use 3-column wordpress layouts, this does not happen. Everything (images, columns, etc) decrease or increase in proportion to the resolution.

Is it because I did not define the width of the 3 columns? If so, how do I go about doing so? In the css style sheet?
sammiedawg is offline   Reply With Quote
Old 7-10-12, 12:56 AM   #10
sammiedawg
 
Join Date: Aug 2004
Location: syracuse
Posts: 360
Reputation: 5
I want to define a fixed-width for each of the 3 columns

thx!
sammiedawg is offline   Reply With Quote
Old 7-10-12, 10:35 AM   #11
rainbore
Rick
 
Join Date: May 2002
Location: Minneapolis, MN
Posts: 1,696
Reputation: 280
I can't be sure what the problem is without seeing the code, but if you want a fixed width for each of the columns then you should certainly define them.

Be sure to check out those two articles I suggested above. They will give you a good sense of what's involved in creating a site that dynamically changes depending on the user's screen dimensions using what they call "Responsive Design". It's not for everyone, though. Unless your site has the potential get a substantial amount of mobile traffic, I wouldn't sacrifice a solid design that works well on desktops and laptops. Smartphone users can still access those sites. It's just less convenient because they have to zoom in and out. Good luck!
__________________
Rick Trethewey
rainbore is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:34 PM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright © 2000-2007 Jelsoft Enterprises Limited.