Jump to content

Adjust Text Size - Load CSS File


Dysan

Recommended Posts

Using PHP, is it possible to load different CSS files, upon different images being clicked?

 

Altogether, there will be 4 different text size settings, can the user can select, depending on how big the text needs to be, in order for the user to see correctly.

 

Upon each image being clicked, how do I load a different style sheet (CSS File)?

Link to comment
Share on other sites

you can create external link for your CSS and call them if they are called..

 

so you will put the names of your file in a variable and call it when needed..

 

or maybe if you only mean class do it the same you may store your class name in an array and call them when needed

Link to comment
Share on other sites

You can have each image to be a link with a query string to query your PHP conditional validation; something like:

 

 

<a href="<?php echo "". $_SERVER['PHP_SELF'] .""; ?>?layout=1"><img src="smallfont.jpg" border="0"></a>
<a href="<?php echo "". $_SERVER['PHP_SELF'] .""; ?>?layout=2"><img src="regularfont.jpg" border="0"></a>
<a href="<?php echo "". $_SERVER['PHP_SELF'] .""; ?>?layout=3"><img src="largefont.jpg" border="0"></a>
<a href="<?php echo "". $_SERVER['PHP_SELF'] .""; ?>?layout=4"><img src="xlargefont.jpg" border="0"></a>

 

 

<link rel="stylesheet" type="text/css" href="<?php

$layout = $_GET['layout'];

if ($layout == "1")
{
echo "stylesheet1.css";
}
else if ($layout == "2")
{
echo "stylesheet2.css";
}
else if ($layout == "3")
{
echo "stylesheet3.css";
}
else if ($layout == "4")
{
echo "stylesheet4.css";
}
else
{
echo "stylesheet1.css";
}
?>"\>

 

I would also set a cookie or create a session; that would keep displaying the style sheet they choose; until the cookie or session expired. This way, they do not have to keep reseting the font size to their prefered viewing size.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.