dynamic css per user - php

i have a gamimng section on my site that allow the user to display a quick status of their stats using colors (blue, red, and green).
i want to generate something like this based per user. i have this so far:
<style>
.box2 {
height: 20px;
background: blue;
float:left;
width:120px;
}
.box3 {
height: 20px;
background: green;
float:left;
width:30px;
}
.box1 {
height: 20px;
background: red;
float:left;
width:140px;
}
</style>
<div>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</div>
should i put the css directly in the page? what will be the best way to implement this using php?

You can always use a generated file using PHP and include it as your CSS file like:
<link rel="stylesheet" type="text/css" href="/css/userstats.php" />
Then in this file you can use the current session to find out the user stats then generate using PHP. Don't forget the put the header:
header("Content-type: text/css");
Example php:
background: #<?php echo $colorX; ?>; // assuming the $colorX is HEX
You can also if you prefer use .htaccess to rewrite the file so it looks less obvious like:
RewriteEngine On
RewriteBase /
RewriteRule ^css/userstats.css$ /path/to/generatedfile.php [L,NC]
So you can use:
<link rel="stylesheet" type="text/css" href="css/userstats.css" />
example code:
<style>
div.bar {
height: 25px;
}
div.bar div {
display: block;
float:left;
height: 25px;
margin: 0;
padding: 0;
position: relative;
}
div.bar div.red {
background: #DD3030;
-webkit-box-shadow: -5px 0px 8px 2px #DD3030;
-moz-box-shadow: -5px 0px 8px 2px #DD3030;
box-shadow: -5px 0px 8px 2px #DD3030;
width:140px;
-moz-border-radius-topleft: 8px;
-moz-border-radius-topright: 0px;
-moz-border-radius-bottomright: 0px;
-moz-border-radius-bottomleft: 8px;
-webkit-border-radius: 8px 0px 0px 8px;
border-radius: 8px 0px 0px 8px;
z-index:10;
}
div.bar div.blue {
background: #3388DD;
-webkit-box-shadow: 0px 0px 8px 2px #3388DD;
-moz-box-shadow: 0px 0px 8px 2px #3388DD;
box-shadow: 0px 0px 8px 2px #3388DD;
width:120px;
z-index:5;
}
div.bar div.green {
background: #1CAD32;
-webkit-box-shadow: 5px 0px 8px 2px #1CAD32;
-moz-box-shadow: 5px 0px 8px 2px #1CAD32;
box-shadow: 5px 0px 8px 2px #1CAD32;
width:30px;
-moz-border-radius-topleft: 0px;
-moz-border-radius-topright: 8px;
-moz-border-radius-bottomright: 8px;
-moz-border-radius-bottomleft: 0px;
-webkit-border-radius: 0px 8px 8px 0px;
border-radius: 0px 8px 8px 0px;
z-index:10;
}
</style>
<div class="bar">
<div class="red"></div>
<div class="blue"></div>
<div class="green"></div>
</div>
jsfiddle: http://jsfiddle.net/g9Vrx/

If the colors are fully customizable, then the best way is to either generate the CSS each time the page loads per user, or generate it once when the user changes the colors in his preferences, and store it in a cache or db. Then just extract it and use it.
Again, if the colors are fully customizable (not like a couple of predefined colors) you should include the CSS in the HTML page since modifying external CSS files with PHP is rather complicated and unnecessary.

Related

Curved <hr> S shape

I've been searching everywhere, how to make a html/css resonsive S shaped dotted line like this
So, far it has been the bain of my existence.
I'm trying to avoid SVG at all costs, althought i've also searched how to do it in SVG.
Can someone help me?
hr.style-seven {
height: 150px;
border-style: solid;
border-color: black;
border-width: 1px 0 0 0;
border-radius: 130px 0px 0px 0px;
border-top: 1px dashed #8c8c8c;
margin-right:130px;
}
hr.style-seven:before {
display: block;
content: "";
height: 150px;
margin-top: -151px;
border-style: solid;
border-color: black;
border-width: 0 0 1px 0;
border-radius: 0px 0px 130px 0px;
margin-left:130px;
margin-right:-130px;
border-bottom: 1px dashed #8c8c8c;
}
.box{ height: 500px; margin-top:200px;}
<body class="box">
<hr class="style-seven"/>
</body>
Demo

Modal box for options in Selectize.js

