CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 13th, 2013, 06:40 AM
ingeborg.haarr ingeborg.haarr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 5 ingeborg.haarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 23 sec
Reputation Power: 0
Help with PHP (I'm new)

This is probably an easy fix,

I want a div-tag on my site to appear only when a use screen resolution is greater than 1024px (it's a floating left "fixed" navigation div that doesn't look good on iPhone). Is this possible? Is PHP the right way to do it, or is it possible with CSS too?

Code:
    <div id="floatNav">
    
    	<ul> 
    	
    		<li>Quick Navigation</li> 
    		<li>&nbsp;</li>
    		<li><a href="#top">Back to Top</a></li> 
    	
    	</ul>
    </div>

Code:
	#floatNav {
		float:left;
		position:fixed;
		padding-right: 20px;
		margin-top: 50px;
		left: 0;
		background: #00dc8f;
		border-radius: 0px 12px 12px 0px;
	}
	
	#floatNav li {
		list-style-type: none;
		margin-left: -20px;
		font-size: 0.7em;
		color: #ffffff;
	}


I thought that with PHP I could use an "if" command or something.

Thanks for any help!

Reply With Quote
  #2  
Old February 13th, 2013, 07:05 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,875 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 4 h 42 m 18 sec
Reputation Power: 813
Hi,

PHP doesn't know anything about the screen solution of the client, because it runs on the server and not in the browser (like JavaScript). All it knows is the user agent (browser), but this information isn't really reliable, because it can be set to anything.

Google for "mobile website" to check common practices of making websites ready for mobile devices.

Reply With Quote
  #3  
Old February 13th, 2013, 10:11 AM
paulh1983 paulh1983 is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2004
Posts: 2,237 paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 11 h 3 m 46 sec
Reputation Power: 201
google search for meta queries that allow you to target devices of specific width.

Reply With Quote
  #4  
Old February 13th, 2013, 10:26 AM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,811 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 19 h 13 m 52 sec
Reputation Power: 6112
thread moved to CSS, though this may be a JS question.
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #5  
Old February 13th, 2013, 12:24 PM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Dev Shed God 30th Plane (19500 - 19999 posts)
 
Join Date: Jul 2004
Location: USA
Posts: 19,835 Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level) 
Time spent in forums: 6 Months 1 Day 22 h 10 m 33 sec
Reputation Power: 4192
Welcome to DevShed Forums, ingeborg.haarr.

Quote:
Originally Posted by paulh1983
google search for meta queries that allow you to target devices of specific width.

"Meta queries"? Perhaps you mean "media queries"? Media queries are the best way to do this.
Comments on this post
paulh1983 agrees: sorry that is what i meant.. doh!
__________________
Spreading knowledge, one newbie at a time. I'm available for hire at Dynamic Site Solutions.

Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

Remember people spend most of their time on other people's sites (so don't violate web design conventions).

Reply With Quote
  #6  
Old February 14th, 2013, 02:08 AM
Galadai Galadai is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 16 Galadai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 47 m 18 sec
Reputation Power: 0
Javascript is the easiest way

Javascript is the way to go about this.

Code:
function getPageWidth()
{
	var html = document.getElementsByTagName('html');
	var pageWidth = parseInt(getComputedStyle(html[0],"").getPropertyValue('width'));
	return (pageWidth);
}

// For Browser width use
if (getPageWidth() < 1024) document.getElementById("floatNav").style.display = "none";

// For full screen width use
if (screen.width < 1024) document.getElementById("floatNav").style.display = "none";


That should do it

Reply With Quote
  #7  
Old February 14th, 2013, 02:00 PM
Paul-Ninja Paul-Ninja is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Location: Troy, NY
Posts: 36 Paul-Ninja User rank is Second Lieutenant (5000 - 10000 Reputation Level)Paul-Ninja User rank is Second Lieutenant (5000 - 10000 Reputation Level)Paul-Ninja User rank is Second Lieutenant (5000 - 10000 Reputation Level)Paul-Ninja User rank is Second Lieutenant (5000 - 10000 Reputation Level)Paul-Ninja User rank is Second Lieutenant (5000 - 10000 Reputation Level)Paul-Ninja User rank is Second Lieutenant (5000 - 10000 Reputation Level)Paul-Ninja User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 15 h 32 m 38 sec
Reputation Power: 66
Javascript is unnecessary. Just use this rule in your css:

Code:
@media only screen and (max-width:1024px) {
.floatnav {display:none }
}
Comments on this post
ManiacDan agrees: Slick

Reply With Quote
  #8  
Old February 14th, 2013, 07:01 PM
Galadai Galadai is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 16 Galadai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 47 m 18 sec
Reputation Power: 0
That is neat. I've learned something

Reply With Quote
  #9  
Old February 15th, 2013, 12:04 AM
ingeborg.haarr ingeborg.haarr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 5 ingeborg.haarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 23 sec
Reputation Power: 0
Thank you so much everyone! I'm going to try it later on and get back to you if it doesn't work ;-)

Reply With Quote
  #10  
Old February 16th, 2013, 03:49 AM
ingeborg.haarr ingeborg.haarr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 5 ingeborg.haarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 23 sec
Reputation Power: 0
Talking

Tried it! Worked like a charm. The code I used:

Code:
@media only screen and (max-width:1024px) {
.floatnav {display:none }
}


Thanks

Reply With Quote
  #11  
Old February 18th, 2013, 10:34 AM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Dev Shed God 30th Plane (19500 - 19999 posts)
 
Join Date: Jul 2004
Location: USA
Posts: 19,835 Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level) 
Time spent in forums: 6 Months 1 Day 22 h 10 m 33 sec
Reputation Power: 4192
In case it wasn't clear, what Paul-Ninja posted is an example of a Media Query tailored to answer this specific question.

Quote:
Originally Posted by Galadai
Javascript is the way to go about this.

Why use getComputedStyle? IE8 doesn't support it (to be fair, IE8 doesn't support CSS3 Media Queries either). Isn't it easier to use innerWidth and/or clientWidth instead?

The good thing here is that the media query is used to give a style to mobile devices, so it doesn't matter very much that old versions of IE will ignore it. (Though they will show that element even when the browser window less wide than 1024px, which is probably more likely for people who rarely upgrade.)

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Hiding DIVs based on screen resolution [was: Help with PHP (I'm new)]

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap