>백엔드 개발 >PHP 튜토리얼 >PHP变量中加CSS代码。

PHP变量中加CSS代码。

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-06-23 14:15:281216검색

#scrolling_1 { width:635px; height:240px; overflow:hidden; padding:1px; border:1px solid #999; margin:0 auto; text-align: left; }#scrollnews_1 { position:absolute; width:645px; height:240px; overflow:hidden; display:inline; top:1; left:1; }#scrollnews_con_1 { width:645px; overflow:hidden; }#scrolling_1 ul { display:block; height:240px; width:645px; }#scrolling_1 ul li { height: 240px; width: 205px; float: left; overflow:hidden; display: inline; margin-right: 10px; }这个我想给PHP变量付值后输出。<?for (i=0 ;i=100; i++) {echo "#scrolling_1 { width:635px; height:240px; overflow:hidden; padding:1px; border:1px solid #999; margin:0 auto; text-align: left; }";#scrollnews_1 { position:absolute; width:645px; height:240px; overflow:hidden; display:inline; top:1; left:1; }#scrollnews_con_1 { width:645px; overflow:hidden; }#scrolling_1 ul { display:block; height:240px; width:645px; }#scrolling_1 ul li { height: 240px; width: 205px; float: left; overflow:hidden; display: inline; margin-right: 10px; }}?>这么写了以后,不正常了。我该怎么写呢?


回复讨论(解决方案)

for (i=0 ;i=100; i++) {
循环写错了吧

变量前面要加$

for ($i=0 ;$i=100; $i++) {

呵呵,
上面的代码写错了。
我从新写了。

#scrolling_1 { width:635px; height:240px; overflow:hidden; padding:1px; border:1px solid #999; margin:0 auto; text-align: left; }#scrollnews_1 { position:absolute; width:645px; height:240px; overflow:hidden; display:inline; top:1; left:1; }#scrollnews_con_1 { width:645px; overflow:hidden; }#scrolling_1 ul { display:block; height:240px; width:645px; }#scrolling_1 ul li { height: 240px; width: 205px; float: left; overflow:hidden; display: inline; margin-right: 10px; }这个我想给PHP变量付值后输出。<?for ($i=0 ;$i<=100; $i++) {echo "#scrolling_1 { width:635px; height:240px; overflow:hidden; padding:1px; border:1px solid #999; margin:0 auto; text-align: left; }";#scrollnews_1 { position:absolute; width:645px; height:240px; overflow:hidden; display:inline; top:1; left:1; }#scrollnews_con_1 { width:645px; overflow:hidden; }#scrolling_1 ul { display:block; height:240px; width:645px; }#scrolling_1 ul li { height: 240px; width: 205px; float: left; overflow:hidden; display: inline; margin-right: 10px; } }?>这么写了以后,不正常了。我该怎么写呢?

echo "****引号位置错了吧?? $i没用到 输出100个同样的样式?

呵呵,
上面的代码写错了。
我从新写了。

#scrolling_1 { width:635px; height:240px; overflow:hidden; padding:1px; border:1px solid #999; margin:0 auto; text-align: left; }#scrollnews_1 { position:absolute; width:645px; height:240px; overflow:hidden; display:inline; top:1; left:1; }#scrollnews_con_1 { width:645px; overflow:hidden; }#scrolling_1 ul { display:block; height:240px; width:645px; }#scrolling_1 ul li { height: 240px; width: 205px; float: left; overflow:hidden; display: inline; margin-right: 10px; }这个我想给PHP变量付值后输出。<?for ($i=0 ;$i<=100; $i++) {echo "#scrolling_1 { width:635px; height:240px; overflow:hidden; padding:1px; border:1px solid #999; margin:0 auto; text-align: left; }";#scrollnews_1 { position:absolute; width:645px; height:240px; overflow:hidden; display:inline; top:1; left:1; }#scrollnews_con_1 { width:645px; overflow:hidden; }#scrolling_1 ul { display:block; height:240px; width:645px; }#scrolling_1 ul li { height: 240px; width: 205px; float: left; overflow:hidden; display: inline; margin-right: 10px; } }?>这么写了以后,不正常了。我该怎么写呢?

你下面那些直接写在里面?
不用双引号

ID只能使用一次,你循环到第二次的时候,怎么可能再使用呢?

你的循环没什么用啊

重复输出统一的样式表 ? 不知道你要干什么,先把问题理清楚吧。

<?phpfor ($i=0 ;$i<=100; $i++) {echo "#scrolling_1 { width:635px; height:240px; overflow:hidden; padding:1px; border:1px solid #999; margin:0 auto; text-align: left; }#scrollnews_1 { position:absolute; width:645px; height:240px; overflow:hidden; display:inline; top:1; left:1; }#scrollnews_con_1 { width:645px; overflow:hidden; }#scrolling_1 ul { display:block; height:240px; width:645px; }#scrolling_1 ul li { height: 240px; width: 205px; float: left; overflow:hidden; display: inline; margin-right: 10px; }";}?>

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.