Is it possible to modify selectize.js? Instead of having a dropdown it will open a modal box for its options ? I am thinking of having a onfocus event then it will open that modal but prevent the dropdown. I'm just not sure how I can achieve it. and How I can populate the selectize once the modal options have been saved
It's usually not a good idea to customize a code library because you will not be able to upgrade to the next version. You are better off rolling your own solution using js and css. Actually making modal boxes is not that difficult, you just need to float a div at a higher z-index than the rest of the page, then put a transparent layer behind it to keep the user from clicking through to the background page. Here is some sample css and html I use to float a modal.
css
.BDT_Dialog_Layer {
position: absolute;
display: table;
top: 0px;
left: 0px;
height: 99%;
width: 99%;
}
.BDT_Dialog_Center {
position:fixed;
top:30%;
width:100%;
}
.BDT_Dialog_Decoration {
position:relative;
margin:0 auto;
text-align: center;
background-color: #ffffff;
display: table;
/* -- background-color: #DDDDDD;
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#FFFFFF' , endColorstr='#BBBBBB');
background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0.1, #FFFFFF), color-stop(1, #BBBBBB) );
background-image: -moz-linear-gradient( center top, #FFFFFF 10%, #BBBBBB 100% ); -- */
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
-khtml-border-radius: 15px;
border-radius: 15px;
-moz-box-shadow: 0 1px 8px #666666, 0 1px 4px #000000;
-webkit-box-shadow: 0 1px 8px #666666, 0 1px 4px #000000;
-khtml-box-shadow: 0 1px 8px #666666, 0 1px 4px #000000;
box-shadow: 0 1px 8px #666666, 0 1px 4px #000000;
}
html
<div id="dialogLayer" class="BDT_Dialog_Layer">
<div class="BDT_Dialog_Center">
<div class="BDT_Dialog_Decoration">
My stuff
</div>
</div>
here is the blocking layer css
div.BlockInteractionWithPage {
position: absolute;
top: 0px;
left: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
background-color: #ffffff;
opacity: 0.0;
filter: alpha(opacity=0); /* filter:alpha for IE8 and earlier */
height: 100%;
width: 100%;
}

Ajax display using php to display navigation with image display in directory

