First question, so be forgiving if you can:
Using PHP I've created a site where users enter info and it is saved to database. Users then style each entry (font, size, color, and location). A string is saved into the database for each parameter, and then I use PHP to echo
out a DIV with the custom styling:
echo "<div id=\"customized\"";
if(isset($backtype)){if($backtype == "image") {echo "style=\"background-image:url('".$backurl."');
background-repeat: no-repeat; background-size: 400px 200px\"";}}
if(isset($backtype)){if($backtype == "color"){echo "style=\"background-color:".$backcolor."\"";}}echo ">";
if($namepos !== ""){echo "<div id=\"".$namepos."\" style=\"font-family:".$namefont."; font-size:".$namesize."; color:".$namecolor.";\">".$name."</div>";}
After getting strings from database this becomes:
<div id="customized" style="background-image:url('raptor.gif'); background-repeat: no-repeat; background-size: 400px 200px ">
<div id="3_1" style="font-family:Courier New; font-size:20pt; color:#f80a8c;">Text here</div></div>
When this DIV is created all the inline styling works, but the location it display is supposed to be dictated by the $namepos
, which echoes out "3_1".
I have an external CSS as follows
#customized {
border: 1px solid grey;
margin: 3px;
position: absolute;
top: 7%;
left: 1%;
width: 400px;
height: 200px;
}
#3_1{
position: absolute;
white-space: nowrap;
top:10%;
left:5%;
}
The final output completely ignores this CSS for the div that is produced by doing echo $namepos
, but works perfectly fine for the containing div id=" customized"
.
I fear that I already know the answer and that it just doesn't work for the dynamically named DIV, but I'm an amateur and if this is true then it's a serious setback, so I come here hoping for a savior.
Any help would be greatly appreciated.