2012-05-10 94 views
0

我嘗試使div class和style在一起,但不知何故style不起作用。我沒有找到答案..這裏是代碼div class and style in PHP

PHP

<div class="table"> 
<p><b>TEXT here</b><br /> 
...</p> 
<div class="table_cell" style="width=180px !important; color=red !important;"><p>1<br />2<br />3<br />4<br />5<br />6</p></div> 
<div class="table_cell" style="width=645px !important;"><p><b>&euro; 282</b><br /></p></div> 
<p>Good luck in the future</p></div> 

CSS中的DIV定義

div.table{ 
margin: 10px; 
padding: 10px; 
width: 825px; 
border: 1px solid; 
background: #E0F8EC; 
border-radius:10px; 
} 

div.table_cell{ 
margin-top: 10px; 
margin-bottom: 10px; 
float: left; 
} 

風格不工作,除了一個從外部CSS文件。在樣式屬性

回答

6

執行CSS語法:

style="width:180px; color:red;" 
+3

另外,當您定義內聯樣式時,您不需要!重要,它們已經具有優先級。 – gcochard

0

在你的風格,使用您在CSS使用(注意冒號(:)兩者之間的相同name:value;語法:

<div class="table"> 
<p><b>TEXT here</b><br /> 
...</p> 
<div class="table_cell" style="width:180px !important; color:red !important;"><p>1<br />2<br />3<br />4<br />5<br />6</p></div> 
<div class="table_cell" style="width:645px !important;"><p><b>&euro; 282</b><br /></p></div> 
<p>Good luck in the future</p></div> 
0

語法類似於width: 100px !important而不是width=100px !important