Hi can someone help me with this project here is the image
I'm having multiple problems if anyone can help me with this and some coding in here The image.php which has the blue image uses php that get's the image name, description , etc and the image is stored in a directory that the php calls only the name..
the problem is that when i call the page the image doesn't show but the data/ strings that comes from the database shows but not the image part how can i fix this??
also I have a navigation that connects to a database and shows the product list how can i use ajax here to add the product id name in the database so that i don't have to add more and more files just only one php page that displays the product and it's image in them here are the coding that i have used
CSS CODES
<style>
#body{
background-image:url(bg0.png);
background-repeat:repeat-x;
width:100%;
height:100%;
}
#header{
width:90%;
height:150px;
background-color:#39F;
margin:auto;
background-image:url(hd.png);
border-radius: 15px;
-moz-box-shadow: 3px 3px 4px #000;
-webkit-box-shadow: 3px 3px 4px #000;
box-shadow: 10px 10px 25px #000;
}
#himg{
border-radius: 0px 0px 0px 15px;
}
#navi{
float:left;
width:20%;
height: 500px;
margin-left: 74px;
margin-top: 10px;
border-radius: 100px 0px 100px 0px;
overflow:hidden;
position:relative;
background-color:#456B87;
background-image:url(nav1.png);
-moz-box-shadow: 3px 3px 4px #000;
-webkit-box-shadow: 3px 3px 4px #000;
box-shadow: 8px 10px 8px #000;
}
#navi ol{
clear:left;
float:left;
list-style:none;
margin:0;
padding: 0;
position:relative;
text-align:center;
left:50%;
vertical-align:middle;
display:table-cell;
}
#navi ol li{
display:block;
float:left;
list-style:none;
margin:0;
padding:0;
position:relative;
right:50%;
}
#navi ol li details{
border-style:solid;
border-radius: 25px 0px 25px 0px;
width: 200px;
background-color:#FDB735;
}
#navi ol li details summary::-webkit-details-marker { display:none; }
#bod{
background-color:#FFFFFF;
float:left;
width: 69%;
max-width: 69%;
margin-left: 9px;
margin-top: 10px;
height: 500px;
max-height: 500px;
border-radius: 15px;
background-image:url(nav1.png);
-moz-box-shadow: 3px 3px 4px #000;
-webkit-box-shadow: 3px 3px 4px #000;
box-shadow: 10px 10px 15px #000;
}
#main{
background-color:#FFFFFF;
width: 95%;
margin-top: 20px;
border-radius: 15px;
height: 90%;
}
</style>
AJAX / JAVASCRIPT CODE
<script language="JavaScript" type="text/javascript">
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest(); //Not IE
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP"); //IE
alert("Your browser doesn't support the XmlHttpRequest object. Better upgrade to Firefox.");
}
}
var receiveReq = getXmlHttpRequestObject();
function catia() {
if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
receiveReq.open("GET", 'products/product-display-cat.php', true);
receiveReq.onreadystatechange = handleCat;
receiveReq.send(null);
}
}
function handleCat() {
if (receiveReq.readyState == 4) {
document.getElementById('main').innerHTML = receiveReq.responseText;
}
}
</script>
End of java script
HTML CODE
<div id='navi'>
</br>
</br>
<ol>
<li><details>
<summary>Products</summary>
<table align='center'>
<tr>
<td><a href='javascript:cat();'>Catia</a></td>
</tr>
</table>
</details></li>
</ol>
</div>
END OF HTML CODE
This is the original page code that i was calling using ajax
<?php
$result = mysql_query("SELECT * FROM products WHERE ID='6'");
while($row = mysql_fetch_array($result))
{echo"
<tr><td><img src='image/1361663812.png'></td></tr>
<tr><td colspan='2'><img src='image/".$row['Logo']."'></td></tr>
<tr><td>Product: ".$row['Product']."</td></tr>
":}
?>
This is the end of the original page code
Some help or even a little help would be very much appreciated here and thanks for your time and effort! Sorry for the javascript i dont know how to show it properly and thanks again
Its ok i got it i used some javascript to cheat my way in showing the picture using this
document.getElementById('img').style.visibility = 'visible';
document.getElementById('img').style.display = 'block';
document.getElementById('img').src='products/image/1361663812.png';
after the ajax part

CSS Centering Problems

I'm having problems with my site i am currently trying to redesign it.
The site: Link
This is my css style-power.css
/* main body style */
body {
background: #c7ff9a;
color: #000000;
font-family: Tahoma, Verdana, sans-serif;
font-size: 12px;
margin: auto;
text-align:center;
}
.container {
width:1800px;
}
.bodycentre {
text-align: center;
width:1300px;
vertical-align:middle;
margin-left:40px;
margin-right:40px;
font-family: Tahoma, Verdana, sans-serif;
}
.header {
text-align:center;
vertical-align:middle;
background:url(../images/powerplay.png) center top no-repeat;
height:150px;
width:1300px;
margin: -10px 0 0 0;
border-bottom:2px solid #ddd;
border-left:2px solid #ddd;
border-right:2px solid #ddd;
box-shadow: 0 0 6px #000;
-moz-box-shadow: 0 0 6px #000;
-webkit-box-shadow: 0 0 6px #000;
padding: 4px 10px 4px 15px;
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
.menu {
position:relative;
float:left;
z-index:5001;
width:190px;
height:215px;
margin: 0 0 0 -305px;
border: 2px solid #ddd;
box-shadow: 0 0 6px #000;
-moz-box-shadow: 0 0 6px #000;
-webkit-box-shadow: 0 0 6px #000;
padding: 4px 10px 4px 15px;
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
.footer {
text-align: center;
vertical-align:baseline;
position: relative;
width:1300px;
}
Problem is that when you go to the link above the .menu div is not there i have fiddled with the css but it just doesn't center. Also when it did center the problem i also had was that when you zoomed in with the java-script zoom the menu was partly of the screen and you could not scroll over to it.
This is the code for the index page:
<link rel="stylesheet" type="text/css" media="screen" href="../styles/style-power.css" />
<div class="container">
<div class="header"></div>
<br />
<br />
<div class="menu">
<ul id="nav">
<p align="left"><strong>Power Play Pro Shop</strong></p>
<li>Home</li><br />
<li><strong>Deals</strong><ul>
<li>Balls</li>
<li>Bags</li>
<li>Shoes</li>
<li>Combos</li>
</ul></li>
<br>
<li>Doubles Home</li><br>
<li>Admin Login</li></ul>
</div>
<div class="bodycentre">
<h3>Power Play Pro Shop</h3>
<p> </p>
<h1>Deals</h1>
<p>Special Deals for the Bowlplex Doubles 2011</p>
<p>Balls</p>
<p>Bags</p>
<p>Shoes</p>
<p>Combos</p>
<p> </p>
<h2>Staff</h2>
<p><img src="../images/players_8_1.jpg" alt="Steve Thornton" width="150" height="200" border="1" /></p>
<p><strong>Steve Thornton</strong></p>
<p> </p>
<p> </p>
<p>For Admin Access Click Here</p>
</div>
<br />
<div class="footer">
<p>© 2011 David Passmore (David Passmore Web Development)</p>
</div>
</div>
Any help would be appreciated,
Thanks Guys and Girls!
Put it into your CSS:
.container > *{margin:0 auto}
There are a few other problems too. meta , link and code for IE should be in head, not body.
try,
.menu {
position:relative;
z-index:5001;
width:190px;
height:215px;
margin:0 auto;
border: 2px solid #ddd;
box-shadow: 0 0 6px #000;
-moz-box-shadow: 0 0 6px #000;
-webkit-box-shadow: 0 0 6px #000;
padding: 4px 10px 4px 15px;
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
just i remove float:left; and margin:0 auto;
i don't why are you put float but i worked your fiddle link. menu going center the page.

Why is my "Page [0]" not centered in my webpage?

My "Page [0]" text isn't centered on my webpage. Anyone know why? I could really use some help please.
Here is the html:
<html>
<head>
<title>Test Forum</title>
<link href="http://prime.programming-designs.com/test_forum/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<img src="http://prime.programming-designs.com/test_forum//images/banner1.png" alt="" id="banner" />
<h1>Test Forums</h1>
<hr />
<div id="navi"><div id="naviheader">Boards</div>Testing<br />General Discussion<br />Video Games<br />Anime and Manga<br />BlazBlue<br />Shin Megami Tensei<br />Earthbound<br />Phantasy Star<br />Mobile Suit Gundam<br /></div>
<div class="postbox"><h4>CyanPrime</h4><hr />Welcome to the King's Gate BBS!</div>Page: [0]
</body>
</html>
Here is the CSS:
#charset "windows-1252";
body{
background-color: #EEFFF8;
color: #000000;
text-align: center;
}
.postbox{
text-align: left;
margin: auto;
background-color: #dbfef8;
border: 1px solid #82FFCD;
width: 50%;
margin-top: 10px;
}
.stickypostbox{
text-align: left;
margin: auto;
background-color: #F5FFFA;
border: 1px solid #82FFCD;
width: 50%;
margin-top: 10px;
}
h4{
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
color: #9932CC;
}
h1{
color: #551A8B;
}
hr{
color: #82FFCD;
background-color: #82FFCD;
height: 1px;
border: 0px dotted #82FFCD;
}
a{
color: #7F00FF;
text-decoration: none;
}
a:hover{
color: #7F00FF;
text-decoration: underline;
}
form{
margin: 0px auto;
width: 50%;
}
#formdiv {
background-color:#dbfef8;
border:1px solid #82FFCD;
}
.fielddiv1{
background-color: #f9f9f9;
border: 1px solid #DBFEF8;
vertical-align: middle;
width: 45%;
float: left;
}
.fielddiv2{
background-color: #f9f9f9;
border: 1px solid #DBFEF8;
vertical-align: middle;
width: 100%;
}
.fieldtext1{
width: 50%;
background-color: #82FFCD;
float: left;
}
.fieldtext2{
width: 100%;
background-color: #82FFCD;
}
#replydiv{
width: 100%;
background-color: #DBFEF8;
margin: 10px 0 10px 0;
}
#admindiv{
width: 100%;
background-color: #DBFEF8;
margin: 10px 0 10px 0;
}
#navi{
width: 200px;
background-color: #dbfef8;
border: 1px solid #82FFCD;
text-align: left;
float: left;
}
#naviheader{
width: 100%;
background-color: #82FFCD;
}
#submitbutton{
border: 1px solid #82FFCD;
background-color: #DBFEF8;
color: #000000;
margin-top: 5px;
width: 100px;
height: 20px;
}
#banner{
border: 1px solid #82FFCD;
}
.postbar{
margin-right: 0px;
margin-top: 0px;
}
.bannedtext{
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
color: #FF0000;
}
And here is the webpage so you can get some context (you'll notice that my "page [0]" is centered on the other boards, but not the index. http://prime.programming-designs.com/test_forum/
The float on the left is pushing the content to the right. It's still centred across the line, but it's not centred across the page. Adding a large bottom margin to .postbox illustrates this.
Centreing problem illustrated http://img169.imageshack.us/img169/9027/williamhtmlproblem.png
My suggestion would be to wrap the footer in a <div>. Either clear: both; (or just left), add margins on either end to compensate for the floated element, or give it position: absolute; left: 0; right: 0; to force centreing across the page.
Change:
Page: [0]
To (wrap it in a div with pager class):
<div class="pager">Page: [0]</div>
Change this in your CSS:
.postbox, .pager{
text-align: left;
margin: auto;
width: 50%;
margin-top: 10px;
}
.postbox {
background-color: #dbfef8;
border: 1px solid #82FFCD;
}
.pager {
text-align: center;
}
The reason this is happening is because your float is pushing over your content. You pager is coming straight off the body tag. In general, it's best to wrap plain text inside an html element.
You may want to revisit the structure of your page. Create a left column and a center column div or something like that.

Categories